Michri Posted December 3, 2007 Share Posted December 3, 2007 I'm attempting to make a basic script to send a keystroke to a background window. The problem I am having is, when I run two instances of the same program, it will only send it to the instance which was most recently focused on. I either want to send it to both, or a specific one of the multiple instances - but the only entry I get when using the window info tool is "Handle". Is there anywhere in the ControlSend command that will accept Handle, so I can specify which window? If not, is there another command I should look into using in my script? Link to comment Share on other sites More sharing options...
martin Posted December 3, 2007 Share Posted December 3, 2007 I'm attempting to make a basic script to send a keystroke to a background window. The problem I am having is, when I run two instances of the same program, it will only send it to the instance which was most recently focused on. I either want to send it to both, or a specific one of the multiple instances - but the only entry I get when using the window info tool is "Handle". Is there anywhere in the ControlSend command that will accept Handle, so I can specify which window? If not, is there another command I should look into using in my script? I would ensure that each instance has a different title. Here's one way to do it. $Title0 = "Title " $Inst = 0 Do $Inst += 1 $Title = $Title0 & $Inst Until not WinExists($Title) $MyGui = GUICreate($Title, .... Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Michri Posted December 3, 2007 Author Share Posted December 3, 2007 I would ensure that each instance has a different title. Here's one way to do it. $Title0 = "Title " $Inst = 0 Do $Inst += 1 $Title = $Title0 & $Inst Until not WinExists($Title) $MyGui = GUICreate($Title, .... I'm somewhat new at this. Could you possibly walk me through what that script will do? Essentially, my goal is to be able to send a keystroke to one instance of a game, to macro an ability on one character, while I play another character. The window title is the same in both instances of the game, and the only thing that shows up in the window info program is the handle, and window title (which are both the same, and dont seem to be of any use). Link to comment Share on other sites More sharing options...
jvanegmond Posted December 3, 2007 Share Posted December 3, 2007 The way I read it you are trying to use ControlSend with handles. All "title" parameters in AutoIt accept a few things. Handles are one of them.. So if you just: ControlSend($hWnd,....) you're done. github.com/jvanegmond Link to comment Share on other sites More sharing options...
Michri Posted December 3, 2007 Author Share Posted December 3, 2007 The way I read it you are trying to use ControlSend with handles.All "title" parameters in AutoIt accept a few things. Handles are one of them.. So if you just: ControlSend($hWnd,....) you're done. So, if for example, the window handle was 0x001B05DE (taken from my active firefox window atm), and I want to send the keystroke "0", where would I put it in the handle in the line, exactly? CODE ControlSend("", "", "", "0")Which of the 3 blank areas? Link to comment Share on other sites More sharing options...
jvanegmond Posted December 3, 2007 Share Posted December 3, 2007 So, if for example, the window handle was 0x001B05DE (taken from my active firefox window atm), and I want to send the keystroke "0", where would I put it in the handle in the line, exactly? CODE ControlSend("", "", "", "0")Which of the 3 blank areas?Title parameter, which is the first.ControlSend(0x001B05DE, "", "", "0") github.com/jvanegmond Link to comment Share on other sites More sharing options...
Michri Posted December 3, 2007 Author Share Posted December 3, 2007 Title parameter, which is the first.ControlSend(0x001B05DE, "", "", "0")No luck. There is no input when I use that method, but it works fine when I use the actual window title. Link to comment Share on other sites More sharing options...
jvanegmond Posted December 3, 2007 Share Posted December 3, 2007 No luck. There is no input when I use that method, but it works fine when I use the actual window title.Opt("WinTitleMatchMode",2) $hwnd = WinGetHandle("Mozilla Firefox") ControlSend($hwnd, "", "", "0") github.com/jvanegmond Link to comment Share on other sites More sharing options...
therks Posted December 3, 2007 Share Posted December 3, 2007 Just to explain: The handle of a window will be different everytime it is created, so you can't use a static value in your script. Using Manadar's code above will retrieve the handle to a window that exists and if you continue to use this handle (in the $hwnd variable) it will always refer to that specific window. My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now