Results 1 to 13 of 13

Thread: Mouse Click?

  1. #1

    Thread Starter
    Hyperactive Member Emo's Avatar
    Join Date
    Jul 2000
    Posts
    428

    Question

    Hello,
    Can somebody tell me how can I make it so when I start my program and point the mouse to a particular spot it will click on that spot in 30 seconds or so? I know I'll have to use the timer for the 30 seconds, but I don't know how to make the mouse click...
    Thanks!
    -Emo
    -=VB6 Enterprise Edition=-
    -=VC++6Enterprise Edition=-
    «¤E³m°O²™¤»

  2. #2
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    Oetje
    [email protected]
    93606776
    Visual Basic 6, Windows 2000

    Never pet a burning dog

  3. #3

    Thread Starter
    Hyperactive Member Emo's Avatar
    Join Date
    Jul 2000
    Posts
    428

    Smile

    Thanks A lot!
    -=VB6 Enterprise Edition=-
    -=VC++6Enterprise Edition=-
    «¤E³m°O²™¤»

  4. #4

    Thread Starter
    Hyperactive Member Emo's Avatar
    Join Date
    Jul 2000
    Posts
    428

    Unhappy Thanks BUT

    I posted the "Thanks A lot" reply before I tested the code, and it turns out that it just moves the mouse to a spot but it doesn't actually make the mouse "click". So if anyone has any suggestions, Please help me!
    Thanks
    -Emo
    -=VB6 Enterprise Edition=-
    -=VC++6Enterprise Edition=-
    «¤E³m°O²™¤»

  5. #5
    Guest
    Code:
    Declare Function Imitate Lib "user32" Alias "GetKeyboardState" _
    (pbKeyState As Byte) As Long
    
    Enum MouseButton
    LeftButton = 1
    RightButton = 2
    MiddleButton = 4
    End Enum
    
    Sub ClickOnMouse (Button as MouseButton)
      Imitate Button
    End Sub
    Usage:

    Code:
    ClickOnMouse LeftButton

  6. #6
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    To make the mouse click:
    Code:
    	mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
    	mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0,
    Oetje
    [email protected]
    93606776
    Visual Basic 6, Windows 2000

    Never pet a burning dog

  7. #7
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    Escaflowne, I didn't see your post.
    Oetje
    [email protected]
    93606776
    Visual Basic 6, Windows 2000

    Never pet a burning dog

  8. #8

    Thread Starter
    Hyperactive Member Emo's Avatar
    Join Date
    Jul 2000
    Posts
    428

    Thumbs up Thanks!

    Thanks for your posts you guys!
    What about if I want to make the "Enter" key to go off with the timer every 30 sec?
    -=VB6 Enterprise Edition=-
    -=VC++6Enterprise Edition=-
    «¤E³m°O²™¤»

  9. #9
    Guest
    Use:
    Code:
    ClickOnMouse &H0D

    OR with sendkeys:
    Code:
    Sendkeys {Return}

  10. #10
    Guest
    http://www.vbapi.com/ref/k/keybd_event.html

    Code:
    Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As _
    Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal _
    dwExtraInfo As Long) 
    
    Const VK_RETURN = &HD
    Const KEYEVENTF_KEYUP = &H2
    
    
    keybd_event VK_RETURN, 0, 0, 0  ' press Enter
    keybd_event VK_RETURN, 0, KEYEVENTF_KEYUP, 0  ' release Enter

  11. #11
    Guest
    Here's the full codes for ClickonMouse (not just enum):
    01 Left mouse button
    02 Right mouse button
    03 Control-break processing
    04 Middle mouse button (three-button mouse)
    08 backspace key
    09 tab key
    0C clear key
    0D enter key
    10 shift key
    11 ctrl key
    12 alt key
    13 pause key
    14 caps lock key
    1B esc key
    20 spacebar
    21 page up key
    22 page down key
    23 end key
    24 home key
    25 left arrow key
    26 up arrow key
    27 right arrow key
    28 down arrow key
    29 select key
    2B execute key
    2C print screen key
    2D ins key
    2E del key
    2F help key
    30 0 key
    31 1 key
    32 2 key
    33 3 key
    34 4 key
    35 5 key
    36 6 key
    37 7 key
    38 8 key
    39 9 key
    41 a key
    42 b key
    43 c key
    44 d key
    45 e key
    46 f key
    47 g key
    48 h key
    49 i key
    4A j key
    4B k key
    4C l key
    4D m key
    4E n key
    4F o key
    50 p key
    51 q key
    52 r key
    53 s key
    54 t key
    55 u key
    56 v key
    57 w key
    58 x key
    59 y key
    5A z key
    5B Left Windows key (Microsoft Natural Keyboard)
    5C Right Windows key (Microsoft Natural Keyboard)
    5D Applications key (Microsoft Natural Keyboard)
    60 Numeric keypad 0 key
    61 Numeric keypad 1 key
    62 Numeric keypad 2 key
    63 Numeric keypad 3 key
    64 Numeric keypad 4 key
    65 Numeric keypad 5 key
    66 Numeric keypad 6 key
    67 Numeric keypad 7 key
    68 Numeric keypad 8 key
    69 Numeric keypad 9 key
    6A Multiply key
    6B Add key
    6C Separator key
    6D Subtract key
    6E Decimal key
    6F Divide key
    70 f1 key
    71 f2 key
    72 f3 key
    73 f4 key
    74 f5 key
    75 f6 key
    76 f7 key
    77 f8 key
    78 f9 key
    79 f10 key
    7A f11 key
    7B f12 key
    7C f13 key
    7D f14 key
    7E f15 key
    7F f16 key
    80H f17 key
    81H f18 key
    82H f19 key
    83H f20 key
    84H f21 key
    85H f22 key
    86H f23 key
    87H f24 key
    90 num lock key
    91 scroll lock key
    F6 Attn key
    F7 CrSel key
    F8 ExSel key
    F9 Erase EOF key
    FA Play key
    FB Zoom key
    FC Reserved for future use.
    FD PA1 key
    FE Clear key
    Smily Face un-Key

  12. #12

    Thread Starter
    Hyperactive Member Emo's Avatar
    Join Date
    Jul 2000
    Posts
    428

    Talking I got It

    I finally got it to work thanks to Matthew Gates' code!
    Thanks Matthew Gates
    And all the other guys who helped
    Thanks!
    -Emo
    -=VB6 Enterprise Edition=-
    -=VC++6Enterprise Edition=-
    «¤E³m°O²™¤»

  13. #13
    Guest
    Or use this:
    Code:
    Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
    Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
    Private Const WM_LBUTTONDOWN = &H201
    Private Const WM_LBUTTONUP = &H202
    Private Const MK_LBUTTON = &H1
    Private Type POINTAPI
        x As Long
        y As Long
    End Type
    
    Private Sub Command1_Click()
    
        Dim Wnd As Long
        Dim PT As POINTAPI
        
        SetCursorPos 100, 100
        Wnd = WindowFromPoint(100, 100)
        PostMessage Wnd, WM_LBUTTONDOWN, MK_LBUTTON, 0
        PostMessage Wnd, WM_LBUTTONUP, MK_LBUTTON, 0
        
    End Sub

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