English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I need to write a program that clicks the mouse in a certain area continuously.
What i need it to do is put the mouse in a certain place, click 3 times, move to a different area then click once...Wait 15 seconds and do it again.
all until i tell it to stop.
Can anyone help me write this? any sudjestions?

2006-10-26 12:25:04 · 3 answers · asked by Raylon 2 in Computers & Internet Programming & Design

3 answers

1)Visual basic has a timer object built in, the time is mesaured in microseconds.
2)Your mouse is based on an X,Y axis define the X,Y points where you want to click.

Thats more than half your algorthim that I just came up with in 2 minutes.

2006-10-26 12:34:41 · answer #1 · answered by D 4 · 0 0

It all depends on what version of VB you are running. I suppose its either vb6 or vb.net.

If you are using vb6 (most probable), you'll need to recurr to the API. Here's some code:

Public Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" ( ByVal hwnd As Long , _
ByVal wMsg As Long , ByVal wParam As Long , lParam As Any) As Long

Public Sub SendClick(lnghWND As Long , x As Long , y As
Long )
Private Const WM_LBUTTONDOWN = &H201
Private Const WM_LBUTTONUP = &H202

Dim iResult As Long
Dim lParam As Long
lParam = (y * &H10000) + x
iResult = SendMessage(lnghWND, WM_LBUTTONDOWN, 0&, ByVal lnglParam)
iResult = SendMessage(lnghWND, WM_LBUTTONUP, 0&, ByVal lnglParam)
End Sub

Now make a timer. Put the interval to (for example) 1000ms (1 sec). Add the following code to the _Timer event:

static i as integer
Dim hw as long

i = i +1
hw = hwnd '//Substitute this line with a function that returns the hwnd of the window you want to send the message to (you can use the API GetWindowFromPoint)//
if i <= 2 then
call SendClick(hw, clickposX_1, clickposY_1)
else
i = 0
call SendClick(hw, clickposX_2, clickposY_2)
end if

That's all. Needless to say that clickposX and co. are the positions where you want to click. You can declare some form-level variables to store the values (which you can easily retrieve using the API function GetCursorPos), or just put them manually (although I recommend the former).

2006-10-26 23:15:09 · answer #2 · answered by OverClocked 2 · 0 0

Try Macro Scheduler. You can find it at http://www.mjtnet.com/macro_scheduler.htm. I hav eused it for many years and can only recommend it.

2006-10-26 20:03:13 · answer #3 · answered by Joey Madison 2 · 0 0

fedest.com, questions and answers