|
-
Oct 8th, 2000, 03:02 AM
#1
Thread Starter
Hyperactive Member
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²™¤»
-
Oct 8th, 2000, 03:06 AM
#2
Fanatic Member
-
Oct 8th, 2000, 03:46 AM
#3
Thread Starter
Hyperactive Member
-=VB6 Enterprise Edition=-
-=VC++6Enterprise Edition=-
«¤E³m°O²™¤»
-
Oct 8th, 2000, 12:36 PM
#4
Thread Starter
Hyperactive Member
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²™¤»
-
Oct 8th, 2000, 12:56 PM
#5
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
-
Oct 8th, 2000, 12:58 PM
#6
Fanatic Member
To make the mouse click:
Code:
mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0,
-
Oct 8th, 2000, 12:59 PM
#7
Fanatic Member
Escaflowne, I didn't see your post.
-
Oct 8th, 2000, 01:11 PM
#8
Thread Starter
Hyperactive Member
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²™¤»
-
Oct 8th, 2000, 01:14 PM
#9
-
Oct 8th, 2000, 01:20 PM
#10
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
-
Oct 8th, 2000, 01:23 PM
#11
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
-
Oct 8th, 2000, 04:36 PM
#12
Thread Starter
Hyperactive Member
-
Oct 8th, 2000, 05:55 PM
#13
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|