
Monoxide
Members-
Posts
5 -
Joined
-
Last visited
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
Monoxide's Achievements

Seeker (1/7)
0
Reputation
-
Thank you Nine and BrewManNH, this is exactly what fixed the issue, I didn't read far enough in the help file that the hotkey interrupts any running function. FYI HotKeySet("`") disables the hotkey just for those that view this in the future. Not whats listed in the quote
-
I have a issue that is stumping me with an array error. I have a random number picker with 2 array's, 1 array holds the numbers available, the other array holds the used numbers. It is controlled by key press set as hotkey. The error seems like a timing issue as if I have it auto run(just called the function on a loop) with a 5 sec delay it can go through 5000 random draws with no problem. When I just hold down the key or do not give it 2-3 sec between pushes it seems to error out. Error I see in the console when running, it can be after 5 numbers or could be 50 or more numbers in. Console output and Error: ! Random Number: 963 Update the Text Move # from Available to Used Delete from Available Available Numbers: 865 Used Numbers: 134 Available Numbers: 864 Used Numbers: 134 Random Numbers From : 1 to 864 Number Picked: 168 ! Random Number: 199 Update the Text Move # from Available to Used Delete from Available Update Number of Available Update Number of Used Update Number on Display Saving used array to file Update Number of Available Update Number of Used Update Number on Display Saving used array to file Update Number of Available Update Number of Used Update Number on Display Saving used array to file Update Number of Available Update Number of Used Update Number on Display Saving used array to file Update Number of Available Update Number of Used Update Number on Display Saving used array to file Delete from Available Update Number of Available Update Number of Used Update Number on Display Saving used array to file Move # from Available to Used Delete from Available Update Number of Available Update Number of Used Update Number on Display Saving used array to file Update Number of Used Update Number on Display Saving used array to file Available Numbers: 861 Used Numbers: 141 Random Numbers From : 1 to 861 Number Picked: 270 ! Random Number: 315 Update the Text Move # from Available to Used Delete from Available Update Number of Available Update Number of Used Update Number on Display Saving used array to file Update the Text Move # from Available to Used Delete from Available Update Number of Available Update Number of Used Update Number on Display Saving used array to file "C:\Program Files (x86)\AutoIt3\Include\Array.au3" (438) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: If $aArray[$iReadFrom_Index] == ChrW(0xFAB1) Then If ^ ERROR ; *** Start added by AutoIt3Wrapper *** #include <FileConstants.au3> ; *** End added by AutoIt3Wrapper *** #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile_x64=..\..\..\Desktop\PillDraw.Exe #AutoIt3Wrapper_Add_Constants=n #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <Array.au3> #include <MsgBoxConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <File.au3> Opt("GUIOnEventMode", 1) Dim $BagNumbers[1] = ["0"] Dim $BagNumbersTemp = 0 Dim $BagNumbersStart = 1 Dim $UsedNumbers[1] = ["0"] Dim $iMax = UBound($BagNumbers) ; get array size Dim $UsedMax = UBound($UsedNumbers) ; get array size Dim $MaxNumbers = 0 Dim $Lock = 0 Dim $sFilePathUsed = @MyDocumentsDir & "\Used.txt" Dim $sFilePathSeed = @MyDocumentsDir & "\Seed.txt" ;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ConsoleWrite("Available Numbers: " & $iMax & @LF) ConsoleWrite("Used Numbers: " & $UsedMax & @LF) ;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ HotKeySet("{ESC}", "Terminate") HotKeySet("`", "_RandomPicker") HotKeySet("~", "_ShowUsed") Opt("GUIOnEventMode", 1) ; Input for the Seed Number, restore previous if 0 Local $PopulatePills = InputBox("Pill Setup? ", "Please enter the total number of " & @CRLF & "Pill numbers to populate." & @CRLF & @CRLF & "Enter 0 to restore previous draw session") ConsoleWrite("Pill Input: " & $PopulatePills & @LF) If $PopulatePills = 0 Then _RestoretheSeed() Else _MakethePills($PopulatePills) _SavetheSeed($PopulatePills) EndIf ConsoleWrite("Available Numbers: " & $iMax & @LF) ConsoleWrite("Used Numbers: " & $UsedMax & @LF) $Start_Bar = ControlGetPos('', 'Start', 40965) #Region ### START Koda GUI section ### Form= ;$Form1 = GUICreate("Pill by button press", 1319, 747, 192, 124) $Form1 = GUICreate('Pill by button press', @DesktopWidth, @DesktopHeight - $Start_Bar[3] - 25) $Label1 = GUICtrlCreateLabel("Wait", 16, 0, @DesktopWidth - 16, 113, BitOR($SS_CENTER, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_THICKFRAME)) ;Press The Red Button GUICtrlSetFont(-1, 70, 800, 0, "Rockwell Extra Bold") GUICtrlSetBkColor(-1, 0xFF0000) $Label2 = GUICtrlCreateLabel("", 16, 150, @DesktopWidth - 16, 375, BitOR($SS_CENTER, $SS_CENTERIMAGE)) ;the number picked GUICtrlSetFont(-1, 350, 400, 0, "Rockwell Extra Bold") GUICtrlSetColor(-1, 0x000000) $Label3 = GUICtrlCreateLabel("", 16, 120, @DesktopWidth - 16, 50, BitOR($SS_CENTER, $SS_CENTERIMAGE)) ;Numbers used: Numbers available: Max Number: GUICtrlSetFont(-1, 30, 400, 0, "MS Sans Serif") GUISetState(@SW_SHOW) ;$pic = GUICtrlCreatePic('C:\Users\tj\OneDrive\AutoItCode\Pill Generator\logo.bmp', 600, 130, 600, 130, BitOR($WS_EX_TRANSPARENT, $SS_CENTER, $SS_CENTERIMAGE)) $Pic1 = GUICtrlCreatePic("C:\Users\tj\OneDrive\AutoItCode\Pill Generator\logo.jpg", @DesktopWidth / 2 - 500, @DesktopHeight / 2, 1000, 200) ;, BitOR($WS_EX_TRANSPARENT, $SS_CENTER, $SS_CENTERIMAGE)) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### GUICtrlSetData($Label3, "Numbers used: " & $UsedMax & " Numbers left: " & $iMax & " Out of: " & $MaxNumbers) ;GUICtrlSetPos($Pic, @DesktopWidth, @DesktopHeight - 300, 600, 130) While 1 ;_RandomPicker() Sleep(250) Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idOK Exit EndSwitch WEnd Func _RandomPicker() $iMax = UBound($BagNumbers) - 1 If $iMax = 0 Then MsgBox($MB_SYSTEMMODAL, "Danger Will Robinson", "You have used all available numbers.") Else GUICtrlSetBkColor($Label1, 0xFF0000) GUICtrlSetData($Label1, "Wait for instructions") ConsoleWrite("Available Numbers: " & $iMax & @LF) ConsoleWrite("Used Numbers: " & $UsedMax & @LF) Local $NumberPicked = Random(1, $iMax, 1) ConsoleWrite("Random Numbers From : 1 to " & $iMax & @LF) ConsoleWrite("Number Picked: " & $NumberPicked & @LF) ConsoleWrite("! " & "Random Number: " & $BagNumbers[$NumberPicked] & @LF) Sleep(250) ConsoleWrite("Update the Text" & @LF) GUICtrlSetData($Label2, $BagNumbers[$NumberPicked]) ConsoleWrite("Move # from Available to Used" & @LF) _ArrayAdd($UsedNumbers, $BagNumbers[$NumberPicked]) Sleep(250) ConsoleWrite("Delete from Available" & @LF) _ArrayDelete($BagNumbers, $NumberPicked) Sleep(250) ConsoleWrite("Update Number of Available" & @LF) $iMax = UBound($BagNumbers) - 1 Sleep(250) ConsoleWrite("Update Number of Used" & @LF) $UsedMax = UBound($UsedNumbers) - 1 $Lock = 0 ConsoleWrite("Update Number on Display" & @LF) GUICtrlSetData($Label3, "Numbers used: " & $UsedMax & " Numbers left: " & $iMax & " Out of: " & $MaxNumbers) _SavetheData() EndIf $Lock = 0 EndFunc ;==>_RandomPicker Func Terminate() Exit EndFunc ;==>Terminate Func _ShowUsed() ConsoleWrite("Available Numbers: " & $iMax & @LF) ConsoleWrite("Used Numbers: " & $UsedMax & @LF) ;_ArrayDisplay($UsedNumbers, "Numbers Used") GUICtrlSetBkColor($Label1, 0x00FF00) If $Lock = 0 Then GUICtrlSetData($Label1, "Press RED button to Draw") GUICtrlSetData($Label2, "Draw") $Lock = 1 Else GUICtrlSetBkColor($Label1, 0xFF0000) GUICtrlSetData($Label1, "Wait for instructions") GUICtrlSetData($Label2, "Wait") $Lock = 0 EndIf EndFunc ;==>_ShowUsed Func _MakethePills($x) While $iMax < $x _ArrayAdd($BagNumbers, $BagNumbersStart) $BagNumbersStart = $BagNumbersStart + 1 $iMax = UBound($BagNumbers) - 1 $UsedMax = UBound($UsedNumbers) - 1 WEnd $iMax = UBound($BagNumbers) - 1 ;_ArrayDisplay($BagNumbers, "Numbers Used") $MaxNumbers = $iMax EndFunc ;==>_MakethePills Func _SavetheData() ;************************ ;save array to text file ;************************ ConsoleWrite("Saving used array to file" & @LF) _FileWriteFromArray($sFilePathUsed, $UsedNumbers, 1) ;MsgBox(0, "", "array was written to text file ") EndFunc ;==>_SavetheData Func _RestoretheData() ;************************** ;read array from text file ;************************** If Not _FileReadToArray($sFilePathUsed, $UsedNumbers) Then MsgBox(4096, "Error", " Error reading Array error:" & @error) Exit EndIf _MakethePills($PopulatePills) ;_ArrayDisplay($UsedNumbers, "Elements to deleted") ;$BagNumbers $UsedNumbers For $i = UBound($UsedNumbers) - 1 To 1 Step -1 ConsoleWrite("Searching for: " & $UsedNumbers[$i] & @CRLF) $vSrch = _ArraySearch($BagNumbers, $UsedNumbers[$i]) ;_ArraySearch($BagNumbers , $UsedNumbers[$i] , 0 , $i - 1) ConsoleWrite("VSearch:" & $vSrch & @CRLF) If $vSrch > 0 Then _ArrayDelete($BagNumbers, $vSrch) Sleep(250) Next ;_ArrayDisplay($BagNumbers, "Elements deleted") $BagNumbersStart = $BagNumbersStart + 1 $iMax = UBound($BagNumbers) - 1 $UsedMax = UBound($UsedNumbers) - 1 EndFunc ;==>_RestoretheData Func _SavetheSeed($x) ConsoleWrite("Save the Seed" & @CRLF) ConsoleWrite($x & @CRLF) _FileCreate($sFilePathSeed) If Not _FileCreate($sFilePathSeed) Then MsgBox($MB_SYSTEMMODAL, "Error", " Error Creating/Resetting log. error:" & @error) EndIf ; Open the file for writing (append to the end of a file) and store the handle to a variable. Local $hFileOpen = FileOpen($sFilePathSeed, $FO_APPEND) If $hFileOpen = -1 Then MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst writing the temporary file.") Return False EndIf ; Write data to the file using the handle returned by FileOpen. FileWrite($hFileOpen, $x & @CRLF) ; Close the handle returned by FileOpen. FileClose($hFileOpen) EndFunc ;==>_SavetheSeed Func _RestoretheSeed() ; Open the file for reading and store the handle to a variable. Local $hFileOpen = FileOpen($sFilePathSeed, $FO_READ) If $hFileOpen = -1 Then MsgBox($MB_SYSTEMMODAL, "", "An error occurred when reading the file.") Return False EndIf ; Read the fist line of the file using the handle returned by FileOpen. Local $sFileRead = FileReadLine($hFileOpen, 1) $PopulatePills = $sFileRead ; Close the handle returned by FileOpen. FileClose($hFileOpen) ConsoleWrite("Restoring picked numbers" & @CRLF) _RestoretheData() EndFunc ;==>_RestoretheSeed There is also an error when compiled that I believe is the same issue. "Error: Array variable has incorrect number of subscripts or subscripts dimension range exceeded."
-
I am using MessageLoop mode for the GUI. I have multiple groups of yes/no radio box. Once Group1 has a selection, Group2 is un-hid. Group3 is hidden until Group2 has a selection. The Edit1 box is never hidden. I need to require input in the Edit1 box if either or both Group1 is "yes" or Group2 is "no" before Group3 is displayed. I seem to be drawing a blank on how to accomplish this. How can I add a check to see if the Edit1 box has data so Group2 or Group3 can then be un-hid?
-
I have been searching for the answer to this same post and some other error's for the last week. I found another thread with the COM error code snippet posted below. After adding to the end of "AccessConstants.au3" script I was able to discover exactly what my problem was. Hopefully this will assist someone else with the same issue. Thanks GEOSoft for the great UDF! Now its just a learning curve to get everything to work as I need it to. Global $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") Func MyErrFunc() $HexNumber = Hex($oMyError.number, 8) MsgBox(0, "COM Error", "COM Error Details:" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & $HexNumber & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) SetError(1) EndFunc ;==>ComErrHandler