Jump to content

Recommended Posts

Posted (edited)

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
Posted

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

Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once."

  • Developers
Posted

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.
  :)

Posted

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?

Posted (edited)

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
Posted

Here is a screenshot that shows  script compiled successfully.

Untitled.thumb.jpg.76c3d0799bc337d38476a 

Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once."

Posted

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

...'struct*', $tGTI

...with:

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

 

​Thank you so much, It worked! :)

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
  • Recently Browsing   0 members

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