Hylia Posted February 16, 2013 Share Posted February 16, 2013 (edited) Firstly, I'm new to both AutoIT & programming in general so I don't really now what it's called what I'm trying to do, so please, bear with me. I'm trying to declare an automaticly created multiple variable, I think it'll be easier if I just show what I've had in my script so far: expandcollapse popup#include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #include <GuiStatusBar.au3> #Region ### START Koda GUI section ### $Form1_1 = GUICreate("Form1_1", 170, 135, 222, 464) $X = GUICtrlCreateInput("pos[0]", 16, 16, 49, 21) $Y = GUICtrlCreateInput("pos[1]", 104, 16, 49, 21) $MouseCoordX = GUICtrlCreateInput("-1", 16, 96, 49, 21) $MouseCoordY = GUICtrlCreateInput("-1", 104, 96, 49, 21) $N = GUICtrlCreateInput("1", 64, 56, 33, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER)) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ;pre-declare x & y For $i = 1 To 5 Assign('x' & $i, -1); Assign('y' & $i, -1); Next ;pre-declare end HotKeySet("{SPACE}", "Var") While 1 $nSet = GUICtrlRead($N) $pos = MouseGetPos() GUICtrlSetData($X, $pos[0]) GUICtrlSetData($Y, $pos[1]) If $nSet = 1 then GUICtrlSetData($MouseCoordX, $x1) GUICtrlSetData($MouseCoordY, $y1) ElseIf $nSet = 2 then GUICtrlSetData($MouseCoordX, $x2) GUICtrlSetData($MouseCoordY, $y2) ElseIf $nSet = 3 then GUICtrlSetData($MouseCoordX, $x3) GUICtrlSetData($MouseCoordY, $y3) ElseIf $nSet = 4 then GUICtrlSetData($MouseCoordX, $x4) GUICtrlSetData($MouseCoordY, $y4) ElseIf $nSet = 5 then GUICtrlSetData($MouseCoordX, $x5) GUICtrlSetData($MouseCoordY, $y5) EndIf $Msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE GUIDelete() fileDelete(@tempDir & "\image9.jpg") ExitLoop Exit EndSelect WEnd Func Var() If $nSet > 0 then $x & $nSet = $pos[0] $y & $nSet = $pos[1] GUICtrlSetData($N, $nSet + 1) EndIf EndFunc My problem is with the Func Var() I want it to automaticly create the numbers for $x1,$x2 etc. When I use my hotkey. How would I do this? Edited February 16, 2013 by Hylia Link to comment Share on other sites More sharing options...
JohnOne Posted February 16, 2013 Share Posted February 16, 2013 (edited) What you are doing seem to be going around the world to buy a lollipop from up the road. Of course I could be wrong because I never used Assign, never found the need for it. I think you should just create a 2D array $aXY[5][2] here you a 5 element array, each of which can store 2 values (x + y) perhaps To visualise, run this #include <Array.au3> local $aXY[5][2] = [[10,20]] _ArrayDisplay($aXY) Edited February 16, 2013 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
water Posted February 16, 2013 Share Posted February 16, 2013 I would suggest to use arrays. That's much easier. The wiki has a good tutorial regarding arrays. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Hylia Posted February 16, 2013 Author Share Posted February 16, 2013 (edited) Ok thanks, it seems to work, however now the "MouseGetPos()" doesn't seem to be updating anymore in the GUI.Update: I've found out what the problem was in the GUI I also have $X & $Y declared, ok, problem solved can someone lock this?Thanks again everyone for your help.expandcollapse popup#include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #Region ### START Koda GUI section ### $Form1_1 = GUICreate("Form1_1", 170, 135, 222, 464) $X = GUICtrlCreateInput("pos[0]", 16, 16, 49, 21) $Y = GUICtrlCreateInput("pos[1]", 104, 16, 49, 21) $MouseCoordX = GUICtrlCreateInput("-1", 16, 96, 49, 21) $MouseCoordY = GUICtrlCreateInput("-1", 104, 96, 49, 21) $N = GUICtrlCreateInput("1", 64, 56, 33, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER)) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ;pre-declare x & y local $X[5] local $Y[5] ;pre-declare end HotKeySet("{SPACE}", "Var") While 1 $nSet = GUICtrlRead($N) $pos = MouseGetPos() GUICtrlSetData($X, $pos[0]) GUICtrlSetData($Y, $pos[1]) If $nSet > 0 then GUICtrlSetData($MouseCoordX, $x[$nSet]) GUICtrlSetData($MouseCoordY, $y[$nSet]) EndIf $Msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE GUIDelete() fileDelete(@tempDir & "\image9.jpg") ExitLoop Exit EndSelect WEnd Func Var() If $nSet > 0 then $x[$nSet] = $pos[0] $y[$nSet] = $pos[1] GUICtrlSetData($N, $nSet + 1) EndIf EndFunc Edited February 16, 2013 by Hylia Link to comment Share on other sites More sharing options...
water Posted February 16, 2013 Share Posted February 16, 2013 This line is invalid:GUICtrlSetData($X, $pos[0])$x is an array so you have to pass the index too$x[$nSet] My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
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