
crazyjts
Active Members-
Posts
27 -
Joined
-
Last visited
crazyjts's Achievements

Seeker (1/7)
0
Reputation
-
Hi all, I have the following snippet of code that sort of works but isn’t doing exactly what I want. expand popup #include <GuiConstants.au3> Global $gGUIWidth = 250 Global $gGUIHeight = 150 Initial() Func Initial() ; Create the initial GUI $BaseGUI = GUICreate("", $gGUIWidth, $gGUIHeight, -1, -1, -1, $WS_EX_TOPMOST + $WS_EX_TOOLWINDOW) GUISetState(@SW_SHOW, $BaseGUI) ; Create a field for entering the current value GUICtrlCreateLabel("Current Value:", 10, 10) $CurrentValueFld = GUICtrlCreateInput("", 10, 40, 215, 20, $ES_NUMBER) GUICtrlSetState($CurrentValueFld, $GUI_FOCUS) ; Create Calculate button Local $CalculateButton = GUICtrlCreateButton("Calculate", 10, 70, 75, 25) GUICtrlSetState($CalculateButton, $GUI_DISABLE) ; Watch the value field and determine if the value is greater than 0 and if so, enable Calculate button $i = 0 Do $CurrentValue = GUICtrlRead($CurrentValueFld) If $CurrentValue > 0 Then GUICtrlSetState($CalculateButton, $GUI_ENABLE + $GUI_FOCUS) $i = 1 EndIf until $i = 1 ;Loop until the user exits and check for ESC, "X", or Begin button While 1 $InitialGUIMsg = GUIGetMsg() If $InitialGUIMsg = $GUI_EVENT_CLOSE Then Exit EndIf WEnd EndFunc I want to be able to: Start with focus in the value field (it is doing this now) Allow for more than one digit to be entered into the field (it is sort of doing this now but I have to bring focus back to the field) Enable the Calculate button and give focus to it once a value is entered into the value field (it is doing this now) but keep the cursor in the value field so the more digits can be entered (it is not doing this now) Be able to hit ESC or “X” to close the dialog at any time (this only works after I enter a digit in the value field Basically, I want to be able to allow the user to enter one or more digits and hit ENTER or SPACE (while the cursor is still in the value field) to push the Calculate button. I assume I need to bring focus to the button but maybe I don't and can get away with assigning hotkeys for ENTER and SPACE to push the Calculate button while keeping focus in the value field. If you could, please add comments in your code as to what the changes are doing if they aren't obvious to a noobish programmer. Thanks for any help you can offer on this.
-
A program will close when press "Esc" button.
crazyjts replied to KenzoIT's topic in AutoIt General Help and Support
If you have the original code, change the hotkey associated with the exit function to something else, I typically use "END" instead of "ESC". If you don't have the original code, don't hit "ESC" -
How do I increment a variable name
crazyjts replied to crazyjts's topic in AutoIt General Help and Support
I ended up getting the Execute function to do what I wanted. $CrntLocx = Execute("$Loc" & $k & "x") $CrntLocy = Execute("$Loc" & $k & "y") -
I'm trying to figure out how to increment a variable while working thru a do...until loop. Func Deploy () ;dbl-clicks the location $k = 1 Do $CrntLocx = $Loc & $k & x ;I'm trying to get this value to increment each time thru e.g Loc1x, Loc2x, Loc3x, etc. $CrntLocy = $Loc & $k & y ;I'm trying to get this value to increment each time thru e.g Loc1y, Loc2y, Loc3y, etc. MouseClick ("left",$CrntLocx,$CrntLocy,2) Sleep(1000) $k = $k + 1 Until $k = 10 EndFunc Thanks for any help
-
Ah....perfect. Thank you!
-
The following section of code is supposed to take a user entered value (e.g. 6) and then take that value to create a predefined constant (e.g. $CrntXPLvl = $CL6XP = 9000) and subtract that constant from another constant ($CL10XP in this example) to obtain the remaining XP the character needs. The result I get for TotalXP is the value of the constant $CL10XP (i.e. 32000) and not the difference between $CL10XP and $CrntXPLvl (CL6XP in this example) which should be 23000 (i.e. 32000 - 9000). I'm sure it's the way I'm trying to use the $CrntXPLvl variable but I cannot figure out the correct way to do what I want. Any help is appreciated. Dim $CL5XP = 1000, $CL6XP = 9000, $CL7XP = 12000, $CL8XP = 18000, $CL9XP = 24000, $CL10XP = 32000 #include <Misc.au3> $CrntLvl = String(InputBox( "Current Level", "Enter your current level and click the OK button" ));gets user input for their current level (6 in this example) $CrntXPLvl = "$CL" & $CrntLvl & "XP";sets $CrntXPLvl equal to $CL<user level>XP, e.g. $CL6XP MsgBox(0,"","$CrntXPLvl = " & $CrntXPLvl);message box displaying that value for $CrntXPLvl If $CrntLvl >= 5 And $CrntLvl < 10 Then;check to see if the user entered value falls within the desired range $TotalXP = $CL10XP - $CrntXPLvl;calculate the total XP remaining based on the user enter value and the high end level MsgBox(0,"Info","Total XP required to move to the next level = " & $TotalXP);message box to display the remaining XP EndIf
-
Need some help with reading from Input Boxes
crazyjts replied to crazyjts's topic in AutoIt General Help and Support
Perfect...I just couldn't figure that one out. Thank you -
I've made a simple GUI below and can read from info.txt and write the default values into the input boxes at GUI startup. What I can't get to happen is to have new values read from the input boxes and written to the info.txt file. For some reason, no matter what value I put into the 3 input boxes I get integer results in info.txt and the test msgbox. #Include <Misc.au3> #Include <File.au3> #Include <String.au3> #include <GuiConstantsEx.au3> ;Check to see if the Info.txt file exists. If not, ask to create it $InfoFile = FileExists("C:\Info.txt") If $InfoFile = 0 Then $FileCreate = MsgBox(1,"Error - Missing file","The file C:\Info.txt was not found." & @CRLF & "Click OK to create this file now and continue setup or Cancel to quit the program") If $FileCreate = 1 Then SplashTextOn("Create missing file","Creating C:\Info.txt",250,50) FileWriteLine("C:\Info.txt","Server not yet set" & @CRLF & "Login name not yet set" & @CRLF & "Password not yet set") Sleep(1000) SplashOff() Else Exit EndIf EndIf ; Set values for account info by reading from C:\Info.txt $Server = FileReadLine("C:\Info.txt",1) $LoginName = FileReadLine("C:\Info.txt",2) $LoginPswd = FileReadLine("C:\Info.txt",3) ; GUI form GuiCreate("Account Info", 400, 200) ; GUI Labels and Input boxes GuiCtrlCreateLabel("Enter the requested account information below", 25, 5, 400, 25) GuiCtrlCreateLabel("Server name:", 25, 25, 75, 25) $Input1 = GuiCtrlCreateInput($Server, 100, 23, 125, 25) GuiCtrlCreateLabel("Account login:", 25, 50, 75, 25) $Input2 = GuiCtrlCreateInput($LoginName, 100, 48, 126) GuiCtrlCreateLabel("Account pswd:", 25, 75, 75, 25) GuiCtrlCreateLabel("==>", 250, 75, 20, 25) $Input3 = GuiCtrlCreateInput($LoginPswd, 100, 73, 125, 25) ; Gui Buttons $BtnOK = GuiCtrlCreateButton("OK", 75, 150, 75, 25) $BtnExit = GuiCtrlCreateButton("Exit", 250, 150, 75, 25) $BtnReadMe = GuiCtrlCreateButton("ReadMe", 290, 70, 75, 25) ; GUI show GuiSetState(@SW_SHOW) ; GUI Message Loop While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop ElseIf $msg = $BtnOK Then GUICtrlRead($Input1) GUICtrlRead($Input2) GUICtrlRead($Input2) MsgBox(0,"",$Input1 & " " & $Input2 & " " & $Input3) $File = FileOpen("C:\Info.txt",2);Opens Info.txt and erases the existing content FileClose($File) FileWrite("C:\Info.txt",$Input1 & @CRLF & $Input2 & @CRLF & $Input3) ExitLoop ElseIf $msg = $BtnExit Then Exit ElseIf $msg = $BtnReadMe Then MsgBox(0,"","You need to enter the info asked for") EndIf WEnd
-
Possible to keep script running while logged off
crazyjts replied to crazyjts's topic in AutoIt General Help and Support
Will the mouse movements, clicks, and keystrokes still happen? They don't seem to be. -
Possible to keep script running while logged off
crazyjts replied to crazyjts's topic in AutoIt General Help and Support
Logged off was a poor choice of words. Switch User is what I was thinking of. -
I'd like to keep a script running that involves both Send and mouse movements & clicks after a user account has been logged off. I want to run the script on one user account then log off that account and then log in to another on the same PC. From what I could tell, the script either stops executing or possbily keeps running but will not Send nor move the mouse or click on the screen. As an alternative, is it possible to have a script confined to one window, send keystrokes, move the mouse around, and click but still have an operable mouse and keyboard to use in another window? Thanks for any insight and possibly some code on how to do this if it is indeed possible.
-
I'm having a problem figuring out how to end Func RqstChk () and return to a previous function (Func GetRqst) or move on to the next function (Func Action). What is happening is: 1) Func Initiate () is started which calls Func GetRqst () 2) Func GetRqst () is started & completed 3) Func Initiate () is continued which now calls Func RqstChk () 4) Fun RqstChk () is started 4a) C:\log.txt is read (it does not contain a string "You told...." for $4b below) 4b) A string between "You told " and ", 'What would you like?'" is not found (due to #4a above) 4c) The array returns an empty value for $Who 4d) If Not IsArray($Who) Then is satisfied 4e) Call ("GetRqst") is performed 5) Func GetRqst () is started & completed 6) The program now returns to where it left off in Func RqstChk () and finds the "Endif" for the "If Not IsArray($Who) Then" statement 7) $Rqst = _StringBetween($File, $Who[0] & " told you, '","'.") is now attempted 7a) Since $Who is an empty array (from #4c-#4d above) #7 can not be completed and an error ("Subscript used with non-Array variable") is returned. So it seems to me that I need to end/exit the Func RqstChk () from within the "If Not IsArray($Who) Then" statement. Func Initiate () <some code> Call ("GetRqst") Call ("RqstChk") EndFunc Func GetRqst () <Some code> EndFunc Func RqstChk () $File = FileRead("C:\log.txt") $Who = _StringBetween($File, "You told ",", 'What would you like?'") If Not IsArray($Who) Then;happens when log.txt does not contain a string value for $Who Call ("GetRqst");want to end func RqstChk here and go back to Func GetRqst EndIf $Rqst = _StringBetween($File, $Who[0] & " told you, '","'.") If Not IsArray($Rqst) Then;happens when log.txt does not contain a string value for $Rqst Call ("GetRqst");want to end func RqstChk here and go back to Func GetRqst EndIf Switch $Rqst[0] Case "Rqst1", "Rqst2", "Rqst3", "Rqst4", "Rqst5", "Rqst6", "Rqst7", "Rqst8", "Rqst9", "Rqst10", "Rqst11", "Rqst12", "Rqst13", "Rqst14", "Rqst15" Call ("Action",$Rqst[0]);want to end func RqstChk here and move on to Func Action passing it $Rqst[0] Case Else Call ("GetRqst");want to end func RqstChk here and go back to Func GetRqst EndSwitch EndFunc Func Action ($Rqst) <Some code> EndFunc absolution (Tault)
-
Ugh...one more problem I didn't foresee. I have an instance where the string "You ask Elvis 'What would you like?'" does not exist in the file. I believe the _StringBetween array for $Who is coming back empty and causing an error. How do I check if the line exists or not prior to using the $Who = _StringBetween($File, "You ask ",", 'What would you like?'") function?