AutoIt3 WinActivate Not Working?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
Enternal
Posts: 1174
Joined: 10 Jan 2012 18:26

AutoIt3 WinActivate Not Working?

Post 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.

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Autoi3 WinActivate Not Working?

Post by highend »

Works fine for me.

What value does $hWnd have when you execute it and does it match the hwnd of XY?

Code: Select all

text <hwnd>;
One of my scripts helped you out? Please donate via Paypal

Enternal
Posts: 1174
Joined: 10 Jan 2012 18:26

Re: AutoIt3 WinActivate Not Working?

Post 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. :veryconfused:

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.

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: AutoIt3 WinActivate Not Working?

Post by bdeshi »

Did you check if another copy of XYplorer is running?
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

Enternal
Posts: 1174
Joined: 10 Jan 2012 18:26

Re: AutoIt3 WinActivate Not Working?

Post 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.

Enternal
Posts: 1174
Joined: 10 Jan 2012 18:26

Re: AutoIt3 WinActivate Not Working?

Post by Enternal »

Same script but in AutoHotkey works perfectly fine.

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: AutoIt3 WinActivate Not Working?

Post 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.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

Enternal
Posts: 1174
Joined: 10 Jan 2012 18:26

Re: AutoIt3 WinActivate Not Working?

Post 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
2016-05-28 07_42_29-Have 2 Windows That Exist.png (24.35 KiB) Viewed 4057 times

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: AutoIt3 WinActivate Not Working?

Post 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...
One of my scripts helped you out? Please donate via Paypal

Enternal
Posts: 1174
Joined: 10 Jan 2012 18:26

Re: AutoIt3 WinActivate Not Working?

Post 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.

Post Reply