forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Can the @lib function be used to send mouse clicks?

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
jrmarquart
Valued Newbie


Joined: 12 Jun 2004
Posts: 28
Location: Boise, ID

PostPosted: Sat Aug 28, 2004 3:00 am    Post subject: Can the @lib function be used to send mouse clicks? Reply with quote

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
View user's profile Send private message Visit poster's website
SnarlingSheep
Professional Member
Professional Member


Joined: 13 Mar 2001
Posts: 759
Location: Michigan

PostPosted: Sat Aug 28, 2004 3:39 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Sat Aug 28, 2004 10:56 am    Post subject: Reply with quote

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
View user's profile Send private message
SnarlingSheep
Professional Member
Professional Member


Joined: 13 Mar 2001
Posts: 759
Location: Michigan

PostPosted: Sat Aug 28, 2004 5:13 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Sat Aug 28, 2004 5:52 pm    Post subject: Reply with quote

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... Rolling Eyes Please correct me if I'm wrong... Embarassed
_________________
[ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial!
Back to top
View user's profile Send private message
jrmarquart
Valued Newbie


Joined: 12 Jun 2004
Posts: 28
Location: Boise, ID

PostPosted: Sat Aug 28, 2004 8:38 pm    Post subject: Can the @lib function be used to send mouse clicks? Reply with quote

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
View user's profile Send private message Visit poster's website
SnarlingSheep
Professional Member
Professional Member


Joined: 13 Mar 2001
Posts: 759
Location: Michigan

PostPosted: Sat Aug 28, 2004 8:45 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
jules
Professional Member
Professional Member


Joined: 14 Sep 2001
Posts: 1043
Location: Cumbria, UK

PostPosted: Sun Aug 29, 2004 10:38 am    Post subject: Reply with quote

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... Rolling Eyes Please correct me if I'm wrong... Embarassed


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
View user's profile Send private message Visit poster's website
jrmarquart
Valued Newbie


Joined: 12 Jun 2004
Posts: 28
Location: Boise, ID

PostPosted: Sun Aug 29, 2004 7:22 pm    Post subject: Reply with quote

Thanks SnarlingSheep! Mouse_event is exactly what I was looking for Cool . Along with Codescript's Constant API Reference I've got everything I need.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group