Jump to content

Recommended Posts

Posted
Func workSpaceSetup ()
   ConsoleWrite ("workSpaceSetup" &@CRLF)
   $workSpace = WinGetHandle ("some site - Google Chrome")
   ConsoleWrite ($workSpace&@CRLF)
   $pos1 = WinGetPos ($workSpace)
   WinMove ($workSpace , "", $pos1[0] , $pos1[1] , 1366, 768, 0)
EndFunc
  Quote

(26) : ==> Subscript used on non-accessible variable.:
WinMove ($workSpace , "", $pos1[0] , $pos1[1] , 1366, 768, 0)
WinMove ($workSpace , "", $pos1^ ERROR
>Exit code: 1    Time: 0.1179

Expand  

So the script is first, the error I get is second in the quote.

This is one function of many for an app I am building but it is the first one that runs so I know there aren't other things at play here.

The idea is to keep the window in the same space it is when the script runs but just resize it as this app is used across multiple computers with different screen resolutions.

Could someone please elaborate upon what "Subscript used on non-accessible variable" means? 

Oh and the variable is declared as "Global $pos1 = 0" at the top outside of any functions with the other global variables.

Any advice would be greatly appreciated!

-Reiz

Posted (edited)

https://www.autoitscript.com/autoit3/docs/function_notes.htm

  Quote

If a function can set the @error flag, you should always check it before using a return value - if @error indicates an error then the function return value is generally undefined...

@error is always set to 0 when entering in a function.

Expand  

Example:

Func workSpaceSetup ()
   ConsoleWrite ("workSpaceSetup" &@CRLF)
   $workSpace = WinGetHandle ("some site - Google Chrome")
   If @error then Return SetError(1,0,0)
   
   ConsoleWrite ($workSpace&@CRLF)
   $pos1 = WinGetPos ($workSpace)
   If @error then Return SetError(2,0,0)
   
   WinMove ($workSpace , "", $pos1[0] , $pos1[1] , 1366, 768, 0)
EndFunc

 

EDIT: Your problem was that you not check if this window title exist, and in next step if WinGetPos returns array 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

  • 2 weeks later...
Posted (edited)

I also get this error regularly with the code (and I am checking for existence):

Func cancelGillickQuestionWindow()

;logMSG("cancelQuestionWindow")
    ; Close the do you want to switch to open (viewing documents) window
    $win1Title = "[TITLE:Question]"
    If  WinExists($win1Title) Then
        $winPos = WinGetPos($win1Title)
        If $winPos[0] = 106 And _
           $winPos[1] = 327 And _
           $winPos[2] = 737 And _
           $winPos[3] = 369 Then
            WinActivate($win1Title)
            Send ( "{ALTDOWN}d{ALTUP}")     ; Defer decision
        EndIf
    EndIf
EndFunc


 

Untitled.jpg.12ab2d1eb3e9913572acae30d03

Edited by dgm5555
deleted return (which wasn't in first code post)
Posted
  On 5/27/2016 at 12:58 PM, dgm5555 said:

and I am checking for existence

Expand  

:blink: Where ?
 

btw:
Please read this:  How to post code on the forum *

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted (edited)

Try this:

cancelGillickQuestionWindow()
If @error Or @extended Then MsgBox($MB_ICONERROR, 'TEST', '@error = ' & @error & @CRLF & '@extended = ' & @extended)


Func cancelGillickQuestionWindow()
    Return
    ;logMSG("cancelQuestionWindow")
    ; Close the do you want to switch to open (viewing documents) window
    $win1Title = "[TITLE:Question]"
    If Not WinExists($win1Title) Then Return SetError(1, 0, 0)

    $winPos = WinGetPos($win1Title)
    If @error Then Return SetError(2, @error, 0)

    If _
            $winPos[0] = 106 And _
            $winPos[1] = 327 And _
            $winPos[2] = 737 And _
            $winPos[3] = 369 _
             Then
        WinActivate($win1Title)

        Send("{ALTDOWN}d{ALTUP}") ; Defer decision
        Return SetError(0, 1, 1)
    EndIf

    Return SetError(0, 2, 1)
EndFunc   ;==>cancelGillickQuestionWindow

 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted (edited)

:oops:.... fixed. :D Thanks.

 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

I do apologise after "fixing" the code posting as per mLipok I pasted my current func which included a return which bypassed it completely (I've now removed the immediate return call)

I've added the edits and integrated your suggestion into my logging system (which will save it to text file), but if I don't get the error in the next hour before I leave work (it's caused by a particular automatic popup window which I can't manually trigger), so I'll post the results here next week.

Thanks for the super-prompt suggestions.

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
×
×
  • Create New...