 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
muffen
Joined: 15 Sep 2008 Posts: 11
|
Posted: Tue Sep 16, 2008 7:28 pm Post subject: Sending keystrokes to multiple windows without ControlSend |
|
|
Thought I'd make a new thread as I have narrowed down the problem a bit more. It is a bit long but I would really appreciate some assistance!
I am trying to send keystrokes to two SWG (Star Wars Galaxies) windows at the same time, but it seems like ControlSend isn't working.
Here is the first version of the script.
| Code: |
WinGet, swgid, List, Star Wars Galaxies
~7::
KeyWait 7
IfWinActive, Star Wars Galaxies
{
ControlSend,, 7, ahk_id %swgid1%
ControlSend,, 7, ahk_id %swgid2%
Return
}
|
This didn't work, so I tried the following.
| Code: |
WinGet, swgid, List, Star Wars Galaxies
~7::
KeyWait 7
IfWinActive, Star Wars Galaxies
{
ControlSend,, 7, ahk_id %swgid1%
Sleep, 1000
ControlSend,, 7, ahk_id %swgid1%
Return
}
|
This should simply have sent the same key to the window twice, but still no luck.
So, I tried the Send command and created the following script.
| Code: |
WinGet, swgid, List, Star Wars Galaxies
~7::
KeyWait 7
IfWinActive, Star Wars Galaxies
{
Send, 7
Sleep, 1000
Send, 7
Return
}
|
This does in fact send the keystroke to the active window twice, so this works (but problem is obviously that I want to send keystrokes to two windows).
So, next step was to see if the windows were being handled correctly, so made this script.
| Code: |
~7::
KeyWait 7
IfWinActive, Star Wars Galaxies
{
IfWinActive, ahk_id %swgid1%
{
WinActivate, ahk_id %swgid2%
Sleep, 500
Send, 7
Sleep, 100
WinActivate, ahk_id %swgid1%
Sleep, 2000
Return
}
IfWinActive, ahk_id %swgid2%
{
WinActivate, ahk_id %swgid1%
Sleep, 500
Send, 7
Sleep, 100
WinActivate, ahk_id %swgid2%
Sleep, 2000
Return
}
Return
}
|
This works, but the swapping of windows is extremely annoying and obviously removes half the point of doing this.
So, my question, how can I send the keystroke to two windows, when ControlSend isn't working?
Thanks! |
|
| Back to top |
|
 |
Bytales
Joined: 06 Sep 2008 Posts: 84
|
Posted: Tue Sep 16, 2008 7:31 pm Post subject: |
|
|
Perhaps, if win active (window 1 - specifi ahk-class), make it active, send the click
then if win active 2, make it active, send the click |
|
| Back to top |
|
 |
muffen
Joined: 15 Sep 2008 Posts: 11
|
Posted: Tue Sep 16, 2008 7:33 pm Post subject: |
|
|
| Bytales wrote: | Perhaps, if win active (window 1 - specifi ahk-class), make it active, send the click
then if win active 2, make it active, send the click |
Thats exactly what the last script in my original post is doing, and that works, but swapping windows is a bit annoying and since the fights can be quite hard sometimes, the swapping of windows sort of destroys the whole point.
Works fine with two chars but I want to run at least three if I get this to work, there simply has to be a way of doing this. |
|
| Back to top |
|
 |
