Jump to content

Not an Array Problem


wolfbartels
 Share

Recommended Posts

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

EndIf

WEnd

Exit

........................................................

$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 by wolfbartels
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

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