Results 1 to 15 of 15

Thread: [RESOLVED] Mouse Click using vb.net

  1. #1

    Thread Starter
    Fanatic Member uniquegodwin's Avatar
    Join Date
    Jul 2005
    Location
    Chennai,India
    Posts
    694

    Resolved [RESOLVED] Mouse Click using vb.net

    Hello..
    Can someone tell me how can I trigger mouse click event whenever I want at any position on the screen where the mouse pointer is?
    Thanks
    Godwin

    Help someone else with what someone helped you!

  2. #2
    Fanatic Member
    Join Date
    May 2005
    Posts
    898

    Re: Mouse Click using vb.net

    On the sceen or on your app's window?
    "so just keep in mind that fantasy is not the same as realtiy and make sure u remember that wii sports may be fun but u cant count on it as exercise ok cool bye" - HungarianHuman

  3. #3

    Thread Starter
    Fanatic Member uniquegodwin's Avatar
    Join Date
    Jul 2005
    Location
    Chennai,India
    Posts
    694

    Re: Mouse Click using vb.net

    Not on my apps window...On screeen...anywhere on the screen ...startmenu anywhere (that includes apps window too)
    Godwin

    Help someone else with what someone helped you!

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Mouse Click using vb.net

    You just use the Shared Cursor.Position property.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    Re: Mouse Click using vb.net

    from all api
    Declare Sub mouse_event Lib "user32" Alias "mouse_event" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)

    change long to integer, and look it up online for examples
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Mouse Click using vb.net

    Quote Originally Posted by jmcilhinney
    You just use the Shared Cursor.Position property.
    Forget I said that. D*mn, must read questions properly before posting.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    Re: Mouse Click using vb.net

    Quote Originally Posted by jmcilhinney
    Forget I said that. D*mn, must read questions properly before posting.
    I do that all the time
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  8. #8

    Thread Starter
    Fanatic Member uniquegodwin's Avatar
    Join Date
    Jul 2005
    Location
    Chennai,India
    Posts
    694

    Re: Mouse Click using vb.net

    ok,how do I change this c# statement into vb.net?
    Code:
    public enum MouseEventFlags
      {
        LEFTDOWNE  = 0x00000002,
        LEFTUP     = 0x00000004,
        MIDDLEDOWN = 0x00000020,
        MIDDLEUP   = 0x00000040,
        MOVE       = 0x00000001,
        ABSOLUTE   = 0x00008000,
        RIGHTDOWN  = 0x00000008,
        RIGHTUP    = 0x00000010
      }
    It gives me an error if I simply put it like
    VB Code:
    1. Public Enum MouseEventFlags
    2.         LEFTDOWNE  = (0x00000002)
    3.     LEFTUP     = 0x00000004
    4.     MIDDLEDOWN = 0x00000020
    5.     MIDDLEUP   = 0x00000040
    6.     MOVE       = 0x00000001
    7.     ABSOLUTE   = 0x00008000
    8.     RIGHTDOWN  = 0x00000008
    9.     RIGHTUP    = 0x00000010
    10.     End Enum
    I have the c# code sample for that API...im trying to convert it to vb.net..and this enum also is used there for it
    Godwin

    Help someone else with what someone helped you!

  9. #9

    Thread Starter
    Fanatic Member uniquegodwin's Avatar
    Join Date
    Jul 2005
    Location
    Chennai,India
    Posts
    694

    Re: Mouse Click using vb.net

    vb.net says it expects end of statement..Thats the error its giving for that enum..What should I do?
    Godwin

    Help someone else with what someone helped you!

  10. #10

    Thread Starter
    Fanatic Member uniquegodwin's Avatar
    Join Date
    Jul 2005
    Location
    Chennai,India
    Posts
    694

    Re: Mouse Click using vb.net

    oops,I guess u told me to look at allapi.net...i was wondering what u meant by "from all api" first.
    now i got it...Ill check there now..I saw this from pinvoke.net
    Godwin

    Help someone else with what someone helped you!

  11. #11

    Thread Starter
    Fanatic Member uniquegodwin's Avatar
    Join Date
    Jul 2005
    Location
    Chennai,India
    Posts
    694

    Re: Mouse Click using vb.net

    Nevermind,I got it...
    Thank You Mr.Polite,you did something so so so so Great...You saved my life by letting me know about that API.
    Thank you Jm too...This method which you told me is the one I was just using...I found it just 2 days back from a code sample...You still tried to help too and have helped me in many things before Thanks
    Godwin

    Help someone else with what someone helped you!

  12. #12

    Thread Starter
    Fanatic Member uniquegodwin's Avatar
    Join Date
    Jul 2005
    Location
    Chennai,India
    Posts
    694

    Re: Mouse Click using vb.net

    Hello people...
    here is an example...Hope it helps someone
    VB Code:
    1. Declare Sub mouse_event Lib "user32" Alias "mouse_event" (ByVal dwFlags As Integer, ByVal dx As Integer, ByVal dy As Integer, ByVal cButtons As Integer, ByVal dwExtraInfo As Integer)
    2.        Private Const MOUSEEVENTF_ABSOLUTE = &H8000 ' absolute move
    3.     Private Const MOUSEEVENTF_LEFTDOWN = &H2 ' left button down
    4.     Private Const MOUSEEVENTF_LEFTUP = &H4 ' left button up
    5.     Private Const MOUSEEVENTF_MOVE = &H1 ' mouse move
    6.     Private Const MOUSEEVENTF_MIDDLEDOWN = &H20
    7.     Private Const MOUSEEVENTF_MIDDLEUP = &H40
    8.     Private Const MOUSEEVENTF_RIGHTDOWN = &H8
    9.     Private Const MOUSEEVENTF_RIGHTUP = &H10
    10.  
    11.     Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    12.         mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 1)
    13.     End Sub
    Ive set a timer to keep the mousedown...
    but now,Im in need of something else too...capturing the mouse event apart from clicking it...fine,Ill start a new thread for that...I wonder if theres a way to do that without APIs
    Godwin

    Help someone else with what someone helped you!

  13. #13
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    Re: [RESOLVED] Mouse Click using vb.net

    nicely done

    remove the extra constants though lol, they don;t seem to be used
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  14. #14
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    Re: [RESOLVED] Mouse Click using vb.net

    umm I'm looking at this page about this on MSDN,
    http://msdn.microsoft.com/library/de...ouse_event.asp

    it says This function has been superseded. Use SendInput instead.
    I don't know what, if any, problems might occur if you stick with this function, but apparently using SendInput is the more correct way
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  15. #15
    New Member
    Join Date
    Sep 2005
    Posts
    4

    Re: [RESOLVED] Mouse Click using vb.net

    but,this mouse event function works so perrrfecttt..theres no problem at all...but,very easy to make an annoying autoclick program with it by putting it in a timer.. maybe thats why they brought something better...i dont know,but this one works soo perfect and mouse buttons left right and middle can all be controlled smoothly including all their events up,down,etc.I think sendkeys doesnt have so much control over the mouse

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width