jimg Posted March 30, 2022 Posted March 30, 2022 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
Nine Posted March 30, 2022 Posted March 30, 2022 (edited) 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 March 30, 2022 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
jimg Posted March 30, 2022 Author Posted March 30, 2022 Thanks. I'll do better next time if I can figure out how to use tags.
ad777 Posted March 30, 2022 Posted March 30, 2022 (edited) @jimg this should works for you : expandcollapse popup#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 March 30, 2022 by ad777 none
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