| View previous topic :: View next topic |
| Author |
Message |
jrmarquart Valued Newbie
Joined: 12 Jun 2004 Posts: 28 Location: Boise, ID
|
Posted: Sat Aug 28, 2004 3:00 am Post subject: Can the @lib function be used to send mouse clicks? |
|
|
I am familiar with the GetAsyncKeyState to detect if a mouse button is being held down and using keybd_event to change the state of a key.
Is there an equivalent to this for sending mouse clicks to the active window and even simulating a mouse button being held down using the @lib function? I'm not interested in clicking on certain coordinates of the screen - I'm only interested in simulating a mouse button being pressed down.
Thanks for any help you can provide. |
|
| Back to top |
|
 |
SnarlingSheep Professional Member


Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Sat Aug 28, 2004 3:39 am Post subject: |
|
|
depending on the program you are sending to, you might be able to use SendMessage to send WM_LBUTTONDOWN(WM_LBUTTONUP to release) to it.
Something like:
| Code: |
LOADLIB user32.dll
%%WM_LBUTTONDOWN = $0201
%%WM_LBUTTONUP = $0202
%%Window = <Window ID here>
%%Return = @LIB(user32,SendMessageA,INT:,INT:%%Window,INT:%%WM_LBUTTONDOWN,INT:0,INT:0)
FREELIB user32.dll
|
_________________ -Sheep
My pockets hurt... |
|
| Back to top |
|
 |
Skit3000 Admin Team

Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
Posted: Sat Aug 28, 2004 10:56 am Post subject: |
|
|
In addition to SnarlingSheep's code, there also is a built-in sendmessage function in VDS called @sendmsg(). It accepts the same parameters as the "real" SendMessageA function:
| Visual Dialogscript Helpfile wrote: | | @SENDMSG(<window>, <message number>, <wparam>, <lparam>) |
_________________ [ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial! |
|
| Back to top |
|
 |
SnarlingSheep Professional Member


Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Sat Aug 28, 2004 5:13 pm Post subject: |
|
|
| Skit3000 wrote: | | It accepts the same parameters as the "real" SendMessageA function |
Are you sure of that? It didn't before, which is why other people built SendMessage VDS DLL's. _________________ -Sheep
My pockets hurt... |
|
| Back to top |
|
 |
Skit3000 Admin Team

Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
|
| Back to top |
|
 |
jrmarquart Valued Newbie
Joined: 12 Jun 2004 Posts: 28 Location: Boise, ID
|
Posted: Sat Aug 28, 2004 8:38 pm Post subject: Can the @lib function be used to send mouse clicks? |
|
|
SnarlingSheep your code works great for windows type applications, but I'm trying to get this mouse functionality to work inside a computer game.
Ideally I'd like to avoid having to use window identifiers for this reason.
I've been using keybd_event with great success for keys. For instance the following will hold down the Ctrl key:
| Code: | | %%Ctrl = @lib(user32,keybd_event,nil:,int:$11,0,0,0) |
I've tried putting in the virual keycodes for the mouse as follows:
| Code: | | %%LeftMouseDown = @lib(user32,keybd_event,nil:,int:$01,0,0,0) |
or
| Code: | | %%LeftMouseDown = @lib(user32,keybd_event,nil:,int:$05,0,0,0) |
but this does not work....
The virtual keycodes I am using can be found at: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/VirtualKeyCodes.asp |
|
| Back to top |
|
 |
SnarlingSheep Professional Member


Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Sat Aug 28, 2004 8:45 pm Post subject: |
|
|
You'll want mouse_event then:
| Code: |
LOADLIB user32.dll
%%MOUSEEVENTF_LEFTDOWN = $02
%%PosX = 100
%%PosY = 100
%%Return = @LIB(user32,mouse_event,NIL:,INT:%%MOUSEEVENTF_LEFTDOWN,INT:%%PosX,INT:%%PosY,INT:0,INT:0)
FREELIB user32.dll
|
_________________ -Sheep
My pockets hurt... |
|
| Back to top |
|
 |
jules Professional Member


Joined: 14 Sep 2001 Posts: 1043 Location: Cumbria, UK
|
Posted: Sun Aug 29, 2004 10:38 am Post subject: |
|
|
| Skit3000 wrote: | I believe @sendmsg() is just a wrapper around the SendMessageA function, since all parameters which are required by SendMessageA are also required by the @sendmsg() function... Please correct me if I'm wrong...  |
You're not wrong. But you don't get as much control over the format of the arguments as @lib() gives you, which might be necessary for certain message types. _________________ The Tech Pro
www.tech-pro.net |
|
| Back to top |
|
 |
jrmarquart Valued Newbie
Joined: 12 Jun 2004 Posts: 28 Location: Boise, ID
|
Posted: Sun Aug 29, 2004 7:22 pm Post subject: |
|
|
Thanks SnarlingSheep! Mouse_event is exactly what I was looking for . Along with Codescript's Constant API Reference I've got everything I need. |
|
| Back to top |
|
 |
|