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>

Opt("MustDeclareVars")

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)
    Sleep(100)
WEnd

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)
    Next
    For $i = 1 To 4
        $aResult[6 + $i] = DllStructGetData($tGTI, 6 + 2, $i)
    Next
    For $i = 9 To 10
        $aResult[$i] -= $aResult[$i - 2]
    Next
    Return $aResult
EndFunc   ;==>_WinAPI_GetGUIThreadInfo

 

Edited by Venix
Link to comment
Share on other sites

  • Developers

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.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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

Link to comment
Share on other sites

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

Edited by TheDcoder
grammer

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

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

Edit::

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

screenshot.jpg

Edited by Venix
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...