wolfbartels Posted December 4, 2006 Posted December 4, 2006 (edited) Hi, there is a very strange behavior with 'WinGetPos'. The following script works fine during execution, but after Exit there shows up an error message saying 'Subscript used with non-Array variable' (same problem with compiled script). On top of a running application there is an additional menu done with AutoIt. The code makes the menu follow the application window when this is moved by the user.............................................While WinExists($AMWhdl) ;handle of appl. window $msg = GUIGetMsg() Select Case $msg = $LFN_Open ;one of the menu items DoFileOpen() ...... EndSelect $AMWposnew = WinGetPos($AMWhdl) ; Moved? If $AMWposnew<>$AMWpos Then $AMWpos=$AMWposnew WinMove($mnhdl, "", $AMWpos[0] + $mnleft, $AMWpos[1] + $mntop) ; added menu EndIfWEndExit........................................................$AMWpos seems to become a non_array variable at the moment the script finishes.What is going on and how can the Error message be avoided?Some idea? Thanks. Edited December 4, 2006 by wolfbartels
Danny35d Posted December 4, 2006 Posted December 4, 2006 May be this will help you. $AMWposnew = WinGetPos($AMWhdl) ; Moved? If IsArray($AMWposnew) Then If $AMWposnew<>$AMWpos Then $AMWpos=$AMWposnew WinMove($mnhdl, "", $AMWpos[0] + $mnleft, $AMWpos[1] + $mntop) ; added menu EndIf EndIF AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
wolfbartels Posted December 4, 2006 Author Posted December 4, 2006 May be this will help you. $AMWposnew = WinGetPos($AMWhdl) ; Moved? If IsArray($AMWposnew) Then If $AMWposnew<>$AMWpos Then $AMWpos=$AMWposnew WinMove($mnhdl, "", $AMWpos[0] + $mnleft, $AMWpos[1] + $mntop) ; added menu EndIf EndIF Thanks, it works! I think I have the explanation: The applications window is closed by the user and only later the script finishes itself and therefor the last WinGetPos does not return an array, because the window does not exist anymore.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now