Bytales
Joined: 06 Sep 2008 Posts: 84
|
Posted: Tue Sep 16, 2008 7:38 pm Post subject: |
|
|
| muffen wrote: | | Bytales wrote: | Perhaps, if win active (window 1 - specifi ahk-class), make it active, send the click
then if win active 2, make it active, send the click |
Thats exactly what the last script in my original post is doing, and that works, but swapping windows is a bit annoying and since the fights can be quite hard sometimes, the swapping of windows sort of destroys the whole point.
Works fine with two chars but I want to run at least three if I get this to work, there simply has to be a way of doing this. |
Then i have another solution for you, which you may not like, but will definetly work !
Use a 22" monitor, with 1680x1050 resolution. Use it in portrait mode, so the screen resolution is 1050x1680. This will fit 2 star wars galaxies in windowed mode, each in 1024x768, one in the upper part, the other one in the lower part.
You first move them to designated pixel coordonates. And then you click what what coordonates you want, if the coordonate is in the upper part of the screen, it will click the 1st window, if it is in the lower part of the screen it will click the second window !
You need a 20/22 incher with tilting capability, so when you turn the screen from the drivers, you tilt the monitor as well.
Is this a MMO game ? |
|
| Back to top |
|
 |
muffen
Joined: 15 Sep 2008 Posts: 11
|
Posted: Tue Sep 16, 2008 7:43 pm Post subject: |
|
|
| Bytales wrote: | | muffen wrote: | | Bytales wrote: | Perhaps, if win active (window 1 - specifi ahk-class), make it active, send the click
then if win active 2, make it active, send the click |
Thats exactly what the last script in my original post is doing, and that works, but swapping windows is a bit annoying and since the fights can be quite hard sometimes, the swapping of windows sort of destroys the whole point.
Works fine with two chars but I want to run at least three if I get this to work, there simply has to be a way of doing this. |
Then i have another solution for you, which you may not like, but will definetly work !
Use a 22" monitor, with 1680x1050 resolution. Use it in portrait mode, so the screen resolution is 1050x1680. This will fit 2 star wars galaxies in windowed mode, each in 1024x768, one in the upper part, the other one in the lower part.
You first move them to designated pixel coordonates. And then you click what what coordonates you want, if the coordonate is in the upper part of the screen, it will click the 1st window, if it is in the lower part of the screen it will click the second window !
You need a 20/22 incher with tilting capability, so when you turn the screen from the drivers, you tilt the monitor as well.
Is this a MMO game ? |
Yes, it is an MMO, and I actually already have 2x19" screens so can run one SWG on each monitor.
Thing is though that I'd like to run more than two, I'm using two right now just to get it working, which is why the screenflipping isn't an option.
I appreciate the input though, I'll see if there is a solution using AHK, if not I'll have to look into other options. |
|
| Back to top |
|
 |
Sivvy
Joined: 21 Jul 2008 Posts: 726 Location: Calgary, AB, Canada
|
Posted: Tue Sep 16, 2008 8:17 pm Post subject: |
|
|
| Code: | SetTitleMatchMode, 2
~7::
KeyWait 7
IfWinActive, Notepad
{
ControlSend,, 7, Notepad
ControlSend,, 7, Notepad
}
Return |
Try that code. If it works in Notepad, then save and open 2 Notepad documents, naming 1 and 2, then try the code underneath...
| Code: | SetTitleMatchMode, 2
~7::
KeyWait 7
IfWinActive, Notepad
{
ControlSend,, 7, 1 - Notepad
ControlSend,, 7, 2 - Notepad
}
Return |
|
|
| Back to top |
|
 |
a7xsoldier Guest
|
Posted: Tue May 25, 2010 2:39 am Post subject: |
|
|
I took your original code and used it on four separate World of Warcraft windows.
This is the code i used:
| Code: |
WinGet, swgid, List, World of Warcraft
~1::
KeyWait 1
IfWinActive, World of Warcraft
{
loop
{
ControlSend,, 1, ahk_id %swgid1%
sleep 10
ControlSend,, 1, ahk_id %swgid2%
sleep 10
ControlSend,, 1, ahk_id %swgid3%
sleep 10
ControlSend,, 1, ahk_id %swgid4%
sleep 5000
}
Return
}
|
This code sends a loop after I hit the "1" key that will send the 1 key to four of my WoW's simultaneously every 5 seconds without having to change windows. This worked for me 100% so I'm not sure why its not working for you. This code also allows me to do other things while my code is running without interrupting it which I find very useful. I hope this helped  |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|