Jump to content

All Activity

This stream auto-updates     

  1. Past hour
  2. Indeed . Don't know if it's for laziness or for conenience, but I prefer don't reinvent the wheel when I can
  3. I've got it partially figured out using #include <Clipboard.au3> While True $Clip = _ClipBoard_GetDataEx($CF_UNICODETEXT) _ClipBoard_SetDataEx($Clip, $CF_UNICODETEXT) Sleep(100) WEnd But still lose some data, specifically cell sizing. Edit: Disregard, sleep(100) seems to have screwed it up somehow when I was testing before. Works fine.
  4. in the array returned by this function you will have: in column 1, elements belonging only to array 1; in column 2, elements belonging only to array 2; in column 3, elements belonging to both arrays p.s. it's a case sensitive function #include <Array.au3> Local $sAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" $aAlphabet = StringSplit($sAlphabet, "", 2) Local $sWord = "HELLO" ; "hello" ; "Hello" ; $aWord = StringSplit($sWord, "", 2) _ArrayDisplay(_Separate($aAlphabet, $aWord)) Func _Separate(ByRef $in0, ByRef $in1) $in0 = _ArrayUnique($in0, 0, Default, Default, 0) $in1 = _ArrayUnique($in1, 0, Default, Default, 0) Local $z[2] = [UBound($in0), UBound($in1)], $low = 1 * ($z[0] > $z[1]), $aTemp[$z[Not $low]][3], $aOut = $aTemp, $aNdx[3] For $i = 0 To $z[Not $low] - 1 If $i < $z[0] Then $aTemp[$i][0] = $in0[$i] If $i < $z[1] Then $aTemp[$i][1] = $in1[$i] Next For $i = 0 To $z[$low] - 1 $x = _ArrayFindAll($aTemp, $aTemp[$i][$low], 0, 0, 1, 0, Not $low) If Not @error Then ; both For $j = 0 To UBound($x) - 1 $aTemp[$x[$j]][2] = 1 Next $aOut[$aNdx[2]][2] = $aTemp[$i][$low] $aNdx[2] += 1 Else ; only in $low $aOut[$aNdx[$low]][$low] = $aTemp[$i][$low] $aNdx[$low] += 1 EndIf Next For $i = 0 To $z[Not $low] - 1 If $aTemp[$i][2] <> 1 Then $aOut[$aNdx[Not $low]][Not $low] = $aTemp[$i][Not $low] $aNdx[Not $low] += 1 EndIf Next ReDim $aOut[_ArrayMax($aNdx)][3] Return $aOut EndFunc ;==>_Separate reference: https://www.autoitscript.com/forum/topic/164728-compare-2-arrays-with-3-arrays-as-a-result/?do=findComment&comment=1202060
  5. That still removes formatting. User 5 Data 1 4/18 User 2 Data 2 4/15 user 3 Data 3 4/18 User 4 Data 4 4/19 Data 5 4/19 instead of User 5 Data 1 4/18 User 2 Data 2 4/15 user 3 Data 3 4/18 User 4 Data 4 4/19 Data 5 4/19
  6. @rcmaehl You could do something like this: #include <MsgBoxConstants.au3> #include <StringConstants.au3> Global $varClipContent = ClipGet() MsgBox($MB_ICONINFORMATION, "Before:", $varClipContent & @CRLF & "User 1 will become now User 5") $varClipContent = StringRegExpReplace($varClipContent, 'User 1', 'User 5') MsgBox($MB_ICONINFORMATION, "After:", $varClipContent & @CRLF & "User 1 is now User 5") ClipPut($varClipContent)
  7. Hi all, I'm having an issue in which if the clipboard contains special formatting it does not pass to ClipPut. I've included a sample script and data below. While True $Clip = ClipGet() ClipPut($Clip) Sleep(100) WEnd Input: User 1 Data 1 4/18 User 2 Data 2 4/15 user 3 Data 3 4/18 User 4 Data 4 4/19 Data 5 4/19 Output: User 1 Data 1 4/18 User 2 Data 2 4/15 User 3 Data 3 4/18 User 4 Data 4 4/19 Data 5 4/19 Is there any way to modify the clipboard data while keeping special formatting? Thanks!
  8. Today
  9. This behavior might not be 100% kosher #include<array.au3> local $aLphabet[8] = ['A','B','D','F','G','H','I' ,'O'] local $aWord[5] = ['H','E','L','L','O'] _ArrayDisplay(StringRegExp(_ArrayToString($aWord , ',') , _ArrayToString($aLphabet , '|') , 3) , 'Matches')
  10. Hopefully the text you want to look for is in a specific control, as that would be rather simple using the array returned from ControlGetPos() If the text you are looking for is only part of a big edit box, or blob of text then as Nine said, you will need OCR. I posted something I did for this here: google tesseract ocr
  11. 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!!
  12. 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).
  13. 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)
  14. 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
  15. Thanks so much!!! I was working forever trying to get this done.
  16. Seems your string split returns more than the second dimension of you array. Add in error handling.
  17. $Form1 = GUICreate("Form1", 409, 437, -1, -1) GUISetBkColor (0xF7F3F7) $TreeView1 = GUICtrlCreateTreeView(0, 0, 289, 433) GUICtrlSetBkColor (-1, 0xF7F3F7)
  18. 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")
  19. 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.
  20. 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
  21. 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...
  22. 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
  23. 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
  24. Post your code, so we can help you By the way, welcome to the AutoIt forums
  1. Load more activity
×
×
  • Create New...