Jump to content

mistersquirrle

Active Members
  • Posts

    406
  • Joined

  • Last visited

  • Days Won

    7

mistersquirrle last won the day on April 5 2023

mistersquirrle had the most liked content!

1 Follower

About mistersquirrle

  • Birthday 04/30/1991

Profile Information

  • Location
    Seattle, WA
  • WWW
    http://mistersquirrle.deviantart.com

Recent Profile Visitors

794 profile views

mistersquirrle's Achievements

  1. I feel like that we're missing something more that you're using, since I have no issues with running it and capturing many times. Also I would make some changes to your While loop for the main: #include "SimpleCaptureTool.au3" Global $capture = 0 ; We only need to set the hotkey once, unless it's unset somewhere If HotKeySet("{HOME}", "Example") = 0 Then MsgBox($MB_SYSTEMMODAL, "", "Could not set the hotkey !") Exit 1 EndIf While $capture = 0 ; You may want to change this to just While True, if you want an infinite loop Sleep(10) ; Small sleep to avoid 100% cpu core usage If $capture = 1 Then ConsoleWrite("Global Var coordinates: " & $iX1 & ", " & $iY1 & ", " & $iX2 & ", " & $iY2 & @CRLF) ;verify I got the coordinates $capture = 0 EndIf WEnd
  2. If it only worked when you put the scripts in the AutoIt install/include folder, it's likely because of your #include <> instead of #include "". Take a look at the help file notes for #include https://www.autoitscript.com/autoit3/docs/keywords/include.htm I know you mentioned that you did try putting them in quotes already, but keep in mind that you either need to provide the relative path or the absolute path in quotes. So if the include file is in the same folder then #include "file.au3" works, but if it's in a different folder then you need to do something like #include "C:/AutoIt_Includes/file.au3" or #include "Includes/file.au3" (assuming the Includes folder is in the same folder as the script). Also if you provide relative paths and then move the file and not the includes you'll get errors. Maybe you know all of that, just mentioning it as it's the issue that comes to mind from what you've said. However if it's working now and you're okay with that, then do whatever works. As mentioned though it's not recommended. If you move the include files back somewhere and still have a problem, try using the full path to the file (hold shift and right click on a file to get a "copy as path" option in the menu) in quotes on the #include line. If you still have errors, provide the exact script text that you're using (at least the include part) and something like a screenshot of an explorer window where the include files are, with the address bar visible if you want more help.
  3. Here's something to consider, all of your includes should be at the top of your script, before you call any functions. Also, the order of your includes could matter. I don't think that the example you gave is something that you've tested, because that does work no problem for everyone here (myself included). How sure are you that the "missing" function is in fact included in your file? As long as it's there, there shouldn't be a reason why it would fail and not be able to find the file. Here's another topic on include file organization: Keep in mind also that even if you include everything into a script, that only means everything will (or should) work from that main script. You still need to make sure that none of your includes have references to things that exist outside of their own files. Otherwise when you include just a single file or two instead of the whole set of them, you can get undefined functions. I would recommend running the "SyntaxCheck Prod" tool in SciTE (Ctrl + F5) on each of your include files to make sure there's nothing missing in the includes itself.
  4. You may want to check out @Melba23's ArrayMultiColSort UDF, it gives a bit more control over sorting, and you can sort by different columns, so you could separate the suffixes (M, T, US) and sort by that column, then the numbers. There's also the ability to set the sort order with strings, though I haven't used this functionality so I can't really guide on it. From the documentation: "Sort order can be either numeric (0/1 = ascending/descending) or a ordered string of items" Besides that, I think maybe an example script/data that we could see would be helpful.
  5. If you're on a roll then you're on a roll. Sometimes just completing the task is better than finding the most optimal way. However that being said, you are definitely doing more typing/work than needed for your X1-Y4 pairs. You're providing each corner of a rectangle, even though you only need opposing corners (like top left and bottom right). For example: ; https://www.autoitscript.com/forum/topic/210615-converting-string-into-a-variable-name/?do=findComment&comment=1521771 #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include <array.au3> Global $id = 0 ; active selection Global $aQuad[][] = [ _ ; Provide coordinates in groups, [Top Left] and [Bottom Right] ["X1", "Y1", "X2", "Y2"], _ [223, 223, 325, 325], _ ;1 [750, 425, 850, 525] _ ;26 ] While 1 Global $sInputBoxAnswer = InputBox("Which quadrant to show?", @CRLF & "Number only, 0 - " & UBound($aQuad) - 1, $id + 1) If @error Then Exit $id = Int($sInputBoxAnswer) If $id < 0 Or $id >= UBound($aQuad) Then ConsoleWrite('Invalid number' & @CRLF) ContinueLoop EndIf For $iY = 1 To 3 Step 2 For $iX = 0 To 2 Step 2 MouseMove($aQuad[$id][$iX], $aQuad[$id][$iY], 1) ToolTip($aQuad[$id][$iX] & ", " & $aQuad[$id][$iY], _ $aQuad[$id][$iX] + 20, _ ; offset so we can see the whole tooltip without the mouse in the way $aQuad[$id][$iY], _ 'X' & ($iX + 2) / 2 & ', Y' & ($iY + 1) / 2) Sleep(250) Next Next ;Sleep(350) ToolTip("") WEnd Here, we're only using X1,Y1 and X2,Y2. These points are the Top Left and Bottom Right coordinates, that's all we need to make a rectangle. That'll save you half the typing for coordinates. I also simplified the main loop, and swapped having 4 mouse moves to a couple of loops. If you wanted to keep that part expanded though, here's what that would look like: MouseMove($aQuad[$id][0], $aQuad[$id][1], 1) ToolTip($aQuad[$id][0] & ", " & $aQuad[$id][1], $aQuad[$id][0], $aQuad[$id][1], "Top left") Sleep(250) MouseMove($aQuad[$id][2], $aQuad[$id][1], 1) ToolTip($aQuad[$id][2] & ", " & $aQuad[$id][1], $aQuad[$id][2], $aQuad[$id][1], "Top right") Sleep(250) MouseMove($aQuad[$id][0], $aQuad[$id][3], 1) ToolTip($aQuad[$id][0] & ", " & $aQuad[$id][3], $aQuad[$id][0], $aQuad[$id][3], "Bottom left") Sleep(250) MouseMove($aQuad[$id][2], $aQuad[$id][3], 1) ToolTip($aQuad[$id][2] & ", " & $aQuad[$id][3], $aQuad[$id][2], $aQuad[$id][3], "Bottom right") Sleep(250) The nice part with not having each one as its own thing is that if you want to change a part of it, instead of changing it 4 places it's only 1. Also I noticed that your coordinates are almost a pattern, at least besides the first 1 or 2 points of the pattern. But, would something like this work? ; https://www.autoitscript.com/forum/topic/210615-converting-string-into-a-variable-name/?do=findComment&comment=1521771 #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include <array.au3> Global $id = 0 ; active selection Global $sInputBoxAnswer Global $aiCoords[2] While 1 $sInputBoxAnswer = InputBox("Which quadrant to show?", @CRLF & "Number only", $id + 1) If @error Then Exit $id = Int($sInputBoxAnswer) If $id <= 0 Then ConsoleWrite('Invalid number' & @CRLF) ContinueLoop EndIf For $iY = 0 To 1 $aiCoords[1] = 225 + (100 * (Floor($id / 10) + $iY)) For $iX = 0 To 1 $aiCoords[0] = 250 + (100 * Mod(($id - 1) + $iX, 10)) MouseMove($aiCoords[0], $aiCoords[1], 1) ToolTip(String($aiCoords[0]) & ", " & String($aiCoords[1]), _ $aiCoords[0] + 20, _ ; offset so we can see the whole tooltip without the mouse in the way $aiCoords[1], _ 'X' & ($iX + 1) & ', Y' & ($iY + 1)) Sleep(250) If $iX = $iY Then ConsoleWrite('id: ' & $id & ' X' & $iX & ',Y' & $iY & ': ' & _ String($aiCoords[0]) & ", " & String($aiCoords[1]) & @CRLF) Next Next ;Sleep(350) ToolTip("") WEnd This assumes that you start at 250 instead of 223, and also hit 350 instead of 335. Everything else just seems to be multiples of 100, with 10 points in X before moving to a new Y and repeating. I think I had some other stuff to say, but then took a work meeting and forgot. Let me know if you have questions.
  6. I like this @TalesFromTheScript and was testing it out when I noticed some issues, which got me into editing it a bit. Now a couple hours later I've changed quite a bit, but kept your main idea there I believe. Check it out: #include <Constants.au3> #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <File.au3> #include <Array.au3> Global $hEdit, $hAverageLabel, $hTypingLabel, $hFile Main() Func Main() $hFile = FileOpen("WordsPerMinute.txt", BitOR($FO_APPEND, $FO_CREATEPATH)) If @error Or $hFile = -1 Then MsgBox($MB_ICONERROR, 'Unable to open stats file', 'Unable to open/create "WordsPerMinute.txt" file. Please check that the file exists, or that there are permissions to create/open files in this directory') Exit EndIf CreateGUI() UpdateAverage() Local $hTimer = False, $hStartTime = False Local $bIsFinished = True Local $iWordCount = 0, $iRemainingSeconds = 0, $iTimeoutSeconds = 4, $iCharacterCount = 0 Local $nAverage = 0, $nMsg = 0, $nActiveTime = 0 Local $sCurrentEdit = '', $sPreviousEdit = '' While 1 Do ; This is just to process any/all messages from the GUI first, to make sure it's responsive to closing $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_NONE ExitLoop Case $GUI_EVENT_CLOSE FileClose($hFile) Exit EndSwitch Until $nMsg <= 0 $sCurrentEdit = GUICtrlRead($hEdit) If $sCurrentEdit <> $sPreviousEdit Then If $bIsFinished Then $hStartTime = TimerInit() GUICtrlSetData($hTypingLabel, "Timer running...") EndIf $hTimer = TimerInit() $bIsFinished = False $sPreviousEdit = $sCurrentEdit EndIf If Not $bIsFinished And TimerDiff($hTimer) > ($iTimeoutSeconds * 1000) Then $bIsFinished = True $nActiveTime = TimerDiff($hStartTime) - TimerDiff($hTimer) ; Subtract inactivity since the last input $iWordCount = _CountWords($sCurrentEdit) $iCharacterCount = StringLen($sCurrentEdit) $nAverage = Round($iWordCount / ($nActiveTime / 60000), 1) ; Calculate WPM with one decimal place GUICtrlSetData($hTypingLabel, "You have just typed " & $nAverage & " WPM") GUICtrlSetData($hEdit, "") ; Previous and Current need to be set to the same value so we can track a new 'session' $sPreviousEdit = '' $sCurrentEdit = '' GUICtrlSetState($hEdit, $GUI_FOCUS) If $iWordCount > 0 Then ; Write a CSV of: ; ComputedAverage,WordCount,ActiveTypingTime,CharacterCount FileWriteLine($hFile, $nAverage & ',' & $iWordCount & ',' & $nActiveTime & ',' & $iCharacterCount) UpdateAverage() EndIf EndIf If Not $bIsFinished And TimerDiff($hTimer) < ($iTimeoutSeconds * 1000) And TimerDiff($hTimer) >= 1000 Then $iRemainingSeconds = $iTimeoutSeconds - Floor(TimerDiff($hTimer) / 1000) If GUICtrlRead($hTypingLabel) <> 'Ending in ' & $iRemainingSeconds & '...' Then GUICtrlSetData($hTypingLabel, 'Ending in ' & $iRemainingSeconds & '...') EndIf EndIf WEnd Return True EndFunc ;==>Main Func UpdateAverage() Local Enum $e_WPM_CSV_AVERAGE, $e_WPM_CSV_WORDCOUNT, $e_WPM_CSV_TIME, $e_WPM_CSV_CHARACTERCOUNT, $e_WPM_CSV_MAX Local $aWordsPerMinute ; Set cursor position to the beginning of the file to read it FileSetPos($hFile, 0, $FILE_BEGIN) _FileReadToArray($hFile, $aWordsPerMinute, $FRTA_NOCOUNT, ',') ; And then set the cursor back to the end of the file so we can write to it FileSetPos($hFile, 0, $FILE_END) ;~ _ArrayDisplay($aWordsPerMinute) If UBound($aWordsPerMinute) <= 0 Then Return SetError(1, 0, False) EndIf Local $nOverallSum = 0, $nAverage = 0 Local $iRecords = 0 For $iLine = 0 To UBound($aWordsPerMinute) - 1 ;~ ConsoleWrite('$aWordsPerMinute[' & $iLine & '][' & $e_WPM_CSV_AVERAGE & ']: ' & $aWordsPerMinute[$iLine][$e_WPM_CSV_AVERAGE] & @CRLF) If Number($aWordsPerMinute[$iLine][$e_WPM_CSV_AVERAGE]) <= 0 Then ContinueLoop $nOverallSum += $aWordsPerMinute[$iLine][$e_WPM_CSV_AVERAGE] $iRecords += 1 Next If $iRecords > 0 Then $nAverage = Round($nOverallSum / $iRecords, 1) GUICtrlSetData($hAverageLabel, "All-time average = " & $nAverage & " WPM") Return SetExtended($iRecords, $nAverage) EndIf Return SetError(2, 0, False) EndFunc ;==>UpdateAverage Func _CountWords($sText) Local $aWords = StringRegExp(StringStripWS($sText, BitOR($STR_STRIPLEADING, $STR_STRIPTRAILING, $STR_STRIPSPACES)), "[^\s]+", 3) Local $iWordCount = UBound($aWords) If $iWordCount = 1 And StringLen($sText) = 1 Then Return 0 EndIf Return $iWordCount EndFunc ;==>_CountWords Func CreateGUI() Local $hGUI = GUICreate("Typing Speed Calculator", 600, 485, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPCHILDREN), $WS_EX_CLIENTEDGE) If @error Then Return False $hEdit = GUICtrlCreateEdit("", 10, 10, 580, 350, BitOR($ES_AUTOVSCROLL, $ES_WANTRETURN, $WS_VSCROLL)) GUICtrlSetState($hEdit, $GUI_FOCUS) GUICtrlSetFont($hEdit, 16, 400, "Segoe UI") $hAverageLabel = GUICtrlCreateLabel("All-time average: 0 WPM", 10, 428, 580, 40, BitOR($SS_CENTER, $WS_BORDER, $SS_CENTERIMAGE, $SS_NOTIFY)) ; Add $SS_NOTIFY style GUICtrlSetFont($hAverageLabel, 16, 700, "Segoe UI") $hTypingLabel = GUICtrlCreateLabel("Start typing anything to begin", 10, 374, 580, 40, BitOR($SS_CENTER, $WS_BORDER, $SS_CENTERIMAGE)) GUICtrlSetFont($hTypingLabel, 16, 700, "Segoe UI") GUICtrlSetColor($hTypingLabel, 0x00008B) ; Set the color of the typing label to dark blue GUICtrlSetColor($hAverageLabel, 0x006400) ; Set the color of the average label to dark green GUISetFont(9, 400, "Segoe UI") GUISetState(@SW_SHOW, $hGUI) Return True EndFunc ;==>CreateGUI I originally started editing it because I noticed you had a Sleep(100), which is much longer than is needed (Sleep(10) which is the minimum is still WAY more than enough to keep it at/near 0% CPU). Additionally since you're using GUIGetMsg(), a Sleep isn't needed at all. From the helpfile: Also, because of this: While 1 If Not WinActive($hGUI) Then $hTimer = 0 ContinueLoop EndIf You were creating two issues. First, since this was at the top of the loop with no Sleep or GUIGetMsg, when the window wasn't active you were using 100% of the CPU core that the AutoIt process was on. I assume you did this to try and prevent unnecessary processing, but created a loop that ended up eating resources doing nothing. This also let GUI msgs stack up since they weren't being processed by GUIGetMsg, so closing the window could take several seconds if you just moved your mouse over it a bit before closing it, since it has to go through your whole loop several times to finally get to and process the close message. It started with that, and then I decided to just start changing things to be more inline with how I would write things. I may not be your style or what you wanted, but feel free to use my script or anything in it for yourself. I also noticed that you had: If $hTimer And TimerDiff($hTimer) > 4000 Then $endTime = TimerDiff($startTime) - 4000 ; Subtract 4 seconds of inactivity Which seemed a bit incorrect to me, since you're assuming a set timer value, but which could be off by up to at least 350ms (100 from Sleep, up to 250 from GUIGetMsg). So I changed it to the time from the last action. I do also like the WM_COMMAND function and what it can do, however I have experienced input delay/lag when using it with other projects, and I figured there was an easier way. I switched it to just a GUICtrlRead comparing a previous value to the current. I added some additional logging to the file besides just the average WPM. I included the word count, time spent typing, and character count. This way the data is there if you wanted to add some more features/stats into it later. I definitely changed a lot, and it's just more to what my preferences are. If you have any questions about some of the changes, let me know. Edit: Also since I changed the .txt format from a single value to a CSV, you will need to create a new file since _FileReadToArray will error if there's a line that has a different size unless you use $FRTA_INTARRAYS
  7. Maybe you should start a thread asking about arrays to get someone to explain what it is that you don't understand about them. I usually find arrays easier to understand when you think about them just as a list, like $aArray[3] would just be: [0] - first item [1] - second item [2] - third item Or a 2d array would just be a list... of lists. So $aArray[3][3] would be: [0][#] [0][0] - first item, first sub [0][1] - first item, second sub [0][2] - first item, third sub [1][#] [1][0] - second item, first sub etc.... [2][#] [2][0] - third item, first sub etc... This type of layout basically it just repeated as you add more dimensions, so quickly $aArray[3][3][3] would look like: [0][#][#] [0][0][#] [0][0][0] - first item, first sub, first tertiary(?) Obviously arrays can start to get out of hand when you start adding a lot of dimensions, which is why a good way to keep track of things is to use variables with names that hold the indexes. For example using @ioa747s example: ; https://www.autoitscript.com/forum/topic/210615-converting-string-into-a-variable-name/?do=findComment&comment=1521771 #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include <array.au3> Global $id = 0 ; active selection Global Enum $E_QUAD_X, $E_QUAD_Y, $E_QUAD_WIDTH, $E_QUAD_HEIGHT, $E_QUAD_MAX ; $E_QUAD_X = 0, $E_QUAD_Y = 1, etc. Global $aQuad[][$E_QUAD_MAX] = [ _ ["X", "Y", "W", "H"], _ [100, 100, 200, 200], _ [200, 100, 300, 300], _ [500, 200, 800, 600], _ [300, 300, 1000, 700]] ;~ _ArrayDisplay($aQuad) While 1 Global $sInputBoxAnswer = InputBox("Which quadrant to show?", @CRLF & "Number only", $id + 1) Select Case @error = 0 ;OK - The string returned is valid ConsoleWrite("$sInputBoxAnswer=" & $sInputBoxAnswer & @CRLF) $id = Int($sInputBoxAnswer) If $id > 0 And $id <= UBound($aQuad) - 1 Then ConsoleWrite("X=" & $aQuad[$id][$E_QUAD_X] & ", ") ConsoleWrite("Y=" & $aQuad[$id][$E_QUAD_Y] & ", ") ConsoleWrite("W=" & $aQuad[$id][$E_QUAD_WIDTH] & ", ") ConsoleWrite("H=" & $aQuad[$id][$E_QUAD_HEIGHT] & @CRLF) MouseMove($aQuad[$id][$E_QUAD_X], $aQuad[$id][$E_QUAD_Y]) ToolTip($aQuad[$id][$E_QUAD_X] & ", " & $aQuad[$id][$E_QUAD_Y], $aQuad[$id][$E_QUAD_X], $aQuad[$id][$E_QUAD_Y], "MouseMove XY") Sleep(500) MouseMove($aQuad[$id][$E_QUAD_WIDTH], $aQuad[$id][$E_QUAD_HEIGHT]) ToolTip($aQuad[$id][$E_QUAD_WIDTH] & ", " & $aQuad[$id][$E_QUAD_HEIGHT], $aQuad[$id][$E_QUAD_WIDTH], $aQuad[$id][$E_QUAD_HEIGHT], "MouseMoveWH") EndIf Case @error = 1 ;The Cancel button was pushed Exit EndSelect Sleep(3000) ConsoleWrite("" & @CRLF) ToolTip("") WEnd Now instead of just having indexes and not remembering that [0] is X and [3] is Height, you can just use the more descriptive variable names. Also, did you even try @Andreik's suggestion? Eval is exactly what you're looking for in your original question, if you don't want to use Arrays. However I would definitely recommend an Array over Eval. If neither of those options work, another option for you is Maps, in the latest version of AutoIt. Maps (or a Scripting Dictionary) are just like the example I gave with using the variables for the Array indexes, except you can use strings directly. So ioa747's example again, but with Maps (maybe not used very efficiently): ; https://www.autoitscript.com/forum/topic/210615-converting-string-into-a-variable-name/?do=findComment&comment=1521771 #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include <array.au3> Global $sInputBoxAnswer Global $id = 0 ; active selection Global Enum $E_QUAD_X, $E_QUAD_Y, $E_QUAD_WIDTH, $E_QUAD_HEIGHT, $E_QUAD_MAX ; $E_QUAD_X = 0, $E_QUAD_Y = 1, etc. Global $mQuad[] ; Just like an Array declaration, except no size is given, signaling it's a map Global $mDimensions[] ; Another map that we'll put in our map $mQuad[1] = $mDimensions $mQuad[1]['X1'] = 100 $mQuad[1]['Y1'] = 100 $mQuad[1]['X2'] = 200 $mQuad[1]['Y2'] = 200 $mQuad[2] = $mDimensions $mQuad[2]['X1'] = 200 $mQuad[2]['Y1'] = 100 $mQuad[2]['X2'] = 300 $mQuad[2]['Y2'] = 300 $mQuad[3] = $mDimensions $mQuad[3]['X1'] = 500 $mQuad[3]['Y1'] = 200 $mQuad[3]['X2'] = 800 $mQuad[3]['Y2'] = 600 $mQuad[4] = $mDimensions $mQuad[4]['X1'] = 300 $mQuad[4]['Y1'] = 300 $mQuad[4]['X2'] = 1000 $mQuad[4]['Y2'] = 700 ;~ Global $aQuad[][$E_QUAD_MAX] = [ _ ;~ ["X", "Y", "W", "H"], _ ;~ [100, 100, 200, 200], _ ;~ [200, 100, 300, 300], _ ;~ [500, 200, 800, 600], _ ;~ [300, 300, 1000, 700]] ;~ _ArrayDisplay($aQuad) While 1 $sInputBoxAnswer = InputBox("Which quadrant to show?", @CRLF & "Number only", $id + 1) Select Case @error = 0 ;OK - The string returned is valid ConsoleWrite("$sInputBoxAnswer=" & $sInputBoxAnswer & @CRLF) $id = Int($sInputBoxAnswer) If MapExists($mQuad, $id) Then ConsoleWrite("X=" & $mQuad[$id]['X1'] & ", ") ConsoleWrite("Y=" & $mQuad[$id]['Y1'] & ", ") ConsoleWrite("W=" & $mQuad[$id]['X2'] & ", ") ConsoleWrite("H=" & $mQuad[$id]['Y2'] & @CRLF) MouseMove($mQuad[$id]['X1'], $mQuad[$id]['Y1']) ToolTip($mQuad[$id]['X1'] & ", " & $mQuad[$id]['Y1'], $mQuad[$id]['X1'], $mQuad[$id]['Y1'], "MouseMove XY") Sleep(500) MouseMove($mQuad[$id]['X2'], $mQuad[$id]['Y2']) ToolTip($mQuad[$id]['X2'] & ", " & $mQuad[$id]['Y2'], $mQuad[$id]['X2'], $mQuad[$id]['Y2'], "MouseMoveWH") Else EndIf Case @error = 1 ;The Cancel button was pushed Exit EndSelect Sleep(3000) ConsoleWrite("" & @CRLF) ToolTip("") WEnd I think that the main answer here for what you're looking to do is that Arrays are your best option, most likely. Of course personal preference will play a part, and someone else may say that SQLite is a better option (though you'll still have to go through Arrays a little bit as a middleman). Arrays are very important for the functionality of a lot of things, I definitely recommend spending some time writing some just test scripts using them, to understand them a little more.
  8. Just because I've had the same question and tested this a bit myself, here's results from a test that I ran in 2018: From this, Switch was always the fastest, and if you can, you should set/keep OnEventMode off. Things depend though, and you may not be able to always use Switch, or the different logic needed to get a specific way working may introduce additional slowdowns Edit: Just to be clear, the OnEventMode stuff doesn't have any direct connection/impact with Select/Switch/If, it's just something else that I was testing at the same time. In general things are a bit slower with OnEventMode, not just Select/Switch/If
  9. To add some more information to what @argumentum is saying, check out: https://superuser.com/questions/1456692/how-do-i-set-advance-file-association-in-windows-10-while-passing-app-parameter You may need to setup file associations again, or look into the registery for the au3 association and edit it to include the "%1" Alternatively in SciTE you can set command line params with Shift + F8 for scripts run from SciTE directly. Or compile to .exe and test with that instead of the .au3 file.
  10. You mainly just need to move your Function declarations outside of your For...Next loop, which should handle your primary issue. #include <MsgBoxConstants.au3> #include <Array.au3> #include <String.au3> Global $sText Global $sChart Global $sDirectory Global $aArray RunWait("C:\Program Files (x86)\DEXIS\Patient Administration.exe", "c:\Program Files (x86)\DEXIS") ;WinActivate ("DEXIS Administration") WinMove("DEXIS Administration", "", 70, 20, 700, 500) Local $i = 0 For $i = 1 To 10 MouseMove(370, 145) MouseClick('LEFT', 370, 145, 2) Sleep(5000) GetPatient() Chart() $sDirectory = ("C:\Users\Administrator.DAVIDSERVER\Desktop\Images\" & $aArray[0]) ;MsgBox($MB_SYSTEMMODAL, "", $sDirectory) DirCreate($sDirectory) Send("{a}") Sleep(1000) MouseClick('LEFT', 282, 219, 2) Sleep(1000) MouseClick('LEFT', 516, 45, 1) Sleep(1000) MouseClick('LEFT', 331, 61, 1) Sleep(1000) MouseClick('LEFT', 900, 638, 1) Sleep(1000) MouseClick('LEFT', 588, 45, 1) Sleep(1000) Send($sDirectory) MouseClick('LEFT', 460, 177, 1) Sleep(500) MouseClick('LEFT', 771, 610, 1) Sleep(10000) WinClose("DEXIS") Next Func Chart() ; Create an array of all the values between "(" and ")". $aArray = _StringBetween($sText, "(", ")") ; Display the results in _ArrayDisplay. ;_ArrayDisplay($aArray, "Default Search") EndFunc ;==>Chart Func GetPatient() ; Retrieve the window title of the active window. $sText = WinGetTitle("[ACTIVE]") ; Display the window title. ;MsgBox($MB_SYSTEMMODAL, "", $sText) EndFunc ;==>GetPatient The problem is that you can't declare a function in a loop, and why would you want to? At that point, just don't use a function, and include what's inside the function in the loop instead.
  11. #include <SQLite.dll.au3> ;needed? This line probably is not, though it may depend on your setup. The SQLite.au3 include definitely it, since it's what has all the functions for SQLite. Unless you're using a different SQLite UDF for AutoIt. But from SciTE you can always remove a line and then run SyntaxCheck Prod (Ctrl + F5) and see if there's any errors. There could still be a problem when it's actually run, but it's a quick way to see if an include is really "needed". It also usually doesn't hurt to include a file multiple times or have unneeded files.
  12. @AutoitMike Well if you don't like updating, then you may not like this, but Jos is working on an update to SciTE to have a dynamic/on the fly intellisense/type ahead that you're looking for, I believe: Otherwise it involves, as I understand it, updating the SciTE lexar/api: https://www.autoitscript.com/site/autoit-script-editor/downloads/ Specifically probably the "au3.api" file, which when I open it up with a text editor, I see things like: MouseClick ( "button" [, x, y [, clicks = 1 [, speed = 10]]] ) Perform a mouse click operation. MouseClickDrag ( "button", x1, y1, x2, y2 [, speed = 10] ) Perform a mouse click and drag operation. MouseDown ( "button" ) Perform a mouse down event at the current mouse position. MouseGetCursor ( ) Returns the cursor ID Number for the current Mouse Cursor. MouseGetPos ( [dimension] ) Retrieves the current position of the mouse cursor. MouseMove ( x, y [, speed = 10] ) Moves the mouse pointer. Which seems to match up exactly with ScITEs intellisense/type ahead/function complete/whatever.
  13. You may want to check your Internet Options, specifically Connections -> LAN Settings: Make sure that there's nothing setup in there, or that it's set up correctly. If you manually enter it in an Internet Explorer window, does it work or fail? What's under the 'More Info' button on the page? You could also look into using the WebDriver UDF to do it through a different browser:
  14. Here's something to keep in mind regarding data types and comparing them (or even checking if they are a specific type): https://www.autoitscript.com/autoit3/docs/intro/lang_operators.htm#:~:text=Comparing different datatypes Another thing to look at is: https://www.autoitscript.com/autoit3/docs/functions/VarGetType.htm Maybe not entirely useful here, but it's along the same lines and is important to keep in mind.
  15. Another thing is that some sites will accept a format like: http://username:password@192.168.1.56:3456, so you can try that, though I have no idea what the page looks like or how it's prompting the password. I think that usually that format only works for sites that prompt user/pass with a browser alert/dialog box, and not a form. That function (_IEFormElementExists) does not exist in AutoIt, it's likely a UDF they're using or made. However to make the code work, it's just a couple changes to do (mostly) the same thing: #include <Constants.au3> #include <IE.au3> ; Open Internet Explorer Global $oIE = _IECreate() ; Navigate to the URL _IENavigate($oIE, "http://192.168.1.56:3456") ; Wait for the page to load _IELoadWait($oIE) Global $oPasswordField = _IEGetObjByName($oIE, "password_field_name") ; Check if a password prompt is displayed If Not @error Then _IEFormElementSetValue($oPasswordField, "your_password") ; Submit the form _IEFormSubmit($oPasswordField) Sleep(2000) ; Wait for the form to submit ; Close the browser _IEQuit($oIE) ElseIf _IEPropertyGet($oIE, "readyState") = "404" Then ; Close the browser _IEQuit($oIE) EndIf Just _IEGetObjByName is enough to check if it 'exists', since it'll throw an @error if it doesn't
×
×
  • Create New...