Sign in to follow this  
Followers 0
crzftx

HWND() x64 broken?

8 posts in this topic

After a bit of searching, it looks like maybe an error in the cast from pointer to integer, since I'm on 64-bit Windows. It is more likely my error than the developers, but I cannot figure out what I did wrong.

Run("notepad.exe")
WinWait("[CLASS:Notepad]")
ConsoleWrite(String(HWnd(WinGetHandle("[CLASS:Notepad]"))) & @CRLF)
ConsoleWrite(String(HWnd(String(HWnd(WinGetHandle("[CLASS:Notepad]"))))) & @CRLF)

0x00000000000A024C

0x0000000000000000

I have an HWND stored in a Windows form, so AutoIt reads it in as a string. If I want to do anything with that string, I convert it back to a handle. It seems to convert as all zeros. Any suggestions?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

How does the example from the helpfile go?

Run("notepad.exe")
WinWait("[CLASS:Notepad]")
Local $hWnd = WinGetHandle("[CLASS:Notepad]")
Local $sHWND = String($hWnd)  ; Convert to a string
WinSetState(HWnd($sHWND), "", @SW_MINIMIZE)
Sleep(5000); Notepad should be minimized
WinClose(HWnd($sHWND))

EDIT: Tested the above code on XP x64 and its working correctly.

Edited by BrettF

Share this post


Link to post
Share on other sites

Thanks for the response, but the example from the helpfile did not work. Notepad opened... nothing happened. Soon the AutoIt icon dissapeared

Maybe because I'm on win7 x64?

Share this post


Link to post
Share on other sites

BrettF was never heard from again.

There are rumors that he was consumed by unknown force when trying to experiment on Win7 64-bit version.

Apparently he was doing something with... with... omg!!! what's that??? it's, it's.... aaaaahhh!!!

beeeeeep........


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

I have an HWND stored in a Windows form, so AutoIt reads it in as a string. If I want to do anything with that string, I convert it back to a handle. It seems to convert as all zeros. Any suggestions?

What are you doing with the handle that it needs to be converted to a string?

Share this post


Link to post
Share on other sites

What are you doing with the handle that it needs to be converted to a string?

storing the handles. For example in a file or on a listview

Share this post


Link to post
Share on other sites

I am not sure why, but it's the second HWnd() that fails when running under x64.

Posted Image

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseX64=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
Run("notepad.exe")
WinWait("[CLASS:Notepad]")
$Hwnd = WinGetHandle("[CLASS:Notepad]")

$String = ""

$Temp = HWnd($Hwnd)
$String &= $Temp & @CRLF
$Temp = String($Temp)
$String &= $Temp & @CRLF
$Temp = HWnd($Temp)
$String &= $Temp & "/" & @error & "/" & @CRLF
$Temp = String($Temp)
$String &= $Temp & @CRLF
$String &= @TAB & @TAB & @TAB

ProcessClose("notepad.exe")
MsgBox(0, "Running under X64: " & (@AutoItX64 = True), $String)

But still, this is all really pointless, why are you not using the value directly?

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