PDA

View Full Version : Sending commands to multiple clients/windows



Username
05-20-2011, 12:34 AM
I was just thinking of slapping something together and wanted some people's opinions on this, I'm trying to find a way to send keyboard and mouse clicks to multiple windows/clients without having them in focus.

So just as an example lets say you have 2 games you alt-tab between regularly, I'm looking for a way to send clicks and keystrokes to both clients at once without having to alt+Tab between them.

I have a few theories on this but nothing concrete as of yet, of course the first things that come to mind are AHK and AutoIT, but I haven't used them in a long time and don't remember all the different commands for them...

I used to have a script in AHK that sent keyboard input to several clients at once, it was fairly simple as I recall but mouse clicks on the other hand... not so much. So I know it should be possible... Knowing that it's possible and actually making it happen are very different things though :(
Some of you might be more familiar with them than I am, how do you think you'd proceed with this?

ThatTallGuy
05-28-2011, 07:35 PM
If you're still looking for a way to do this, you can (at the beginning) store the coordinates of all the windows in which you're interested. Then when you capture a mouse click, you can calculate the offset from the current window and send mouse click messages to the other windows at their window coordinates + offset.

AHK Commands:
http://www.autohotkey.com/docs/commands/WinGetPos.htm
http://www.autohotkey.com/docs/commands/MouseGetPos.htm
http://www.autohotkey.com/docs/commands/Click.htm

Username
05-29-2011, 04:24 AM
If you're still looking for a way to do this, you can (at the beginning) store the coordinates of all the windows in which you're interested. Then when you capture a mouse click, you can calculate the offset from the current window and send mouse click messages to the other windows at their window coordinates + offset.

AHK Commands:
http://www.autohotkey.com/docs/commands/WinGetPos.htm
http://www.autohotkey.com/docs/commands/MouseGetPos.htm
http://www.autohotkey.com/docs/commands/Click.htm

ty for the info, any way to send a mouse click without it tieing up your cursor? For example sending a mouse click to a background or minimized application?

IceHound
05-29-2011, 06:02 AM
as far as i know, AHK is unable to do this. i could be wrong, but i was never able to find anything like this when i was working on my milticlient stuff.

ThatTallGuy
05-29-2011, 02:15 PM
ty for the info, any way to send a mouse click without it tieing up your cursor? For example sending a mouse click to a background or minimized application?

Minimized, no. Background, yes but it's a little trickier. A mouse click happens by sending the window in question a message that is added to the window's message queue. The Click functions provides a nice little interface for you, but you can manually send messages using the SendMessage/PostMessage (http://www.autohotkey.com/docs/commands/PostMessage.htm) functions (post is probably what you want) by figuring out the opcode for mouse click [see below] and sending the backgrounded window that message.

Here's a brief overview: SendMessage/PostMessage (http://www.autohotkey.com/docs/misc/SendMessage.htm)

And here's the tl;dr from this thread (http://www.autohotkey.com/forum/topic47496.html)


PostClick(x,y,win="A") { ; assumes 'win' is the active window if no window title is specified

lParam := x & 0xFFFF | (y & 0xFFFF) << 16
PostMessage, 0x201, , %lParam%, , %win% ;WM_LBUTTONDOWN
PostMessage, 0x202, , %lParam%, , %win% ;WM_LBUTTONUP
}

nogarD
05-29-2011, 03:54 PM
WinAPI SendMessage()?

Username
05-30-2011, 04:22 AM
http://www.autohotkey.com/docs/misc/SendMessage.htm

I'll look into that when I get the chance, not sure how well/if it'd work with eve, and then it might also be a little iffy on the detection side of things... Ty for the posts guys, some pretty interesting stuff.