Sign in to follow this  
Followers 0
Buckw1

Winhandles

10 posts in this topic

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?

Share this post


Link to post
Share on other sites



Failing that, you could always change their titles with WinSetTitle to be something different from each other.

Share this post


Link to post
Share on other sites

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?


[center]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.[/center]

Share this post


Link to post
Share on other sites

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..")

Share this post


Link to post
Share on other sites

Exactly what I had in mind Helge.


[center]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.[/center]

Share this post


Link to post
Share on other sites

Still the same requirement of starting up one instance at a time then grabbing the handle, correct?

Share this post


Link to post
Share on other sites

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.

[center]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.[/center]

Share this post


Link to post
Share on other sites

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.

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.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0