Jump to content

==> Subscript used on non-accessible variable.:


jimg
 Share

Recommended Posts

I'm sure someone will point out the stupid problem with this code.  I'm a very occasional user.  I'm trying to define a bounding box for a later operation.

When I hit the "calibrate" button and then type "A", I get the  ==> Subscript used on non-accessible variable.:

A second question would be how to make F1 my hotkey.

cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.16.0
 Author:         myName

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here
#include <Math.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
global $xypos[2]
$xyvalid=0
$puller = GUICreate("Pull",110,100,-1,-1,-1,$WS_EX_TOPMOST)
guisetstate(@SW_SHOW,$puller)
$cal = GUICtrlCreateButton("Calibrate",5,5,50,15)
$new = GUICtrlCreateButton("New",5,25,100,30)
$next = GUICtrlCreateButton("Next",5,60,100,30)
$exit = GUICtrlCreateButton("Exit",60,5,45,15)
HotKeySet("A", "getmouse")

while 1
    Switch GUIGetMsg()
    Case    $exit
        ExitLoop
    Case $new
    Case $next
    Case $cal
        GUICtrlSetState($next,$GUI_HIDE)
        GUICtrlSetState($new,$GUI_HIDE)
        $xyvalid=0
        $msg=GUICtrlCreateLabel("Put mouse over first line, press F1",5,25,100,60)
        while $xyvalid=0
            sleep(100)
        WEnd
        $xtop=$xypos[0]
        $ytop=$xypos[1]
        $xyvalid=0
        guictrlsetdata($msg,"Put cursor over last line, press F1")
        while $xyvalid=0
            sleep(100)
        Wend
        $xbot=$xypos[0]
        $ybot=$xypos[1]        
        
    EndSwitch

WEnd

 

Func getmouse()
    $xypos = MouseGetCursor()
    $xyvalid=1
EndFunc

Link to comment
Share on other sites

I believe you are mixing MouseGetCursor with MouseGetPos...

Look at Send function (in help file) to learn how to use F1 key

Please use tags when you post code, Thanks in advance.

Edited by Nine
Link to comment
Share on other sites

@jimg

this should works for you ^_^:

#include <Math.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPISys.au3>


global $xypos ;, $Cur
$xyvalid = 0
$puller = GUICreate("Pull", 110, 100, -1, -1, -1, $WS_EX_TOPMOST)
guisetstate(@SW_SHOW, $puller)
$cal = GUICtrlCreateButton("Calibrate", 5, 5, 50, 15)
$new = GUICtrlCreateButton("New", 5, 25, 100, 30)
$next = GUICtrlCreateButton("Next", 5, 60, 100, 30)
$exit = GUICtrlCreateButton("Exit", 60, 5, 45, 15)
HotKeySet("A", "getmouse")
HotKeySet("{F1}", "getmouse")
while 1
    Switch GUIGetMsg()
        Case $exit
            ExitLoop
            ;Exit
        Case $new
        Case $next
        Case $cal
            GUICtrlSetState($next, $GUI_HIDE)
            GUICtrlSetState($new, $GUI_HIDE)
            $xyvalid = 0
            $msg = GUICtrlCreateLabel("Put mouse over first line, press F1", 5, 25, 100, 60)
            while $xyvalid = 0
                sleep(100)
            WEnd
            ;MsgBox(64, 'Cursor ID', $Cur)
            $xtop = $xypos[0]
            $ytop = $xypos[1]
            $xyvalid = 0
            guictrlsetdata($msg, "Put cursor over last line, press F1")
            while $xyvalid = 0
                sleep(100)
            ;   exitloop
            Wend
            $xbot = $xypos[0]
            $ybot = $xypos[1]

    EndSwitch
    Sleep(50)
WEnd

Func getmouse()
    $xypos = MouseGetPos()
    ;$Cur = MouseGetCursor()
    $xyvalid = 1
EndFunc   ;==>getmouse

 

Edited by ad777

iam ِAutoit programmer.

best thing in life is to use your Brain to

Achieve

everything you want.

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