Page 1 of 1
AutoIt3 WinActivate Not Working?
Posted: 28 May 2016 09:14
by Enternal
Guys can you test this simple code in Autoit3?
Code: Select all
Local $hWnd = WinActivate("[CLASS:ThunderRT6FormDC]", "")
WinSetState($hWnd, "", @SW_RESTORE)
I tested it with class Notepad and some others and they work. Yet for XYplorer, it does not seem to work at all. Just me?
[edit] Odd thing is I do see XYplorer being activated and focused on IF XYplorer is restored. If it's minimized, then it does nothing.
Re: Autoi3 WinActivate Not Working?
Posted: 28 May 2016 09:38
by highend
Works fine for me.
What value does $hWnd have when you execute it and does it match the hwnd of XY?
Re: AutoIt3 WinActivate Not Working?
Posted: 28 May 2016 13:17
by Enternal
Hmm... Very odd. It was working before in the past.
It returned 0x0001038A for the $hWnd. It returned 0x00561620 if I run the script directly from XYplorer.
EDIT: Interestingly, after just sitting there repeatedly running the script out of boredom and tiredness, there was one moment where it actually worked and it actually gave a different $hWnd. Amazing. This seems to be related to a complaint I saw about this function on the Autoit forums about how it's finick at times for no reason.
On a different computer, it works perfectly with $hWnd 0x00040902.
Even now I'm confused since it worked repeatedly for me before and suddenly stopped working only recently.
Re: AutoIt3 WinActivate Not Working?
Posted: 28 May 2016 13:36
by bdeshi
Did you check if another copy of XYplorer is running?
Re: AutoIt3 WinActivate Not Working?
Posted: 28 May 2016 13:39
by Enternal
Yeah already checked that. Don't notice any other programs with the same Class. Odd thing is I do see XYplorer being activated and focused on IF XYplorer is restored. If it's minimized, then it does nothing.
Re: AutoIt3 WinActivate Not Working?
Posted: 28 May 2016 13:46
by Enternal
Same script but in AutoHotkey works perfectly fine.
Re: AutoIt3 WinActivate Not Working?
Posted: 28 May 2016 13:53
by bdeshi
Confusing.
Enternal wrote:It returned <a handle> for the $hWnd. It returned <another handle> if I run the script directly from XYplorer.
How are you running it outside of XYplorer?
ed: added a bit of possibly important info to 1st post.
Re: AutoIt3 WinActivate Not Working?
Posted: 28 May 2016 16:44
by Enternal
SammaySarkar wrote:Confusing.
Enternal wrote:It returned <a handle> for the $hWnd. It returned <another handle> if I run the script directly from XYplorer.
How are you running it outside of XYplorer?
ed: added a bit of possibly important info to 1st post.
I simply run it directly from the Desktop through Explorer. Not only that, just a moment ago while writing this post, it worked once again and then stopped working afterwards. Very very weird.
... and I found the issue. So... in the past AutoIt would never tried to activate a program that had no visible window. Why now? The problem was it's trying to activate Dexpot (oh, this is also written in VB6?!). I mean, AutoHotKey properly ignores it and picked XYplorer instead unlike AutoIt. Well, now I need to find easy ways to ignore it (or have a double check that it uses ThunderRT6FormDC AND it has XYplorer in its title). *sigh*
I found out through:
Code: Select all
If WinExists("[CLASS:ThunderRT6FormDC]") Then
MsgBox(0, "Found You", "Yet, Can I Eat The Pizza?", 1)
Local $hWnd = WinActivate("[CLASS:ThunderRT6FormDC]", "")
WinSetState($hWnd, "", @SW_RESTORE)
;MsgBox($MB_OK, "Test", $hWnd)
$var = WinList("[CLASS:ThunderRT6FormDC]", "")
_ArrayDisplay($var, "Have " & $var[0][0] & " Windows That Exist")
Else
MsgBox(0, '', 'Could Not Find Pizza. How VILE!')
Exit
EndIf
- 2016-05-28 07_42_29-Have 2 Windows That Exist.png (24.35 KiB) Viewed 4092 times
Re: AutoIt3 WinActivate Not Working?
Posted: 28 May 2016 17:07
by highend
Code: Select all
$var = WinList("[CLASS:ThunderRT6FormDC]")
For $i = 1 To $var[0][0]
If StringInStr($var[$i][0], "xyplorer") = 0 Then ContinueLoop
; Do whatever needs to be done
Next
Would be one way...
Re: AutoIt3 WinActivate Not Working?
Posted: 29 May 2016 23:09
by Enternal
highend wrote:Code: Select all
$var = WinList("[CLASS:ThunderRT6FormDC]")
For $i = 1 To $var[0][0]
If StringInStr($var[$i][0], "xyplorer") = 0 Then ContinueLoop
; Do whatever needs to be done
Next
Would be one way...
Thanks! DId not mean it was hard or anything, just tired after all that troubleshooting haha.