AutoHotkey Community

It is currently May 27th, 2012, 3:22 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: September 16th, 2008, 8:28 pm 
Offline

Joined: September 16th, 2008, 12:21 am
Posts: 11
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!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 16th, 2008, 8:31 pm 
Offline

Joined: September 6th, 2008, 3:11 pm
Posts: 84
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 16th, 2008, 8:33 pm 
Offline

Joined: September 16th, 2008, 12:21 am
Posts: 11
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 16th, 2008, 8:38 pm 
Offline

Joined: September 6th, 2008, 3:11 pm
Posts: 84
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 ?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 16th, 2008, 8:43 pm 
Offline

Joined: September 16th, 2008, 12:21 am
Posts: 11
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 16th, 2008, 9:17 pm 
Offline

Joined: July 21st, 2008, 4:16 pm
Posts: 726
Location: Calgary, AB, Canada
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 25th, 2010, 3:39 am 
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 :)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 18th, 2012, 9:20 pm 
For ControlSend
WinTitle can be specifed be process ID. If you can get the PID's from both SWG's it be as:

SetTitleMatchMode, 2
~7::
KeyWait 7
IfWinActive, Notepad
{
ControlSend,, 7, ahk_pid [%Var% or manual input] ;SWG window1
ControlSend,, 7, ahk_pid [%Var% or manual input] ;SWG window2
}
Return


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: rbrtryn and 19 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group