ezzetabi Posted December 2, 2004 Posted December 2, 2004 Test this script. MsgBox(4096,'','Please opens two windows and give focus the first one.') Sleep(200);So the focus returns to the new window instead of the msgbox it self. $a = WinGetHandle('') MsgBox(4096,'','Please give focus to an other window') Sleep(200) $a = $a & @LF & WinGetHandle('') $a = StringSplit($a,@lf) MsgBox(4096,'',$a[1] & @lf & 'This should be the handle of the first window') WinActivate($a[1]);But it is not. MsgBox(4096,'No way','But the window did not actived... :( Why?') As you can see the script does not work. There is a way to convert a string to and handle?
scriptkitty Posted December 2, 2004 Posted December 2, 2004 Strange, a handle is not a string, a number, or anything inbetween. $b=WinGetHandle('') select case IsFloat($b) msgbox(1,"", "is float") case IsInt ($b) msgbox(1,"","is integer") case isnumber($b) msgbox(1,"","is number") case isstring($b) msgbox(1,"","is text") case else msgbox(1,"","is none of the above") endselect AutoIt3, the MACGYVER Pocket Knife for computers.
Somerset Posted December 2, 2004 Posted December 2, 2004 (edited) WinActivate works on title and text not handle... Edited December 2, 2004 by beerman
scriptkitty Posted December 2, 2004 Posted December 2, 2004 (edited) not the point, try this out: $b1=WinGetHandle('') clipput($b1) $b=clipget() $title=Wingettitle($b) $title2=wingettitle($b1) MsgBox(1,$b&"-"&$title,$b1&"-"&$title2) and it does work with handles msgbox is not the best to see it however: $b1=WinGetHandle('') WinSetState($b1,"",@SW_MINIMIZE) sleep(1000) WinActivate($b1) Edited December 2, 2004 by scriptkitty AutoIt3, the MACGYVER Pocket Knife for computers.
sugi Posted December 2, 2004 Posted December 2, 2004 (edited) Test this script.As you can see the script does not work. There is a way to convert a string to and handle?I don't know how to do this but I noticed that the content of $a differs when you add a simple Opt('WinTitleMatchMode', 4) on top.EDIT: and I just found a way to work around this:MsgBox(4096,'','Please opens two windows and give focus the first one.') Sleep(500);So the focus returns to the new window instead of the msgbox it self. $a = WinGetHandle('') MsgBox(4096,String($a),'Please give focus to an other window') Sleep(500) $a = $a & @LF & WinGetHandle('') $a = StringSplit($a,@lf) MsgBox(4096,'',$a[1] & @lf & 'This should be the handle of the first window') Opt('WinTitleMatchMode', 4) WinActivate("handle=" & $a[1]);But it is not. MsgBox(4096,'No way','But the window did not actived... :( Why?')Works for me (notice the change of WinTitleMatchMode) Edited December 2, 2004 by sugi
scriptkitty Posted December 2, 2004 Posted December 2, 2004 nice Sugi, I have been useing it without the "handle=" part, I forgot about that. $a = WinGetHandle('') WinSetState($a,"",@SW_MINIMIZE) $a = $a & @LF & WinGetHandle('') $a = StringSplit($a,@lf) tooltip("about to restore") sleep(1000) Opt('WinTitleMatchMode', 4) WinActivate("handle=" & $a[1]); need "handle=" if you change it I still am worndering why the handle acts like it does, it is not text, it is not a number of any type, and it doesn't seem to be binary. AutoIt3, the MACGYVER Pocket Knife for computers.
Valik Posted December 2, 2004 Posted December 2, 2004 The Variant class natively handles HWND's. Jon obviously didn't provide a cast to string/number for HWNDs, and in my opinion, rightly so, as HWNDs aren't meant for human use. Using WinTitleMatchMode-4 reverts back to the old string-based handling of HWNDs, not the new internal method Jon added. That is why you are able to print an HWND or whatever using that mode.
ezzetabi Posted December 2, 2004 Author Posted December 2, 2004 We may need a HWND() function to convert... I could add 1 to the AU3Xtra.dll, but how lame is that?<{POST_SNAPBACK}>Lame? Why? This is greatly needed.Now that Autoit can handle... handles without using Opt('WinTitleMatchMode',4) we need that command!
ezzetabi Posted December 2, 2004 Author Posted December 2, 2004 Oh, yes. I see. Well, lets ask Jon so.
jpm Posted December 2, 2004 Posted December 2, 2004 I think in Opt('WinTitleMatchMode',4) WinWait or WinWaitActive should return when successful the handle to avoid to add extra $handle=WinGetHandle("title", "text")WinWaitActive ( "Device Manager") $hWin=WinGetHandle("Device Manager") can be simplified to$hWin=WinWaitActive ( "Device Manager")
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