Jump to content

All Activity

This stream auto-updates     

  1. Past hour
  2. ok..figured out some of it...When the unit reboots, it sends the name, serial number, and other info back to the script...I didnt filter that info out so it actually was getting added to the show stat array....causing the error...Thanks @Jojo-OP2, used the console....working now to filter the response from the unit! Thanks @jdelaney, still learning the error checking of arrays!!
  3. Possible workaround: ControlClick($hWnd, '', '[CLASS:TPageControl; INSTANCE:1]', 'primary', 1, $g_aGuiLoc[$LOC_TAB_2][$COORD_X], $g_aGuiLoc[$LOC_TAB_2][$COORD_Y]) Where $g_aGuiLoc contains coordinates to (somewhere inside) concerning tab header (relative to TPageControl's location). Address controls by INSTANCE. First activation of each tab changes INSTANCE number of controls (cycle through all tabs first for INSTANCE to consistently relate to same control). Now it should be possible to address controls by for example [CLASS:TEdit; INSTANCE:25] (even if another tab than containing one is visible). Not all GUICtrl...() functions work for Delphi controls (most cases solvable using workarounds however).
  4. ConsoleWrite($sResult) $srString = StringReplace($sResult, @CRLF & @CRLF, @CRLF) $srString = StringReplace($srString, "SHOW STAT", "") $srString = StringReplace($srString, "ATTN", "") $srString = StringReplace($srString, ">", "") $srString = StringReplace($srString, @CRLF, "|") $srString = StringStripWS($srString, $STR_STRIPLEADING + $STR_STRIPTRAILING + $STR_STRIPSPACES) ConsoleWrite($srString & @CRLF) $aSTATtemp = StringSplit($srString, "|", 2) Can you insert the 2 Consolewrite lines and check if the output is correct ? And since you use $cols for your columms you should also use it for your loop instead of Ubound($cell, 1) - 1 Edit : Unless you expect a diffrent number of cells every time* Local $cols = 3 Local $arr[1][$cols] Local $cell For $ii = 0 To UBound($aSTATtemp, 1) - 1 $cell = StringSplit($aSTATtemp[$ii], " ", 2) ReDim $arr[UBound($arr, 1) + 1][$cols] For $jj = 0 To $cols - 1 ; <===== use $cols $arr[$ii][$jj] = $cell[$jj] Next Next _ArrayDelete($arr, UBound($arr, 1) - 1) _ArrayColDelete($arr, 0)
  5. Hello every one, I wrote this function which can be used to do a task in the main loop without using : Sleep() inspired : https://www.autoitscript.com/forum/topic/198580-check-every-10sec-_imagesearch/ .... Here is the function : ;Timer_Task.au3 #include <Array.au3> #Region Example While 1 _Loop_Task("_Test()", 1, 1000) Sleep(1000) Wend Func _Test() MsgBox(0, 0, 0) EndFunc #EndRegion Example ; #FUNCTION# ===================================================================================================================== ; Name ..........: _Loop_Task ; Description ...: Doing a Task in the main loop without using Sleep() ; Syntax ........: _Loop_Task($Task, $Index, $MSEC_To_Wait) ; Parameters ....: $Task - A string of the task ..like this : "MsgBox(0, 0, 0)" ; $Index - A unique value which specifies the task , it is unique as 2 tasks can't have the same index ; $MSEC_To_Wait - the number of Milliseconds to wait...the task will be done every ($MSEC_To_Wait) Milliseconds ; Return values .: None ; Author ........: El-Masry : إبراهيم عصام الدين يوسف ; Email .........: iimosa7777@gmail.com ; Written in ....: ISN Autoit Studio ; With Example ..: Yes ; Inspired.......: https://www.autoitscript.com/forum/topic/198580-check-every-10sec-_imagesearch/ ; ================================================================================================================================ Func _Loop_Task($Task, $Index, $MSEC_To_Wait) ;note : #include <Array.au3> If IsDeclared("Task_Index_3425") == 0 Then Global $Task_Index_3425[] = [0] If _ArraySearch($Task_Index_3425, $Index) == -1 Then _ArrayAdd($Task_Index_3425, $Index) $Task_ID = _ArraySearch($Task_Index_3425, $Index) ConsoleWrite("Task ID = " & $Task_ID& @CRLF) If IsDeclared("Timer_Start_3425_" & $Task_ID) Then $M_Time = TimerDiff(Eval("Timer_Start_3425_" & $Task_ID)) ConsoleWrite("M_Time = " & $M_Time & @CRLF) If IsDeclared("Task_3425_" & $Task_ID) == 0 Then Assign("Task_3425_" & $Task_ID, 0, 2) ConsoleWrite("Waited Time = " & Eval("Task_3425_" & $Task_ID)& @CRLF) Assign("Task_3425_" & $Task_ID, Eval("Task_3425_" & $Task_ID) + $M_Time, 2) ConsoleWrite(Eval("Task_3425_" & $Task_ID)& @CRLF) If Eval("Task_3425_" & $Task_ID) >= $MSEC_To_Wait Then Execute($Task) Assign("Task_3425_" & $Task_ID, 0, 2) EndIf EndIf Assign("Timer_Start_3425_" & $Task_ID, TimerInit(), 2) EndFunc Have fun with it
  6. Today
  7. Thanks so much!!! I was working forever trying to get this done.
  8. Seems your string split returns more than the second dimension of you array. Add in error handling.
  9. $Form1 = GUICreate("Form1", 409, 437, -1, -1) GUISetBkColor (0xF7F3F7) $TreeView1 = GUICtrlCreateTreeView(0, 0, 289, 433) GUICtrlSetBkColor (-1, 0xF7F3F7)
  10. An other way could be Scripting.Dictionary ;Local $sAlphabet = "ABCDEFGHIJKLMOPQRSTUVWXYZ" Local $sAlphabet = "ABCDEFGHIJKL" $aAlphabet = StringSplit($sAlphabet, "", 2) Local $sWord = "Hello" $aWord = StringSplit($sWord, "", 2) Local $sdAlphabet = ObjCreate("Scripting.Dictionary"), $count $sdAlphabet.CompareMode = 1 ; case insensitive For $i In $aAlphabet $sdAlphabet.Item($i) ; populate the dictionary Next For $i In $aWord If $sdAlphabet.Exists($i) Then $count += 1 ; then check Next Msgbox(0,"", $count & " values out of " & UBound($aWord) & " from $aWord exist in $aAlphabet")
  11. And what is the application you are trying to read text from ? If it is pixel based, you will need to read it thru an OCR apps.
  12. SO...I am horrible at arrays, as many of you that have helped me know!! This program works like a champ, until I reboot the test unit...then....bleck!!! I have it narrowed down to the _SwitchPos($hFile) function i have writen, which sends a SHOW STATUS command to the unit under test, recieves the status of all the attenuators and RF switches. Upon a reboot command it throws the ""K:\Work\AutoIT Scripts\Mine\Models\10204\Edit\Test\10204_Functions.au3" (184) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $arr[$ii][$jj] = $cell[$jj].... Ive tried resetting the $arr to 0, redim, ubound, destoy it, kick it, tell it no dessert, but it refuses to function!! The only thing that worked was the _ScriptRestart() function I found in the forums, but I dont think killing the script and restarting it is the most efficient way...plus you loose the data in the rich text window that needs to be kept and sent to a file for archive purposes.... Any help would be greatly appreciated.. This is the core of the script... #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=..\..\..\..\..\Icons\DXP_Options_PrinterSetup_ICON.ico #AutoIt3Wrapper_Compression=3 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #cs ============================ # Header # ============================================================= Title ............: 10204 Core Test Description ......: Script Version ...: Author ...........: Charles Wright Language .........: English AutoIt Version ...: 3.3.14.5 Notes ............: Version History ..: Alpha Build #ce ============================ # Header # ============================================================= ; ======================================================================================================== #Region Main Includes ------------------------------------------------------------------------------------ ; ======================================================================================================== #include-once #include <Array.au3> #include <ButtonConstants.au3> #include <ColorConstants.au3> #include <CommInterface.au3> #include <EditConstants.au3> #include <FontConstants.au3> #include <GUIConstantsEx.au3> #include <GuiRichEdit.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <Restart.au3> #include "10204_Functions.au3" ; ======================================================================================================== #EndRegion Main Includes ------------------------------------------------------------------------------------ ; ======================================================================================================== Opt("GUIResizeMode", $GUI_DOCKAUTO) ; ======================================================================================================== #Region Main Variables ----------------------------------------------------------------------------------- ; ======================================================================================================== $SoundFile = "C:\Windows\Media\Windows Ding.wav" FileInstall("C:\Windows\Media\Windows Ding.wav", $SoundFile) $MyIcon = "K:\Work\AutoIT Scripts\Icons\DXP_Options_PrinterSetup_ICON.ico" ;Load MyIcon for Menu Bar FileInstall("K:\Work\AutoIT Scripts\Icons\DXP_Options_PrinterSetup_ICON.ico", $MyIcon) ; Install ico when compiled Global $ClickConnect = 0, $StatusMemo = "" Global $hFile Global $aResult[0] Global $aSTAT[0][1] Global $sSwitchName Global $sResult = "" Global $SW1, $SW2, $SW3, $SW4, $SW5, $SW6, $SW7, $SW8, $SW9 ; ======================================================================================================== #EndRegion Main Variables -------------------------------------------------------------------------------- ; ======================================================================================================== ; ======================================================================================================== #Region Main GUI Creation -------------------------------------------------------------------------------- ; ======================================================================================================== $g_10204Test = GUICreate("10204 Test", 836, 694, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME)) GUISetBkColor(0xFFFBF0) ; ##### Connect and Edit Window ####################################################### GUICtrlCreateLabel("COM Port:", 144, 16, 77, 24, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $i_CommPort = GUICtrlCreateInput("", 226, 16, 41, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER)) $b_Connect = GUICtrlCreateButton("Connect", 273, 16, 75, 25) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetBkColor(-1, 0xFF0000) $b_Disconnect = GUICtrlCreateButton("Disconnect", 352, 16, 75, 25) $b_Reboot = GUICtrlCreateButton("Reboot", 432, 16, 75, 25) $g_hRichEdit = _GUICtrlRichEdit_Create($g_10204Test, "", 8, 48, 617, 297, _ BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL, $ES_READONLY)) ; ##### TX1 Output Paths ############################################################## GUICtrlCreateLabel("4.4.2", 40, 352, 39, 24) GUICtrlSetFont(-1, 12, 400, 4, "MS Sans Serif") $b_TX1 = GUICtrlCreateButton("TX1", 24, 376, 67, 25) GUICtrlSetBkColor(-1, 0xBFCDDB) $b_J11J17 = GUICtrlCreateButton("J11-J17", 24, 408, 67, 25) GUICtrlSetBkColor(-1, 0xBFCDDB) $b_J12J17 = GUICtrlCreateButton("J12-J17", 24, 440, 67, 25) GUICtrlSetBkColor(-1, 0xBFCDDB) $b_J13J17 = GUICtrlCreateButton("J13-J17", 24, 472, 67, 25) GUICtrlSetBkColor(-1, 0xBFCDDB) $b_J14J17 = GUICtrlCreateButton("J14-J17", 24, 504, 67, 25) GUICtrlSetBkColor(-1, 0xBFCDDB) $b_J15J17 = GUICtrlCreateButton("J15-J17", 24, 536, 67, 25) GUICtrlSetBkColor(-1, 0xBFCDDB) $b_J16J17 = GUICtrlCreateButton("J16-J17", 24, 568, 67, 25) GUICtrlSetBkColor(-1, 0xBFCDDB) $b_J16J17Amp = GUICtrlCreateButton("J16-J17 AMP", 24, 600, 67, 25) GUICtrlSetBkColor(-1, 0xBFCDDB) ; ##### RX1 Input Paths ############################################################### GUICtrlCreateLabel("4.4.3", 128, 352, 39, 24) GUICtrlSetFont(-1, 12, 400, 4, "MS Sans Serif") $b_RX1 = GUICtrlCreateButton("RX1", 112, 376, 67, 25) GUICtrlSetBkColor(-1, 0xBFCDDB) $b_J10J4 = GUICtrlCreateButton("J10-J4", 112, 408, 67, 25) GUICtrlSetBkColor(-1, 0xBFCDDB) $b_J10J5 = GUICtrlCreateButton("J10-J5", 112, 440, 67, 25) GUICtrlSetBkColor(-1, 0xBFCDDB) $b_J10J6 = GUICtrlCreateButton("J10-J6", 112, 472, 67, 25) GUICtrlSetBkColor(-1, 0xBFCDDB) $b_J10J7 = GUICtrlCreateButton("J10-J7", 112, 504, 67, 25) GUICtrlSetBkColor(-1, 0xBFCDDB) $b_J10J8 = GUICtrlCreateButton("J10-J8", 112, 536, 67, 25) GUICtrlSetBkColor(-1, 0xBFCDDB) $b_J10J9 = GUICtrlCreateButton("J10-J9", 112, 568, 67, 25) GUICtrlSetBkColor(-1, 0xBFCDDB) ; ##### RX2 Input Paths ############################################################### GUICtrlCreateLabel("4.4.4", 216, 352, 39, 24) GUICtrlSetFont(-1, 12, 400, 4, "MS Sans Serif") $b_J3J4 = GUICtrlCreateButton("J3-J4", 200, 376, 67, 25) GUICtrlSetBkColor(-1, 0xBFCDDB) $b_J3TERM = GUICtrlCreateButton("J3 TERM", 200, 408, 67, 25) GUICtrlSetBkColor(-1, 0xBFCDDB) $b_J3J18 = GUICtrlCreateButton("J3-J18", 200, 440, 67, 25) GUICtrlSetBkColor(-1, 0xBFCDDB) $b_J3J19 = GUICtrlCreateButton("J3-J19", 200, 472, 67, 25) GUICtrlSetBkColor(-1, 0xBFCDDB) $b_J3J20 = GUICtrlCreateButton("J3-J20", 200, 504, 67, 25) GUICtrlSetBkColor(-1, 0xBFCDDB) GUICtrlCreateLabel("COM Port:", 144, 16, 77, 24, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") ; ##### Attenuator Test ############################################################### GUICtrlCreateLabel("4.4.5", 304, 352, 39, 24) GUICtrlSetFont(-1, 12, 400, 4, "MS Sans Serif") $b_SetSwitch1 = GUICtrlCreateButton("Set Switches", 288, 376, 67, 25) GUICtrlSetBkColor(-1, 0xBFCDDB) ; ##### Power Meters Test ############################################################# GUICtrlCreateLabel("4.4.6", 392, 352, 39, 24) GUICtrlSetFont(-1, 12, 400, 4, "MS Sans Serif") $b_SetSwitch2 = GUICtrlCreateButton("Set Switches", 376, 376, 75, 25) GUICtrlSetBkColor(-1, 0xBFCDDB) $b_PM1 = GUICtrlCreateButton("Query PM 1", 376, 408, 75, 25) GUICtrlSetBkColor(-1, 0xBFCDDB) $b_PM2 = GUICtrlCreateButton("Query PM 2", 376, 440, 75, 25) GUICtrlSetBkColor(-1, 0xBFCDDB) $i_PM1OffSet = GUICtrlCreateInput("", 376, 480, 73, 21) $b_PM1OffSet = GUICtrlCreateButton("PM 1 Off Set", 376, 504, 75, 25) GUICtrlSetBkColor(-1, 0xBFCDDB) $i_PM2OffSet = GUICtrlCreateInput("", 376, 544, 73, 21) $b_PM2OffSet = GUICtrlCreateButton("PM 2 Off Set", 376, 568, 75, 25) GUICtrlSetBkColor(-1, 0xBFCDDB) $b_AttnZero = GUICtrlCreateButton("Set Attn's to 0", 472, 376, 75, 25) GUICtrlSetBkColor(-1, 0xBFCDDB) GUICtrlCreateLabel("4.4.7", 488, 352, 39, 24) GUICtrlSetFont(-1, 12, 400, 4, "MS Sans Serif") $b_NFT1 = GUICtrlCreateButton("J16-J17", 568, 376, 59, 25) GUICtrlSetBkColor(-1, 0xBFCDDB) GUICtrlCreateLabel("4.4.9", 584, 352, 39, 24) GUICtrlSetFont(-1, 12, 400, 4, "MS Sans Serif") $b_NFT2 = GUICtrlCreateButton("J3-J18", 568, 408, 59, 25) GUICtrlSetBkColor(-1, 0xBFCDDB) $b_NFT3 = GUICtrlCreateButton("J10-J9", 568, 440, 59, 25) GUICtrlSetBkColor(-1, 0xBFCDDB) ; Switch 1 Position Markers ================================================================================= GUICtrlCreateLabel("SW 1", 712, 40, 43, 24, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetFont(-1, 12, 400, 4, "MS Sans Serif") Global $abS1[7] For $bS1 = 1 + 0 To 6 $abS1[$bS1] = GUICtrlCreateButton($bS1, 625 + ($bS1 * 27), 64, 27, 24) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetBkColor(-1, 0xFFFBF0) Next ; =========================================================================================================== ; Switch 2 Position Markers ================================================================================= GUICtrlCreateLabel("SW 2", 712, 104, 43, 24, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetFont(-1, 12, 400, 4, "MS Sans Serif") Global $abS2[7] For $bS2 = 1 + 0 To 6 $abS2[$bS2] = GUICtrlCreateButton($bS2, 625 + ($bS2 * 27), 128, 27, 24) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetBkColor(-1, 0xFFFBF0) Next ; =========================================================================================================== ; Switch 3 Position Markers ================================================================================= GUICtrlCreateLabel("SW 3", 712, 160, 43, 24, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetFont(-1, 12, 400, 4, "MS Sans Serif") Global $abS3[3] For $bS3 = 1 + 0 To 2 $abS3[$bS3] = GUICtrlCreateButton($bS3, 680 + ($bS3 * 27), 183, 27, 24) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetBkColor(-1, 0xFFFBF0) Next ; =========================================================================================================== ; Switch 4 Position Markers ================================================================================= GUICtrlCreateLabel("SW 4", 711, 227, 43, 24, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetFont(-1, 12, 400, 4, "MS Sans Serif") Global $abS4[3] For $bS4 = 1 + 0 To 2 $abS4[$bS4] = GUICtrlCreateButton($bS4, 680 + ($bS4 * 27), 250, 27, 24) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetBkColor(-1, 0xFFFBF0) Next ; =========================================================================================================== ; Switch 5 Position Markers ================================================================================= GUICtrlCreateLabel("SW 5", 713, 283, 43, 24, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetFont(-1, 12, 400, 4, "MS Sans Serif") Global $abS5[3] For $bS5 = 1 + 0 To 2 $abS5[$bS5] = GUICtrlCreateButton($bS5, 680 + ($bS5 * 27), 307, 27, 24) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetBkColor(-1, 0xFFFBF0) Next ; =========================================================================================================== ; Switch 6 Position Markers ================================================================================= GUICtrlCreateLabel("SW 6", 713, 349, 43, 24, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetFont(-1, 12, 400, 4, "MS Sans Serif") Global $abS6[3] For $bS6 = 1 + 0 To 2 $abS6[$bS6] = GUICtrlCreateButton($bS6, 680 + ($bS6 * 27), 373, 27, 24) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetBkColor(-1, 0xFFFBF0) Next ; =========================================================================================================== GUICtrlCreateLabel("ATTN 1", 672, 440, 119, 24, $SS_CENTER) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $i_Attn1 = GUICtrlCreateInput("", 664, 472, 121, 32, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER)) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") GUICtrlCreateLabel("ATTN 2", 672, 520, 119, 24, $SS_CENTER) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $i_Attn2 = GUICtrlCreateInput("", 664, 544, 121, 32, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER)) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") ; =========================================================================================================== $b_OutFile = GUICtrlCreateButton("Send To File", 544, 16, 75, 25) GUICtrlSetBkColor(-1, 0xBFCDDB) GUISetState(@SW_SHOW) ; =========================================================================================================== GUICtrlCreateLabel("Manual Command", 328, 616, 113, 20, $SS_CENTER) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $i_Manual = GUICtrlCreateInput("", 112, 640, 521, 21) $b_Manual = GUICtrlCreateButton("Send", 640, 640, 75, 25) GUICtrlSetBkColor(-1, 0xBFCDDB) ; =========================================================================================================== _DisplayPorts($g_hRichEdit) ; ======================================================================================================== #EndRegion Main GUI Creation -------------------------------------------------------------------------------- ; ======================================================================================================== While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $b_Connect If $ClickConnect = 0 Then _ConnectSet($i_CommPort) _SwitchPos($hFile) Else SoundPlay($SoundFile) _GUICtrlRichEdit_SetCharColor($g_hRichEdit, 255) _GUICtrlRichEdit_AppendText($g_hRichEdit, "You are already Connected." & @CRLF) EndIf If $ClickConnect = "1" Then GUICtrlSetBkColor($b_Connect, $COLOR_GREEN) Else GUICtrlSetBkColor($b_Connect, $COLOR_RED) EndIf Case $b_Disconnect If $ClickConnect = 0 Then SoundPlay($SoundFile) _GUICtrlRichEdit_SetCharColor($g_hRichEdit, 255) _GUICtrlRichEdit_AppendText($g_hRichEdit, "You are already Disconnected." & @CRLF) GUICtrlSetState($b_Connect, $GUI_FOCUS) Else _CommAPI_ClosePort($hFile) GUICtrlSetBkColor($b_Connect, $COLOR_RED) _GUICtrlRichEdit_SetCharColor($g_hRichEdit, 255) _GUICtrlRichEdit_AppendText($g_hRichEdit, "User Disconnected." & @CRLF) $ClickConnect = 0 EndIf Case $b_Reboot $uInput = "REBOOT" _UnitSend($uInput) _GUICtrlRichEdit_SetCharColor($g_hRichEdit, 16711680) _UnitRecieve($StatusMemo) ;_ScriptRestart() Debug Only _SwitchPos($hFile) ; ### 4.4.2 ############################################################################### Case $b_TX1 $uInput = "SetSwitch 4 1 0; SetSwitch 5 1 0; SetAttenuator 1 0" _UnitSend($uInput) _GUICtrlRichEdit_SetCharColor($g_hRichEdit, 16711680) _UnitRecieve($StatusMemo) _SwitchPos($hFile) Case $b_J11J17 $uInput = "SetSwitch 1 1 0" _UnitSend($uInput) _GUICtrlRichEdit_SetCharColor($g_hRichEdit, 16711680) _UnitRecieve($StatusMemo) _SwitchPos($hFile) Case $b_J12J17 $uInput = "SetSwitch 1 2 0" _UnitSend($uInput) _GUICtrlRichEdit_SetCharColor($g_hRichEdit, 16711680) _UnitRecieve($StatusMemo) _SwitchPos($hFile) Case $b_J13J17 $uInput = "SetSwitch 1 3 0" _UnitSend($uInput) _GUICtrlRichEdit_SetCharColor($g_hRichEdit, 16711680) _UnitRecieve($StatusMemo) _SwitchPos($hFile) Case $b_J14J17 $uInput = "SetSwitch 1 4 0" _UnitSend($uInput) _GUICtrlRichEdit_SetCharColor($g_hRichEdit, 16711680) _UnitRecieve($StatusMemo) _SwitchPos($hFile) Case $b_J15J17 $uInput = "SetSwitch 1 5 0" _UnitSend($uInput) _GUICtrlRichEdit_SetCharColor($g_hRichEdit, 16711680) _UnitRecieve($StatusMemo) _SwitchPos($hFile) Case $b_J16J17 $uInput = "SetSwitch 1 6 0" _UnitSend($uInput) _GUICtrlRichEdit_SetCharColor($g_hRichEdit, 16711680) _UnitRecieve($StatusMemo) _SwitchPos($hFile) Case $b_J16J17Amp $uInput = "SetSwitch 1 6 0; SetSwitch 4 2 0; SetSwitch 5 2 0" _UnitSend($uInput) _GUICtrlRichEdit_SetCharColor($g_hRichEdit, 16711680) _UnitRecieve($StatusMemo) _SwitchPos($hFile) ; ### 4.4.3 ############################################################################### Case $b_RX1 $uInput = "SetSwitch 6 1 1; SetSwitch 3 1 1; SetAttenuator 2 0" _UnitSend($uInput) _GUICtrlRichEdit_SetCharColor($g_hRichEdit, 16711680) _UnitRecieve($StatusMemo) _SwitchPos($hFile) Case $b_J10J4 $uInput = "SetSwitch 3 2 1; SetSwitch 2 1 1" _UnitSend($uInput) _GUICtrlRichEdit_SetCharColor($g_hRichEdit, 16711680) _UnitRecieve($StatusMemo) _SwitchPos($hFile) Case $b_J10J5 $uInput = "SetSwitch 2 2 1" _UnitSend($uInput) _GUICtrlRichEdit_SetCharColor($g_hRichEdit, 16711680) _UnitRecieve($StatusMemo) _SwitchPos($hFile) Case $b_J10J6 $uInput = "SetSwitch 2 3 1" _UnitSend($uInput) _GUICtrlRichEdit_SetCharColor($g_hRichEdit, 16711680) _UnitRecieve($StatusMemo) _SwitchPos($hFile) Case $b_J10J7 $uInput = "SetSwitch 2 4 1" _UnitSend($uInput) _GUICtrlRichEdit_SetCharColor($g_hRichEdit, 16711680) _UnitRecieve($StatusMemo) _SwitchPos($hFile) Case $b_J10J8 $uInput = "SetSwitch 2 5 1" _UnitSend($uInput) _GUICtrlRichEdit_SetCharColor($g_hRichEdit, 16711680) _UnitRecieve($StatusMemo) _SwitchPos($hFile) Case $b_J10J9 $uInput = "SetSwitch 2 6 1" _UnitSend($uInput) _GUICtrlRichEdit_SetCharColor($g_hRichEdit, 16711680) _UnitRecieve($StatusMemo) _SwitchPos($hFile) ; ### 4.4.4 ############################################################################### Case $b_J3J4 $uInput = "SetSwitch 3 1 1" _UnitSend($uInput) _GUICtrlRichEdit_SetCharColor($g_hRichEdit, 16711680) _UnitRecieve($StatusMemo) _SwitchPos($hFile) Case $b_J3TERM $uInput = "SetSwitch 3 2 1" _UnitSend($uInput) _GUICtrlRichEdit_SetCharColor($g_hRichEdit, 16711680) _UnitRecieve($StatusMemo) _SwitchPos($hFile) Case $b_J3J18 $uInput = "SetSwitch 3 2 1" _UnitSend($uInput) _GUICtrlRichEdit_SetCharColor($g_hRichEdit, 16711680) _UnitRecieve($StatusMemo) _SwitchPos($hFile) Case $b_J3J19 $uInput = "SetSwitch 3 2 1" _UnitSend($uInput) _GUICtrlRichEdit_SetCharColor($g_hRichEdit, 16711680) _UnitRecieve($StatusMemo) _SwitchPos($hFile) Case $b_J3J20 $uInput = "SetSwitch 3 2 1" _UnitSend($uInput) _GUICtrlRichEdit_SetCharColor($g_hRichEdit, 16711680) _UnitRecieve($StatusMemo) _SwitchPos($hFile) ; ### 4.4.5 ############################################################################### Case $b_SetSwitch1 $uInput = "SetSwitch 1 1 0; SetSwitch 4 1 0; SetSwitch 5 1 0; SetSwitch 6 1 1; SetSwitch 2 6 1; SetAttenuator 1 0; SetAttenuator 2 0" _UnitSend($uInput) _GUICtrlRichEdit_SetCharColor($g_hRichEdit, 16711680) _UnitRecieve($StatusMemo) _SwitchPos($hFile) ; ### 4.4.6 ############################################################################### Case $b_SetSwitch2 $uInput = "RFSW ALL 1; RFSW 6 2; ATTN 1 0" _UnitSend($uInput) _GUICtrlRichEdit_SetCharColor($g_hRichEdit, 16711680) _UnitRecieve($StatusMemo) _SwitchPos($hFile) Case $b_PM1 $uInput = "QueryPowerMeter 1" _UnitSend($uInput) _GUICtrlRichEdit_SetCharColor($g_hRichEdit, 16711680) _UnitRecieve($StatusMemo) Case $b_PM2 $uInput = "QueryPowerMeter 2" _UnitSend($uInput) _GUICtrlRichEdit_SetCharColor($g_hRichEdit, 16711680) _UnitRecieve($StatusMemo) Case $b_PM1OffSet $PM1OS = GUICtrlRead($i_PM1OffSet) $uInput = "PWRMTR OFFSET 1 " & $PM1OS _UnitSend($uInput) _GUICtrlRichEdit_SetCharColor($g_hRichEdit, 16711680) _UnitRecieve($StatusMemo) Case $b_PM2OffSet $PM2OS = GUICtrlRead($i_PM2OffSet) $uInput = "PWRMTR OFFSET 2 " & $PM2OS _UnitSend($uInput) _GUICtrlRichEdit_SetCharColor($g_hRichEdit, 16711680) _UnitRecieve($StatusMemo) ; ### 4.4.7 ############################################################################### Case $b_AttnZero $uInput = "SetSwitch 1 6 0; SetAttenuator 1 0; SetAttenuator 2 0" _UnitSend($uInput) _GUICtrlRichEdit_SetCharColor($g_hRichEdit, 16711680) _UnitRecieve($StatusMemo) _SwitchPos($hFile) ; ### 4.4.9 ############################################################################### Case $b_NFT1 $uInput = "SetSwitch 1 6 0; SetSwitch 4 2 0; SetSwitch 5 2 0; SetAttenuator 1 0" _UnitSend($uInput) _GUICtrlRichEdit_SetCharColor($g_hRichEdit, 16711680) _UnitRecieve($StatusMemo) _SwitchPos($hFile) Case $b_NFT2 $uInput = "SetSwitch 3 2 0" _UnitSend($uInput) _GUICtrlRichEdit_SetCharColor($g_hRichEdit, 16711680) _UnitRecieve($StatusMemo) _SwitchPos($hFile) Case $b_NFT3 $uInput = "SetSwitch 6 1 1; SetSwitch 2 6 1; SetAttenuator 2 0" _UnitSend($uInput) _GUICtrlRichEdit_SetCharColor($g_hRichEdit, 16711680) _UnitRecieve($StatusMemo) _SwitchPos($hFile) Case $b_Manual $uInput = GUICtrlRead($i_Manual) _UnitSend($uInput) _GUICtrlRichEdit_SetCharColor($g_hRichEdit, 16711680) _UnitRecieve($StatusMemo) _SwitchPos($hFile) GUICtrlSetData($i_Manual, "", "") EndSwitch WEnd This is the Functions that contain the error.... ; ======================================================================================================== #Region Main Includes ------------------------------------------------------------------------------------ ; ======================================================================================================== #include-once #include <Array.au3> #include <ColorConstants.au3> #include <CommInterface.au3> #include <File.au3> #include <GuiRichEdit.au3> ; ======================================================================================================== #EndRegion Main Includes ------------------------------------------------------------------------------------ ; ======================================================================================================== ; ======================================================================================================== #Region Main Variables ----------------------------------------------------------------------------------- ; ======================================================================================================== Global $i_CommPort, $SoundFile, $g_hRichEdit, $Edit1, $hFile Global $abS1, $abS2, $abS3, $abS4, $abS5, $abS6, $ii, $jj Global $i_Attn1, $i_Attn2 Local $b_Holder1, $b_Holder2, $b_Holder3, $b_Holder4, $b_Holder5, $b_Holder6 ; ======================================================================================================== #EndRegion Main Variables ----------------------------------------------------------------------------------- ; ======================================================================================================== ; #FUNCTION# ============================================================================================== ; Name ..........: _ConnectSet ; ========================================================================================================= Func _ConnectSet($i_CommPort) Global $uPort = GUICtrlRead($i_CommPort) If $uPort = "" Then SoundPlay($SoundFile) ; Error Alert _GUICtrlRichEdit_SetCharColor($g_hRichEdit, 255) _GUICtrlRichEdit_AppendText($g_hRichEdit, "Please Enter a ComPort." & @CRLF) _GUICtrlRichEdit_AppendText($g_hRichEdit, "---------------------------------------" & @CRLF) $ClickConnect = 0 ; Connection Flag - no connection Return EndIf Local Const $iPort = "" & $uPort & "" Local Const $iBaud = "115000" Local Const $iParity = "0" Local Const $iByteSize = "8" Local Const $iStopBits = "1" $ClickConnect = 1 ; Connection Flag - connection established Global $hFile = _CommAPI_OpenCOMPort($iPort, $iBaud, $iParity, $iByteSize, $iStopBits) ; Ref commAPI _CommAPI_ClearCommError($hFile) If @error Then Exit SetError(@error, @ScriptLineNumber) _CommAPI_PurgeComm($hFile) If @error Then Exit SetError(@error, @ScriptLineNumber) _CommAPI_TransmitString($hFile, "*IDN?" & @CR) ; _CommAPI_TransmitData(Const $hFile, Const $sData) Local $sResult = _CommAPI_ReceiveString($hFile, 1000) ;_CommAPI_ReceiveString(Const $hFile[, $iTimeout = 1[, $iMaxLength = 0[, $sSeparator = ""]]]) If Not $sResult = "" Then $ClickConnect = "1" Else $ClickConnect = "0" EndIf _CommAPI_ClearCommError($hFile) If @error Then Return SetError(@error, @ScriptLineNumber) _CommAPI_PurgeComm($hFile) If @error Then Return SetError(@error, @ScriptLineNumber) _GUICtrlRichEdit_SetCharColor($g_hRichEdit, 16711680) _GUICtrlRichEdit_AppendText($g_hRichEdit, $sResult) _GUICtrlRichEdit_AppendText($g_hRichEdit, "---------------------------------------" & @CRLF) EndFunc ;==>_ConnectSet ; #FUNCTION# ============================================================================================== ; Name ..........: _DisplayPorts ; ========================================================================================================= Func _DisplayPorts($g_hRichEdit) Local $sCommPorts = _CommAPI_GetCOMPorts() ; ref https://www.autoitscript.com/wiki/CommAPI_Examples Local $uCommPorts = "COM Ports:" & @LF & $sCommPorts & @LF _GUICtrlRichEdit_AppendText($g_hRichEdit, "---------------------------------------" & @CRLF & @CRLF) _GUICtrlRichEdit_SetCharColor($g_hRichEdit, 16711680) _GUICtrlRichEdit_AppendText($g_hRichEdit, $uCommPorts) _GUICtrlRichEdit_AppendText($g_hRichEdit, "---------------------------------------" & @CRLF) _GUICtrlRichEdit_SetCharColor($g_hRichEdit, 16711680) EndFunc ;==>_DisplayPorts ; #FUNCTION# ============================================================================================== ; Name ..........: _UnitSend ; ========================================================================================================= Func _UnitSend($uInput) _CommAPI_ClearCommError($hFile) If @error Then Return SetError(@error, @ScriptLineNumber) _CommAPI_PurgeComm($hFile) If @error Then Return SetError(@error, @ScriptLineNumber) _CommAPI_TransmitString($hFile, $uInput & @CR) ; _CommAPI_TransmitData(Const $hFile, Const $sData) If @error Then Return SetError(@error, @ScriptLineNumber) Sleep(500) GUICtrlSetData($uInput, "") EndFunc ;==>_UnitSend ; #FUNCTION# ============================================================================================== ; Name ..........: _UnitRecieve ; ========================================================================================================= Func _UnitRecieve($StatusMemo) Local $sResult = _CommAPI_ReceiveString($hFile, 5000) ;_CommAPI_ReceiveString(Const $hFile[, $iTimeout = 1[, $iMaxLength = 0[, $sSeparator = ""]]]) *1000 If @error Then Return SetError(@error, @ScriptLineNumber, $sResult) Sleep(500) If $StatusMemo = "" Then _GUICtrlRichEdit_AppendText($g_hRichEdit, $sResult & @CRLF) _GUICtrlRichEdit_AppendText($g_hRichEdit, "---------------------------------------" & @CRLF) Else _GUICtrlRichEdit_AppendText($g_hRichEdit, $StatusMemo & @CRLF) _GUICtrlRichEdit_AppendText($g_hRichEdit, $sResult & @CRLF) _GUICtrlRichEdit_AppendText($g_hRichEdit, "---------------------------------------" & @CRLF) EndIf Return $sResult EndFunc ;==>_UnitRecieve ; #FUNCTION# ============================================================================================== ; Name ..........: _OutFile ; ========================================================================================================= Func _OutFile() $MyDocsFolder = "::{450D8FBA-AD25-11D0-98A8-0800361B1103}" ;Declares The variable $MyDocsFolder $savewhere = FileSaveDialog("Save to...", $MyDocsFolder, "Rich Text Files (*rtf)", 2, "10204 Command Test sn") ;opens a dialog where you want to save your file If StringInStr($savewhere, ".rtf") Then ;checks if the file extention is already there _FileCreate($savewhere) ;creates the file in directory selected (I'm not sure if it's necessary or not) $savetofile = _GUICtrlRichEdit_StreamToFile($g_hRichEdit, $savewhere) Else ;else adds file extention $savewhere = $savewhere & ".rtf" _FileCreate($savewhere) ;creates the file in directory selected (I'm not sure if it's necessary or not) $savetofile = _GUICtrlRichEdit_StreamToFile($g_hRichEdit, $savewhere) EndIf ;Ends the if EndFunc ;==>_OutFile ; #FUNCTION# ============================================================================================== ; Name ..........: _SwitchPos($hFile) ; ========================================================================================================= Func _SwitchPos($hFile) _CommAPI_ClearCommError($hFile) If @error Then Return SetError(@error, @ScriptLineNumber) _CommAPI_PurgeComm($hFile) If @error Then Return SetError(@error, @ScriptLineNumber) _CommAPI_TransmitString($hFile, "SHOW STAT" & @CR) ; _CommAPI_TransmitData(Const $hFile, Const $sData) - Works for show set and show stat If @error Then Exit SetError(@error, @ScriptLineNumber) Sleep(500) $sResult = _CommAPI_ReceiveString($hFile, 1000) ;_CommAPI_ReceiveString(Const $hFile[, $iTimeout = 1[, $iMaxLength = 0[, $sSeparator = ""]]]) If @error Then Exit SetError(@error, @ScriptLineNumber, $sResult) $srString = StringReplace($sResult, @CRLF & @CRLF, @CRLF) $srString = StringReplace($srString, "SHOW STAT", "") $srString = StringReplace($srString, "ATTN", "") $srString = StringReplace($srString, ">", "") $srString = StringReplace($srString, @CRLF, "|") $srString = StringStripWS($srString, $STR_STRIPLEADING + $STR_STRIPTRAILING + $STR_STRIPSPACES) $aSTATtemp = StringSplit($srString, "|", 2) Local $cols = 3 Local $arr[1][$cols] Local $cell For $ii = 0 To UBound($aSTATtemp, 1) - 1 $cell = StringSplit($aSTATtemp[$ii], " ", 2) ReDim $arr[UBound($arr, 1) + 1][$cols] For $jj = 0 To UBound($cell, 1) - 1 $arr[$ii][$jj] = $cell[$jj] Next Next _ArrayDelete($arr, UBound($arr, 1) - 1) _ArrayColDelete($arr, 0) $aSTAT = $arr Local $num = 0 $ATTN1 = $aSTAT[1][1] GUICtrlSetData($i_Attn1,$ATTN1) $ATTN2 = $aSTAT[2][1] GUICtrlSetData($i_Attn2,$ATTN2) $SW1 = $aSTAT[3][1] $SW2 = $aSTAT[4][1] $SW3 = $aSTAT[5][1] $SW4 = $aSTAT[6][1] $SW5 = $aSTAT[7][1] $SW6 = $aSTAT[8][1] $SW7 = $aSTAT[9][1] $SW8 = $aSTAT[10][1] $SW9 = $aSTAT[11][1] For $i = 0 To UBound($abS1) - 1 GUICtrlSetBkColor($abS1[$i], 0xFFFBF0) Next GUICtrlSetBkColor($abS1[$SW1], $COLOR_RED) For $i = 0 To UBound($abS2) - 1 GUICtrlSetBkColor($abS2[$i], 0xFFFBF0) Next GUICtrlSetBkColor($abS2[$SW2], $COLOR_RED) For $i = 0 To UBound($abS3) - 1 GUICtrlSetBkColor($abS3[$i], 0xFFFBF0) Next GUICtrlSetBkColor($abS3[$SW3], $COLOR_RED) For $i = 0 To UBound($abS4) - 1 GUICtrlSetBkColor($abS4[$i], 0xFFFBF0) Next GUICtrlSetBkColor($abS4[$SW4], $COLOR_RED) For $i = 0 To UBound($abS5) - 1 GUICtrlSetBkColor($abS5[$i], 0xFFFBF0) Next GUICtrlSetBkColor($abS5[$SW5], $COLOR_RED) For $i = 0 To UBound($abS6) - 1 GUICtrlSetBkColor($abS6[$i], 0xFFFBF0) Next GUICtrlSetBkColor($abS6[$SW6], $COLOR_RED) EndFunc ;==>_SwitchPos
  13. Here is how you get the date and time out the web site : #include <Constants.au3> Local $String = BinaryToString(InetRead ("http://worldtimeapi.org/api/timezone/America/Toronto",1)) Local $Time = StringRegExp ($String,'datetime: (.+?)T(\d+:\d+:\d+)', $STR_REGEXPARRAYMATCH) MsgBox ($MB_SYSTEMMODAL,"",$Time[0] & " " & $Time[1]) Now I will let you convert those to the right format. Not a big deal...
  14. HotKeySet("{1}", "Source1") Func MsClick($tittle, $text, $controlid, $clickType, $clicks = 1, $x = 1, $y = 1) $coord = UiRatio($x, $y) If IsArray($coord) Then ControlClick($tittle, $text, $controlid, $clickType, $clicks, $coord[0], $coord[1]) Else MsgBox(1, "Error", "UIRatio() didn't return an Array") EndIf EndFunc ;==>MsClick Func UiRatio($_x, $_y) Dim $return[2] $size = WinGetClientSize("STUDIO | Producer - Google Chrome") ; Must set so we can get windows' size If @error Then ; If @error >= 1 then return Return Else $return[0] = $size[0] * ($_x / $size[0]) $return[1] = $size[1] * ($_y / $size[1]) EndIf Return $return EndFunc ;==>UiRatio While 1 Sleep(100) WEnd Func Source1() Opt("MouseCoordMode", 2) MsClick("STUDIO | Producer - Google Chrome", "", "", "left", 1, 1283, 628) ;MsClick("STUDIO | Producer - Google Chrome", "", "", "left", 1, 964, 312) EndFunc When i'm inserting the code on the forum the formating doesn't look good, but if you paste it into Scite It should be fine Edit : or you can be a better scripter than I am and follow BrewManNH recommandations and use SetError() to set your own error flag that you'll check after UiRatio() Returns
  15. The _WinAPI_Mouse_Event() is something that should be used for this Didn't try anything to workout the $x $y for accuracy The *65535 is used a hack taken from here #include <WinAPISys.au3> #include <WinAPIRes.au3> $hWnd = WinActivate("[CLASS:MSPaintApp]") WinMove($hWnd, "", 0, 0, 600, 600) $aPos = WinGetPos($hWnd) $aCPos = ControlGetPos($hWnd, "", "[CLASS:MSPaintView]") $aPos[1] += $aCPos[1] _MouseDraw($aPos[0], $aPos[1]) Func _MouseDraw($x1, $y1) $x = $x1 * 65535 / @DesktopWidth + 2500 $y = $y1 * 65535 / @DesktopHeight + 1500 _WinAPI_Mouse_Event(BitOR($MOUSEEVENTF_ABSOLUTE, $MOUSEEVENTF_MOVE), $x, $y) For $j = 0 To 1 For $i = 1 To 20 If $j Then _WinAPI_Mouse_Event(BitOR($MOUSEEVENTF_ABSOLUTE, $MOUSEEVENTF_MOVE), $x, $y) _WinAPI_Mouse_Event(BitOR($MOUSEEVENTF_ABSOLUTE, $MOUSEEVENTF_LEFTDOWN), $x, $y) _WinAPI_Mouse_Event(BitOR($MOUSEEVENTF_ABSOLUTE, $MOUSEEVENTF_MOVE), $x + 12000, $y + ($i * 1100)) _WinAPI_Mouse_Event(BitOR($MOUSEEVENTF_ABSOLUTE, $MOUSEEVENTF_LEFTUP), $x, $y) Next Next _WinAPI_Mouse_Event(BitOR($MOUSEEVENTF_ABSOLUTE, $MOUSEEVENTF_MOVE), $x, $y) EndFunc ;==>_MouseDraw Deye
  16. Post your code, so we can help you By the way, welcome to the AutoIt forums
  17. I want to get the position of a text on the window based on which certain actions needs to be taken. I tried WinGetText() but it is not serving the purpose. Can someone help me out here?
  18. @amosrinat, as what Melba said, you can decide which is which. You can disable the OnEvent mode on [param] 0 "AutoItSetOption('GUIOnEventMode', 0)" or you may do a Func () code same as below to make you script working. Func Button1() $csv=FileOpenDialog("Open", "C:\" ,"csv files (*.csv)") GUICtrlSetData($Input1,$csv) EndFunc KS15
  19. Every function should return either a valid return or sets the @error.
  20. @BrewManNH, Thank you sir. I am obvisly super new to this. Can you give me any tips on adding in error checking? I am looking at the documentation now. Again, thank you.
  21. In this example:- The function IsArray1SomeInArray2() answers your first question of post #1. The function IsArray1InArray2() answers your second question of post #1. An optional case sensitivity parameter is added to answer one of my questions. #include <Array.au3> Local $sAlphabet = "ABCDEFGHIJKLMOPQRSTUVWXYZ" $aAlphabet = StringSplit($sAlphabet, "", 2) Local $sWord = "hello" ; "HELLO" ; "Hello" ; $aWord = StringSplit($sWord, "", 2) MsgBox(0, "IsArray1SomeInArray2()", "One or more of the elements of Array1" & (IsArray1SomeInArray2($aWord, $aAlphabet, 0) ? " are in " : " are NOT in ") & "Array2") MsgBox(0, "IsArray1InArray2()", "All the elements of Array1" & (IsArray1InArray2($aWord, $aAlphabet, 0) ? " are in " : " are NOT in ") & "Array2") ; Checks if some of the values from array1 ($word) are also in the array2 ($alphabet); also, ; Checks if some of the values from array1 ($alphabet) are also in the array2 ($word). Func IsArray1SomeInArray2($Array1, $Array2, $iCase = 0) ; $iCase = 0 (case insensitive, "h" = "H") $Array1 = _ArrayUnique($Array1, 0, 0, $iCase, $ARRAYUNIQUE_NOCOUNT) $Array2 = _ArrayUnique($Array2, 0, 0, $iCase, $ARRAYUNIQUE_NOCOUNT) Return UBound(StringRegExp(_ArrayToString($Array2), ($iCase ? "" : "(?i)") & _ArrayToString($Array1), 3)) > 0 EndFunc ;==>IsArray1SomeInArray2 ; Checks if all of the values from array1 ($word) are also in the array2 ($alphabet) Func IsArray1InArray2($Array1, $Array2, $iCase = 0) $Array1 = _ArrayUnique($Array1, 0, 0, $iCase, $ARRAYUNIQUE_NOCOUNT) $a = StringRegExp(_ArrayToString($Array2), ($iCase ? "" : "(?i)") & _ArrayToString($Array1), 3) Return UBound($Array1) = UBound($a) EndFunc ;==>IsArray1InArray2 If you do not understand something in either function, I suggest you use as many ConsoleWrite( [Insert variable here] & @CRLF)'s as needed, together with AutoIt's help file. Just as I have done, do, and will do. In SciTE, I use "cw ", that is, "cw" followed by a space - a shortcut.
  22. Do some error checking. Check to see if there's an error returned from WinGetClientSize before trying to return the array that isn't there. You should do some error checking in MsClick as well in case the UIRatio function fails to find the window as well.
  23. You sir are correct on that. I tested out the code using notepad instead and it worked. I then switched back over to Chrome and now it clicks the button fine but it does not once I resize the window. Thoughts? HotKeySet("{1}", "Source1") Func MsClick($tittle, $text, $controlid, $clickType, $clicks = 1, $x = 1, $y = 1) $coord = UiRatio($x, $y) ControlClick($tittle, $text, $controlid, $clickType, $clicks, $coord[0], $coord[1]) EndFunc ;==>MsClick Func UiRatio($_x, $_y) Dim $return[2] $size = WinGetClientSize("STUDIO | Producer - Google Chrome") ; Must set so we can get windows' size $return[0] = $size[0] * ($_x / $size[0]) $return[1] = $size[1] * ($_y / $size[1]) Return $return EndFunc ;==>UiRatio While 1 Sleep(100) WEnd Func Source1() Opt("MouseCoordMode", 2) MsClick("STUDIO | Producer - Google Chrome", "", "", "left", 1, 1283, 628) ;MsClick("STUDIO | Producer - Google Chrome", "", "", "left", 1, 964, 312) EndFunc
  24. It seems like WinGetClientSize can't find the window, probably because you're trying to look for the class of the window and its title at the same time. Pick one.
  25. Yesterday
  26. Hello, I am looking for a small bit of help. I'm trying to get my script working in a Chrome window. If I remove the resize code, my script will work fine and click the button that I want it to. What I am trying to do is get it work if the window changes sizes or if the computer has a different resolution then what I created this on. There probably is an easier way to do this but this is what I found by searching through the forums. When I run the code below and use my hotkey, I get this error. Thanks in advance!!!! "C:\Users\BaDvs3viL\Documents\asdasd.au3" (11) : ==> Subscript used on non-accessible variable.: $return[0] = $size[1] * ($_x / $size[0]) $return[0] = $size^ ERROR Here is my script. HotKeySet("{1}", "Source1") Func MsClick($tittle, $text, $controlid, $clickType, $clicks = 1, $x = 1, $y = 1)     $coord = UiRatio($x, $y)     ControlClick($tittle, $text, $controlid, $clickType, $clicks, $coord[0], $coord[1]) EndFunc   ;==>MsClick Func UiRatio($_x, $_y)     Dim $return[2]     $size = WinGetClientSize("[CLASS:STUDIO | Producer - Google Chrome]") ; Must set so we can get windows' size     $return[0] = $size[1] * ($_x / $size[0])     $return[1] = $size[1] * ($_y / $size[1])     Return $return EndFunc   ;==>UiRatio While 1 Sleep(100) WEnd Func Source1() Opt("MouseCoordMode", 2) MsClick("STUDIO | Producer - Google Chrome", "", "", "left", 1, 1282, 627) MsClick("STUDIO | Producer - Google Chrome", "", "", "left", 1, 964, 312) EndFunc
  1. Load more activity
×
×
  • Create New...