Jump to content
Venix

Any idea why this won't compile?

Recommended Posts

Venix

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

Share this post


Link to post
Share on other sites
Starstar

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."

Share this post


Link to post
Share on other sites
Jos

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


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Venix

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
Starstar

Try latest version AutoIt v3.3.12.0


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

Share this post


Link to post
Share on other sites
TheDcoder

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

Edited by TheDcoder
grammer

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites
Venix

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

Share this post


Link to post
Share on other sites
Starstar

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."

Share this post


Link to post
Share on other sites
trancexx

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

...'struct*', $tGTI

...with:

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

 

  • Like 1

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
Venix

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

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

×