Jump to content

HWND() x64 broken?


Recommended Posts

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?
Link to comment
Share on other sites

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
Link to comment
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?

Link to comment
Share on other sites

  • 3 weeks later...

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?

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...