Buckw1 Posted September 7, 2006 Posted September 7, 2006 How do you get the handles of 2 game screens? Case in point being 2 instances of Eve Online running on same PC (dual screens). Both windows have same title,"EVE". A quick test of the wingethandle function returns the numeric number for 1 client only. My objective is to control both clients with a AutoIt script. Ideas?
Valuater Posted September 7, 2006 Posted September 7, 2006 maybe... Run("Notepad.exe") WinWaitActive("") $win1 = WinGetHandle("") Run("Notepad.exe") WinWaitActive("") $win2 = WinGetHandle("") MsgBox(0, "Notepad handle test", $win1 & @CRLF & $win2, 5) WinClose($win1) sleep(2000) WinClose($win2) 8)
Buckw1 Posted September 7, 2006 Author Posted September 7, 2006 maybe... Run("Notepad.exe") WinWaitActive("") $win1 = WinGetHandle("") Run("Notepad.exe") WinWaitActive("") $win2 = WinGetHandle("") MsgBox(0, "Notepad handle test", $win1 & @CRLF & $win2, 5) WinClose($win1) sleep(2000) WinClose($win2) 8) Nice idea, get the handles at startup rather than after....will try it when I get home. Thanks!
exodius Posted September 7, 2006 Posted September 7, 2006 Failing that, you could always change their titles with WinSetTitle to be something different from each other.
Moderators SmOke_N Posted September 7, 2006 Moderators Posted September 7, 2006 maybe... Run("Notepad.exe") WinWaitActive("") $win1 = WinGetHandle("") Run("Notepad.exe") WinWaitActive("") $win2 = WinGetHandle("") MsgBox(0, "Notepad handle test", $win1 & @CRLF & $win2, 5) WinClose($win1) sleep(2000) WinClose($win2) 8)Providing the speed of the PC, couldn't you very well get an active window that isn't from the process you just ran from the above code? Val... didn't I/you/we/someone make a udf that's in your wrappers to get the exe's windows or handles specifically? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Helge Posted September 7, 2006 Posted September 7, 2006 Failing that, you could always change their titles with WinSetTitle to be something different from each other.How would that have worked ? If you can't get the handle of the wanted window like Valuater suggested then WinSetTitle wouldn't be able to magically figure out what window to change the title of either. Anyway..You could try to download http://www.autoitscript.com/fileman/users/Helge/udfs/_ProcessGetHWnd.au3, and do something like this :$pid1 = Run($gamefile) Sleep(3000) ; wait for window to exist $hwnd1 = _ProcessGetHWnd($pid, 1, $gametitle)oÝ÷ ÚØb²0z÷«É®r޶׫jëh×6$pid1 = Run($gamefile) $hwnd1 = 0 For $i = 1 To 10 ; times out after 10 * 500 = 5sec $hwnd1 = _ProcessGetHWnd($pid, 1, $gametitle) If @error Then ExitLoop Sleep(500) Next If $hwnd1 = 0 Then MsgBox(16, "Error", "Failed to get HWND..")
Moderators SmOke_N Posted September 7, 2006 Moderators Posted September 7, 2006 Exactly what I had in mind Helge. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Buckw1 Posted September 8, 2006 Author Posted September 8, 2006 Still the same requirement of starting up one instance at a time then grabbing the handle, correct?
Moderators SmOke_N Posted September 8, 2006 Moderators Posted September 8, 2006 Still the same requirement of starting up one instance at a time then grabbing the handle, correct?If you want to be specific, that's how I'd do it, otherwise you would just get every window for every instance of the .exe. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
exodius Posted September 8, 2006 Posted September 8, 2006 How would that have worked ? If you can't get the handle of the wanted windowlike Valuater suggested then WinSetTitle wouldn't be able to magically figure outwhat window to change the title of either.Start up the first instance window, whose name you already know, and change it to something. Now start up the second window and do the same.
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