Jump to content

Making this code work with Latest AutoIT Version


jbc1
 Share

Recommended Posts

Hi,

I have been working on/off on a project for a while now so I have not been keeping up to date with every new AutoIT version. The version of Autoit I used before was 3.2.4.9.

I have now updated to 3.3.0.0 and have gotten my scripts compling and mostly working. I am having a problem though with a function I got from the forum about two years ago, (see bottom of this post for the function).

I don't exactly remember where I got this or who wrote it, but since I updated to 3.3.0.0, this seems to fail.

The actual compilation doesn't fail, but when I call this function, for example like this (attempting to get the source of an Internet_Explorer Server Object:

$wa = WinActivate($Win_hWnd)
$cc = ControlClick ($Win_hWnd, "", "[Class:Internet Explorer_Server]")
$hWnd_IEServer = ControlGetHandle($Win_hWnd,"","[Class:Internet Explorer_Server]")
If $hWnd_IEServer = "" Then;  
  _FileWriteLog($logfile, "Error getting handle to the 'Internet Explorer_Server' control" & @CRLF)
Else
  $o_IE = _MISC_ObjGetFromHWND($hWnd_IEServer)
  If Not IsObj($o_IE) Then;; An error occurred getting the Object from the window handle
       _FileWriteLog($logfile, "Error getting the 'Internet Explorer_Server' object" & @CRLF)    ; This error message is always generated
  Else
    ;.....

then the error message "Error getting the 'Internet Explorer_Server' object" is always generated.

Does anybody know off hand why this doesn't work with the latest AutoIT version?

Func ObjGetFromHWND(ByRef $hWin)
    
    DLLCall("ole32.dll","int","CoInitialize","ptr",0)
    If @error Then Return SetError(@error,@extended,0)

    Local Const $WM_HTML_GETOBJECT = _MISC_RegisterWindowMessage("WM_HTML_GETOBJECT")
    If @error Then Return SetError(@error,@extended,0)
    
    Local Const $SMTO_ABORTIFHUNG = 0x0002
    Local $lResult, $typUUID, $aRet, $oIE

    _MISC_SendMessageTimeout($hWin, $WM_HTML_GETOBJECT, 0, 0, $SMTO_ABORTIFHUNG, 1000, $lResult)
    If @error Then Return SetError(@error,@extended,0)

    $typUUID = DLLStructCreate("int;short;short;byte[8]")
    DLLStructSetData($typUUID,1,0x626FC520)
    DLLStructSetData($typUUID,2,0xA41E)
    DLLStructSetData($typUUID,3,0x11CF)
    DLLStructSetData($typUUID,4,0xA7,1)
    DLLStructSetData($typUUID,4,0x31,2)
    DLLStructSetData($typUUID,4,0x0,3)
    DLLStructSetData($typUUID,4,0xA0,4)
    DLLStructSetData($typUUID,4,0xC9,5)
    DLLStructSetData($typUUID,4,0x8,6)
    DLLStructSetData($typUUID,4,0x26,7)
    DLLStructSetData($typUUID,4,0x37,8)

    $aRet = DllCall("oleacc.dll", "int", "ObjectFromLresult", "int", $lResult, _
            "ptr", DLLStructGetPtr($typUUID), "int", 0, "idispatch_ptr", "")
    If @error Then Return SetError(@error,@extended,0)

    If Not IsObj($aRet[4]) Then Return SetError(1,@extended,0)

    $oIE = $aRet[4].Script()
    Return $oIE
EndFunc
Link to comment
Share on other sites

What exactly does that do for you that _IEAttach() doesn't?

Aside from calling _MISC_ObjGetFromHWND(), but declaring _ObjGetFromHWND(), I don't see any obvious errors. But then, I have no idea what you want it to do.

:D

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...