Jump to content

Any idea why this won't compile?

Recommended Posts

To make a long story short I had started a thread before related to trying to call the GetGUIThreadInfo function in user32.dll. Thereafter I updated my AutoIt to realise how stupid I had been because it had already been coded in WinAPIsys.au3. This leads me to my next query, I am trying to compile this code in AutoIT version 3.3.6 but for one reason or another the DLL call seems to fail.

Following is the error information.

Z:\Window Moved.au3 (15) : ==> Subscript used with non-Array variable.:
$display = WingetTitle($windowInformation[5])
$display = WingetTitle($windowInformation^ ERROR

The GetGUIThreadInfo function is simply copied from the WinAPIsys.au3 I just changed the name is all. The reason I can't just compile this on  a modern version of AutoIT is that I work in a secure environment where I cant get anything digital in or out without an extreme amount of effort so I am stuck in the dark ages. I have  virtual machine set up with the AutoIT 3.3.6 so I can test if any suggested solutions work :).

Here is the code, any help is greatly appreciated.

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <SendMessage.au3>
#include <WinAPI.au3>


Dim $hCurrentWindow, $threadProcessID, $pID, $windowInformation, $display

While 1
    $hCurrentWindow = WinGetHandle("[Active]")
    $pID = _WinAPI_GetCurrentProcessID()
    $threadProcessID = _WinApi_GetWindowThreadProcessId($hCurrentWindow, $pID)
    $windowInformation = GetGUIThreadInfo($threadProcessID)
    $display = WingetTitle($windowInformation[5])
    If $display = "" Then $display = "No Active Move/Size Loop"
    ToolTip($display, 0, 0)

Func GetGUIThreadInfo($iThreadID)
    Local Const $tagGUITHREADINFO = 'dword Size;dword Flags;hwnd hWndActive;hwnd hWndFocus;hwnd hWndCapture;hwnd hWndMenuOwner;hwnd hWndMoveSize;hwnd hWndCaret;long rcCaret[4]'
    Local $tGTI = DllStructCreate($tagGUITHREADINFO)
    DllStructSetData($tGTI, 1, DllStructGetSize($tGTI))

    Local $aRet = DllCall('user32.dll', 'bool', 'GetGUIThreadInfo', 'dword', $iThreadID, 'struct*', $tGTI)
    If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, 0)

    Local $aResult[11]
    For $i = 0 To 6
        $aResult[$i] = DllStructGetData($tGTI, $i + 2)
    For $i = 1 To 4
        $aResult[6 + $i] = DllStructGetData($tGTI, 6 + 2, $i)
    For $i = 9 To 10
        $aResult[$i] -= $aResult[$i - 2]
    Return $aResult
EndFunc   ;==>_WinAPI_GetGUIThreadInfo


Edited by Venix

Share this post

Link to post
Share on other sites

Not sure why you ask about Compilation, but you are not testing for success of GetGUIThreadInfo().

When you look inside that Func you see there is an option it could return nothing and setting an error.


Share this post

Link to post
Share on other sites

Your code is working fine on my machine.....

​I can get it to work on an up to date version of AutoIT but not the outdated version I will need to try and compile it on which is version 3.3.6 I can post screenshots if that is of help to anyone?

Share this post

Link to post
Share on other sites

@Venix Why wont it compile :huh:? What error do you get in the complication process?

Edited by TheDcoder

My contributions to the AutoIt Community - ##AutoIt at freenode, real-time chat



If I have hurt or offended you in anyway, Please accept my apologies, I never (regardless of the situation) intend to do that to anybody.

Share this post

Link to post
Share on other sites

To reiterate what I had stated earlier. This will compile perfectly fine on a modern version of AutoIT. But given the circumstances of where I am going to be developing this program it will have to compile on version 3.3.6.


Sorry for any trouble I realise this is a strange request.


Edited by Venix

Share this post

Link to post
Share on other sites

Older version of the language doesn't know about "struct*".
If you want it to work there replace:

...'struct*', $tGTI


...'ptr', DllStructGetPtr($tGTI)


​Thank you so much, It worked! :)

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

  • Create New...