Windows handles are not strings,

Recommended Posts

ezzetabi 1

ezzetabi 1

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?

Share this post

Link to post

Share on other sites

sugi 0

sugi 0

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?')