Fractured Posted August 1, 2018 Posted August 1, 2018 Hello all. Im working on a GuI to automate some of the testing I do at work. It can open TeraTerm, use a user input comm port and enter the commands associated with the button descriptions. Problem is that there is a set of buttons labeled J0T-J8T and J0C-J8C. They need to not only check there status but change the corresponding buttons status..i.e. J0T on/J0C off...J0T off/J0C on....I have looked through the forums, and although it seems like an array is probly the best bet I have absolutely no clue on how to even try that!! So any help with the buttons would be greatly appreciated. As you will see in my script I do assign colors to the buttons, so that it is a visual to what state the button is in....The edit box is more for my debugging and playing than actual use since I dont want to have TeraTerm write console to a file then read the file back into the script. TeraTerm will already be open so no need to double the work. Lastly, and of less importance is, is there any way to shorten the script. I have a lot of "binary" type logic using if/then statements. Is this ok or will it slow the script down? Still learning the ways... Thanks! expandcollapse popup; #INDEX# ================================================================================================= ; Name ..........: 6936.au3 ; Version Date ..: 2018-07-27 ; AutoIt Version : 3.3.8.1 ; Author(s) .....: Charles Wright ; Dll(s) ........: ; Error handling : ; ========================================================================================================= ; Includes ================================================================================================ ;========================================================================================================== #include <ColorConstants.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GuiEdit.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <ComUDF.au3> ;========================================================================================================== ; Global Variables ======================================================================================== ; Switch Settings ========================================================================================= ;========================================================================================================== Global $HSSLBstatus = 0 ;0 = off, 1 = on Global $A = 2 ;default = 2 / 1 = Calibration Noise Source, 2 = External Noise (J2-/J28) Global $C = 1 ;default = 1 / 1 = Calibration Source Off, 2 = Calibration Source On Global $D = 1 ;default = 1 / 1 = Amp On/In Path, 2 = Amp Off/Bypass Global $AntStat = 1 ;default = 1 / When set, S2A-S2I set to T (DF) Global $CalStat = 0 ;default = 0 / When set, S2A-S2I set to C (CAL) Global $N = 2 ;default = 2 / 1 = LF, 2 = HF1, 3 = HF2 Global $T = 1 ;default = 1 / 1 = Off, 2 = Bit On Global $HLBs = 0 ; Command Variables ======================================================================================= ; Random Bits ============================================================================================= ;========================================================================================================== Global $Command, $Status, $Command, $HSSLoopBk Global $HLB = "Off" Global $sMsg = "" Global $cHLBoff = "HSS LOOPBK 0{ENTER}" Global $cHLBon = "HSS LOOPBK 1{ENTER}" Global $cA ="A{ENTER}" ;========================================================================================================== Opt("MustDeclareVars", 1) main() ; Main ==================================================================================================== ;========================================================================================================== Func main() Global $g_Core = GUICreate("6936 Pre-Test", 627, 602, 234, 133) GUISetFont(9, 400, 0, "MS Sans Serif") GUISetBkColor(0xB9D1EA) Global $CoreHandle = WinGetHandle($g_Core) Global $bSTTP = GUICtrlCreateButton("Connect", 24, 48, 75, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) Global $uComm = GUICtrlCreateInput("", 104, 48, 49, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER)) GUICtrlSetTip(-1, "Comm Port") GUICtrlCreateLabel("COMM Port", 104, 24, 59, 17) ;-- Local $bS = GUICtrlCreateButton("Status (S)", 24, 88, 75, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) ;-- Local $bR = GUICtrlCreateButton("RESET (R)", 104, 88, 75, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) ;-- GUICtrlCreateLabel("HSS LOOPBK", 64, 128, 72, 17) GUICtrlSetTip(-1, "Default = off") Local $bHSSLoopBk = GUICtrlCreateButton("" & $HLB & "", 64, 152, 75, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) ;-- GUICtrlCreateLabel("Test Selection (A#)", 56, 192, 95, 17) GUICtrlSetTip(-1, "Default = 2") Local $bA = GUICtrlCreateButton("" & $A & "", 64, 208, 75, 25) GUICtrlSetBkColor(-1, 0xFF0000) ;-- GUICtrlCreateLabel("Calibration Control (C#)", 48, 248, 112, 17) GUICtrlSetTip(-1, "Default = 1") Local $bC = GUICtrlCreateButton("" & $C & "", 64, 264, 75, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) ;-- GUICtrlCreateLabel("Amp Control (D#)", 56, 304, 85, 17) GUICtrlSetTip(-1, "Default = 1") Local $bD = GUICtrlCreateButton("" & $D & "", 64, 328, 75, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) ;-- Local $bANT = GUICtrlCreateButton("SOT/Cal (ANT)", 56, 368, 91, 25) GUICtrlSetTip(-1, "Default = ANT") GUICtrlSetBkColor(-1, 0xFF0000) ;-- Local $bCAL = GUICtrlCreateButton("SOT/Cal (CAL)", 56, 400, 91, 25) GUICtrlSetTip(-1, "Default = ANT") GUICtrlSetBkColor(-1, $COLOR_WHITE) ;-- GUICtrlCreateLabel("Antenna Band Select (N#)", 40, 440, 129, 17) GUICtrlSetTip(-1, "Default = 2") Local $bN1 = GUICtrlCreateButton("1", 40, 464, 35, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) Local $bN2 = GUICtrlCreateButton("2", 80, 464, 35, 25) GUICtrlSetBkColor(-1, 0xFF0000) Local $bN3 = GUICtrlCreateButton("3", 120, 464, 35, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) ;-- GUICtrlCreateLabel("Antenna Bit (T#)", 56, 504, 82, 17) GUICtrlSetTip(-1, "Default = 1") Local $bT = GUICtrlCreateButton("" & $T & "", 48, 528, 99, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) ;-- Local $SStatus = GUICtrlCreateButton("SHOW STAT", 56, 560, 75, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) ;-- GUICtrlCreateLabel("SOT/Cal (J#)", 360, 32, 81, 20) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") Local $bJ0T = GUICtrlCreateButton("J0T", 224, 56, 35, 25) GUICtrlSetBkColor(-1, $COLOR_RED) Local $bJ1T = GUICtrlCreateButton("J1T", 264, 56, 35, 25) GUICtrlSetBkColor(-1, $COLOR_RED) Local $bJ2T = GUICtrlCreateButton("J2T", 304, 56, 35, 25) GUICtrlSetBkColor(-1, $COLOR_RED) Local $bJ3T = GUICtrlCreateButton("J3T", 344, 56, 35, 25) GUICtrlSetBkColor(-1, $COLOR_RED) Local $bJ4T = GUICtrlCreateButton("J4T", 384, 56, 35, 25) GUICtrlSetBkColor(-1, $COLOR_RED) Local $bJ5T = GUICtrlCreateButton("J5T", 424, 56, 35, 25) GUICtrlSetBkColor(-1, $COLOR_RED) Local $bJ6T = GUICtrlCreateButton("J6T", 464, 56, 35, 25) GUICtrlSetBkColor(-1, $COLOR_RED) Local $bJ7T = GUICtrlCreateButton("J7T", 504, 56, 35, 25) GUICtrlSetBkColor(-1, $COLOR_RED) Local $bJ8T = GUICtrlCreateButton("J8T", 544, 56, 35, 25) GUICtrlSetBkColor(-1, $COLOR_RED) ;-- Local $bJ0C = GUICtrlCreateButton("J0C", 224, 88, 35, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) Local $bJ1C = GUICtrlCreateButton("J1C", 264, 88, 35, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) Local $bJ2C = GUICtrlCreateButton("J2C", 304, 88, 35, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) Local $bJ3C = GUICtrlCreateButton("J3C", 344, 88, 35, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) Local $bJ4C = GUICtrlCreateButton("J4C", 384, 88, 35, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) Local $bJ5C = GUICtrlCreateButton("J5C", 424, 88, 35, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) Local $bJ6C = GUICtrlCreateButton("J6C", 464, 88, 35, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) Local $bJ7C = GUICtrlCreateButton("J7C", 504, 88, 35, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) Local $bJ8C = GUICtrlCreateButton("J8C", 544, 88, 35, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) ;-- Local $bHSG0 = GUICtrlCreateButton("HSS SEND G0", 200, 168, 99, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) Local $bHSG1 = GUICtrlCreateButton("HSS SEND G1", 304, 168, 99, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) Local $bHSG2 = GUICtrlCreateButton("HSS SEND G2", 408, 168, 99, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) Local $bHSG3 = GUICtrlCreateButton("HSS SEND G3", 512, 168, 99, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) Local $bHSG4 = GUICtrlCreateButton("HSS SEND G4", 200, 208, 99, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) Local $bHSG5 = GUICtrlCreateButton("HSS SEND G5", 304, 208, 99, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) Local $bHSG6 = GUICtrlCreateButton("HSS SEND G6", 408, 208, 99, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) Local $bHSG7 = GUICtrlCreateButton("HSS SEND G7", 512, 208, 99, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) Local $bHSG8 = GUICtrlCreateButton("HSS SEND G8", 360, 248, 99, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) ;--- Global $console = GUICtrlCreateEdit("", 216, 296, 393, 289, $WS_VSCROLL) GUICtrlSetData(-1, "") GUISetState(@SW_SHOW, $g_Core) Local $sMsg = "" While 1 Global $nMsg1 = GUIGetMsg() Switch $nMsg1 Case $GUI_EVENT_CLOSE MsgBox($MB_OK, "Window Close", "Exiting Tera Term, Exiting 6536...", 1) ;Send("{CTRLDOWN}B{CTRLUP}CONSOLE 0{CTRLDOWN}D{CTRLUP}{ENTER}") WinClose("[CLASS:VTWin32]", "") GUIDelete($CoreHandle) Exit Case $bSTTP Local $Comm = GUICtrlRead($uComm) Local $Model = "6936RFDU.INI" _MemoWrite("Starting TeraTerm on COMM " & $Comm & "." & @CRLF) ShellExecute("C:\Program Files (x86)\teraterm\ttermpro.exe", "/C=" & $Comm & " /F=" & $Model, "C:\Program Files (x86)\teraterm") Global $hWnd = WinWait("[CLASS:VTWin32]", "", 2) WinMove($hWnd, "[CLASS:VTWin32]", 1008, 4, 589, 850, 1) _MemoWrite("Opening Console Mode 2" & @CRLF) Sleep(100) ;Send("{CTRLDOWN}B{CTRLUP}CONSOLE 2{CTRLDOWN}D{CTRLUP}{ENTER}") Sleep(100) Case $bS Local $hWnd = WinWait("[CLASS:VTWin32]", "", 2) ControlFocus($hWnd, "", "") _MemoWrite("Status Command Sent" & @CRLF) ;Send("S{ENTER}") Sleep(100) Case $bR Local $hWnd = WinWait("[CLASS:VTWin32]", "", 2) ControlFocus($hWnd, "", "") _MemoWrite("Reset Command Sent and Reseting Gui" & @CRLF) ;Send("R{ENTER}") ;Reset all variables ----------------------------------------------------------------------------------------------------- Global $HSSLBstatus = 0 ;0 = off, 1 = on Global $A = 2 ;default = 2 / 1 = Calibration Noise Source, 2 = External Noise (J2-/J28) Global $C = 1 ;default = 1 / 1 = Calibration Source Off, 2 = Calibration Source On Global $D = 1 ;default = 1 / 1 = Amp On/In Path, 2 = Amp Off/Bypass Global $AntStat = 1 ;default = 1 / When set, S2A-S2I set to T (DF) Global $CalStat = 0 ;default = 0 / When set, S2A-S2I set to C (CAL) Global $N = 2 ;default = 2 / 1 = LF, 2 = HF1, 3 = HF2 Global $T = 1 ;default = 1 / 1 = Off, 2 = Bit On Global $HLBs = 0 ;-------------------------------------------------------------------------------------------------------------------------- GUIDelete($CoreHandle) main() Case $bHSSLoopBk Local $hWnd = WinWait("[CLASS:VTWin32]", "", 2) ControlFocus($hWnd, "", "") If $HLBs = 0 Then $HLB = "On" $HLBs = 1 $Command = $cHLBon ;_CommandSend() _MemoWrite("HSS LoopBk = On" & @CRLF) GUICtrlSetData($bHSSLoopBk, $HLB) GUICtrlSetBkColor($bHSSLoopBk, $COLOR_RED) Else $HLB = "Off" $HLBs = 0 $Command = $cHLBoff ;_CommandSend() _MemoWrite("HSS LoopBk = Off" & @CRLF) GUICtrlSetData($bHSSLoopBk, $HLB) GUICtrlSetBkColor($bHSSLoopBk, $COLOR_WHITE) Endif Case $bA If $A = 2 Then $A = 1 $Command = "A1{ENTER}" ;_CommandSend() GUICtrlSetData($bA, "1") GUICtrlSetStyle($bA, $GUI_SS_DEFAULT_BUTTON) Local $CommandSL = StringLeft($Command, 2) _MemoWrite("" & $CommandSL & "" & @CRLF) Else $A = 2 $Command = "A2{ENTER}" ;_CommandSend() GUICtrlSetData($bA, "2") GUICtrlSetBkColor($bA, 0xFF0000) Local $CommandSL = StringLeft($Command, 2) _MemoWrite("" & $CommandSL & "" & @CRLF) EndIf Case $bC If $C = 2 Then $C = 1 $Command = "C1{ENTER}" ;_CommandSend() GUICtrlSetData($bC, "1") GUICtrlSetStyle($bC, $GUI_SS_DEFAULT_BUTTON) Local $CommandSL = StringLeft($Command, 2) _MemoWrite("" & $CommandSL & "" & @CRLF) Else $C = 2 $Command = "C2{ENTER}" ;_CommandSend() GUICtrlSetData($bC, "2") GUICtrlSetBkColor($bC, 0xFF0000) Local $CommandSL = StringLeft($Command, 2) _MemoWrite("" & $CommandSL & "" & @CRLF) EndIf Case $bD If $D = 2 Then $D = 1 $Command = "D1{ENTER}" ;_CommandSend() GUICtrlSetData($bD, "1") GUICtrlSetStyle($bD, $GUI_SS_DEFAULT_BUTTON) Local $CommandSL = StringLeft($Command, 2) _MemoWrite("" & $CommandSL & "" & @CRLF) Else $D = 2 $Command = "D2{ENTER}" ;_CommandSend() GUICtrlSetData($bD, "2") GUICtrlSetBkColor($bD, 0xFF0000) Local $CommandSL = StringLeft($Command, 2) _MemoWrite("" & $CommandSL & "" & @CRLF) EndIf Case $bANT ; Set to ANT (T) If $AntStat = 0 Then $AntStat = 1 $Command = "ANT{ENTER}" ;_CommandSend() GUICtrlSetBkColor($bANT, $COLOR_RED) Local $CommandSL = StringLeft($Command, 3) _MemoWrite("" & $CommandSL & "" & @CRLF) ; Set to CAL (C) = 0 $CalStat = 0 GUICtrlSetBkColor($bCAL, $COLOR_WHITE) msgbox($MB_SYSTEMMODAL, "SOT/Cal", "(CAL) = Off", 1) Else msgbox($MB_SYSTEMMODAL, "SOT/Cal", "ANT already On", 1) EndIf Case $bCAL ; Set to ANT (T) If $CalStat = 0 Then $CalStat = 1 $Command = "CAL{ENTER}" ;_CommandSend() GUICtrlSetBkColor($bCAL, $COLOR_RED) Local $CommandSL = StringLeft($Command, 3) _MemoWrite("" & $CommandSL & "" & @CRLF) ; Set to ANT(T) = 0 $AntStat = 0 GUICtrlSetBkColor($bANT, $COLOR_WHITE) msgbox($MB_SYSTEMMODAL, "SOT/Cal", "(ANT) = Off", 1) Else msgbox($MB_SYSTEMMODAL, "SOT/Cal", "CAL already On", 1) EndIf Case $bN1 If $N <> 1 Then $N = 1 $Command = "N1{ENTER}" ;_CommandSend() GUICtrlSetBkColor($bN1, $COLOR_RED) GUICtrlSetBkColor($bN2, $COLOR_WHITE) GUICtrlSetBkColor($bN3, $COLOR_WHITE) Local $CommandSL = StringLeft($Command, 2) _MemoWrite("" & $CommandSL & "" & @CRLF) EndIf Case $bN2 If $N <> 2 Then $N = 2 $Command = "N2{ENTER}" _CommandSend() GUICtrlSetBkColor($bN1, $COLOR_WHITE) GUICtrlSetBkColor($bN2, $COLOR_RED) GUICtrlSetBkColor($bN3, $COLOR_WHITE) Local $CommandSL = StringLeft($Command, 2) _MemoWrite("" & $CommandSL & "" & @CRLF) EndIf Case $bN3 If $N <> 3 Then $N = 3 $Command = "N3{ENTER}" _CommandSend() GUICtrlSetBkColor($bN1, $COLOR_WHITE) GUICtrlSetBkColor($bN2, $COLOR_WHITE) GUICtrlSetBkColor($bN3, $COLOR_RED) Local $CommandSL = StringLeft($Command, 2) _MemoWrite("" & $CommandSL & "" & @CRLF) EndIf Case $bT If $T = 2 Then $T = 1 $Command = "T1{ENTER}" ;_CommandSend() GUICtrlSetData($bT, "1") GUICtrlSetBkColor($bT, $COLOR_WHITE) Local $CommandSL = StringLeft($Command, 2) _MemoWrite("" & $CommandSL & " Bit Off" & @CRLF) Else $T = 2 $Command = "T2{ENTER}" ;_CommandSend() GUICtrlSetData($bT, "2") GUICtrlSetBkColor($bT, 0xFF0000) Local $CommandSL = StringLeft($Command, 2) _MemoWrite("" & $CommandSL & " Bit On" & @CRLF) EndIf Case $SStatus Local $hWnd = WinWait("[CLASS:VTWin32]", "", 2) ControlFocus($hWnd, "", "") ;Send("SHOW STAT{ENTER}") _MemoWrite("SHOW STAT" & @CRLF) Sleep(100) EndSwitch WEnd EndFunc ; #FUNCTION# ============================================================================================== ; Name ..........: _CommandSend ; ========================================================================================================= Func _CommandSend() Send($Command) EndFunc ; ========================================================================================================= Func _MemoWrite($sMessage) GUICtrlSetData($console, $sMessage & @CRLF, 1) EndFunc ;==>MemoWrite   Â
BrewManNH Posted August 1, 2018 Posted August 1, 2018 Try it this way. I converted your code for the button creation of all the J#T buttons, putting the control IDs into an array, and adding the button press detection to the messageloop. expandcollapse popup; #INDEX# ================================================================================================= ; Name ..........: 6936.au3 ; Version Date ..: 2018-07-27 ; AutoIt Version : 3.3.8.1 ; Author(s) .....: Charles Wright ; Dll(s) ........: ; Error handling : ; ========================================================================================================= ; Includes ================================================================================================ ;========================================================================================================== #include <ColorConstants.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GuiEdit.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <ComUDF.au3> ;========================================================================================================== ; Global Variables ======================================================================================== ; Switch Settings ========================================================================================= ;========================================================================================================== Global $HSSLBstatus = 0 ;0 = off, 1 = on Global $A = 2 ;default = 2 / 1 = Calibration Noise Source, 2 = External Noise (J2-/J28) Global $C = 1 ;default = 1 / 1 = Calibration Source Off, 2 = Calibration Source On Global $D = 1 ;default = 1 / 1 = Amp On/In Path, 2 = Amp Off/Bypass Global $AntStat = 1 ;default = 1 / When set, S2A-S2I set to T (DF) Global $CalStat = 0 ;default = 0 / When set, S2A-S2I set to C (CAL) Global $N = 2 ;default = 2 / 1 = LF, 2 = HF1, 3 = HF2 Global $T = 1 ;default = 1 / 1 = Off, 2 = Bit On Global $HLBs = 0 ; Command Variables ======================================================================================= ; Random Bits ============================================================================================= ;========================================================================================================== Global $Command, $Status, $Command, $HSSLoopBk Global $HLB = "Off" Global $sMsg = "" Global $cHLBoff = "HSS LOOPBK 0{ENTER}" Global $cHLBon = "HSS LOOPBK 1{ENTER}" Global $cA = "A{ENTER}" ;========================================================================================================== Opt("MustDeclareVars", 1) main() ; Main ==================================================================================================== ;========================================================================================================== Func main() Global $g_Core = GUICreate("6936 Pre-Test", 627, 602, 234, 133) GUISetFont(9, 400, 0, "MS Sans Serif") GUISetBkColor(0xB9D1EA) Global $CoreHandle = WinGetHandle($g_Core) Global $bSTTP = GUICtrlCreateButton("Connect", 24, 48, 75, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) Global $uComm = GUICtrlCreateInput("", 104, 48, 49, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER)) GUICtrlSetTip(-1, "Comm Port") GUICtrlCreateLabel("COMM Port", 104, 24, 59, 17) ;-- Local $bS = GUICtrlCreateButton("Status (S)", 24, 88, 75, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) ;-- Local $bR = GUICtrlCreateButton("RESET (R)", 104, 88, 75, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) ;-- GUICtrlCreateLabel("HSS LOOPBK", 64, 128, 72, 17) GUICtrlSetTip(-1, "Default = off") Local $bHSSLoopBk = GUICtrlCreateButton("" & $HLB & "", 64, 152, 75, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) ;-- GUICtrlCreateLabel("Test Selection (A#)", 56, 192, 95, 17) GUICtrlSetTip(-1, "Default = 2") Local $bA = GUICtrlCreateButton("" & $A & "", 64, 208, 75, 25) GUICtrlSetBkColor(-1, 0xFF0000) ;-- GUICtrlCreateLabel("Calibration Control (C#)", 48, 248, 112, 17) GUICtrlSetTip(-1, "Default = 1") Local $bC = GUICtrlCreateButton("" & $C & "", 64, 264, 75, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) ;-- GUICtrlCreateLabel("Amp Control (D#)", 56, 304, 85, 17) GUICtrlSetTip(-1, "Default = 1") Local $bD = GUICtrlCreateButton("" & $D & "", 64, 328, 75, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) ;-- Local $bANT = GUICtrlCreateButton("SOT/Cal (ANT)", 56, 368, 91, 25) GUICtrlSetTip(-1, "Default = ANT") GUICtrlSetBkColor(-1, 0xFF0000) ;-- Local $bCAL = GUICtrlCreateButton("SOT/Cal (CAL)", 56, 400, 91, 25) GUICtrlSetTip(-1, "Default = ANT") GUICtrlSetBkColor(-1, $COLOR_WHITE) ;-- GUICtrlCreateLabel("Antenna Band Select (N#)", 40, 440, 129, 17) GUICtrlSetTip(-1, "Default = 2") Local $bN1 = GUICtrlCreateButton("1", 40, 464, 35, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) Local $bN2 = GUICtrlCreateButton("2", 80, 464, 35, 25) GUICtrlSetBkColor(-1, 0xFF0000) Local $bN3 = GUICtrlCreateButton("3", 120, 464, 35, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) ;-- GUICtrlCreateLabel("Antenna Bit (T#)", 56, 504, 82, 17) GUICtrlSetTip(-1, "Default = 1") Local $bT = GUICtrlCreateButton("" & $T & "", 48, 528, 99, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) ;-- Local $SStatus = GUICtrlCreateButton("SHOW STAT", 56, 560, 75, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) ;-- GUICtrlCreateLabel("SOT/Cal (J#)", 360, 32, 81, 20) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") Local $abJT[9] ; ++++++++++++++++++++++++++++++++++++++++++ ; + This section changed + ; ++++++++++++++++++++++++++++++++++++++++++ For $Button = 0 To 8 $abJT[$Button] = GUICtrlCreateButton("J" & $Button & "T", 224 + ($Button * 40), 56, 35, 25) GUICtrlSetBkColor(-1, $COLOR_RED) ;~ Local $bJ1T = GUICtrlCreateButton("J1T", 264, 56, 35, 25) ;~ GUICtrlSetBkColor(-1, $COLOR_RED) ;~ Local $bJ2T = GUICtrlCreateButton("J2T", 304, 56, 35, 25) ;~ GUICtrlSetBkColor(-1, $COLOR_RED) ;~ Local $bJ3T = GUICtrlCreateButton("J3T", 344, 56, 35, 25) ;~ GUICtrlSetBkColor(-1, $COLOR_RED) ;~ Local $bJ4T = GUICtrlCreateButton("J4T", 384, 56, 35, 25) ;~ GUICtrlSetBkColor(-1, $COLOR_RED) ;~ Local $bJ5T = GUICtrlCreateButton("J5T", 424, 56, 35, 25) ;~ GUICtrlSetBkColor(-1, $COLOR_RED) ;~ Local $bJ6T = GUICtrlCreateButton("J6T", 464, 56, 35, 25) ;~ GUICtrlSetBkColor(-1, $COLOR_RED) ;~ Local $bJ7T = GUICtrlCreateButton("J7T", 504, 56, 35, 25) ;~ GUICtrlSetBkColor(-1, $COLOR_RED) ;~ Local $bJ8T = GUICtrlCreateButton("J8T", 544, 56, 35, 25) ;~ GUICtrlSetBkColor(-1, $COLOR_RED) Next ;-- Local $bJ0C = GUICtrlCreateButton("J0C", 224, 88, 35, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) Local $bJ1C = GUICtrlCreateButton("J1C", 264, 88, 35, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) Local $bJ2C = GUICtrlCreateButton("J2C", 304, 88, 35, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) Local $bJ3C = GUICtrlCreateButton("J3C", 344, 88, 35, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) Local $bJ4C = GUICtrlCreateButton("J4C", 384, 88, 35, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) Local $bJ5C = GUICtrlCreateButton("J5C", 424, 88, 35, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) Local $bJ6C = GUICtrlCreateButton("J6C", 464, 88, 35, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) Local $bJ7C = GUICtrlCreateButton("J7C", 504, 88, 35, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) Local $bJ8C = GUICtrlCreateButton("J8C", 544, 88, 35, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) ;-- Local $bHSG0 = GUICtrlCreateButton("HSS SEND G0", 200, 168, 99, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) Local $bHSG1 = GUICtrlCreateButton("HSS SEND G1", 304, 168, 99, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) Local $bHSG2 = GUICtrlCreateButton("HSS SEND G2", 408, 168, 99, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) Local $bHSG3 = GUICtrlCreateButton("HSS SEND G3", 512, 168, 99, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) Local $bHSG4 = GUICtrlCreateButton("HSS SEND G4", 200, 208, 99, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) Local $bHSG5 = GUICtrlCreateButton("HSS SEND G5", 304, 208, 99, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) Local $bHSG6 = GUICtrlCreateButton("HSS SEND G6", 408, 208, 99, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) Local $bHSG7 = GUICtrlCreateButton("HSS SEND G7", 512, 208, 99, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) Local $bHSG8 = GUICtrlCreateButton("HSS SEND G8", 360, 248, 99, 25) GUICtrlSetBkColor(-1, $COLOR_WHITE) ;--- Global $console = GUICtrlCreateEdit("", 216, 296, 393, 289, $WS_VSCROLL) GUICtrlSetData(-1, "") GUISetState(@SW_SHOW, $g_Core) Local $sMsg = "" While 1 Global $nMsg1 = GUIGetMsg() Switch $nMsg1 Case $GUI_EVENT_CLOSE MsgBox($MB_OK, "Window Close", "Exiting Tera Term, Exiting 6536...", 1) ;Send("{CTRLDOWN}B{CTRLUP}CONSOLE 0{CTRLDOWN}D{CTRLUP}{ENTER}") WinClose("[CLASS:VTWin32]", "") GUIDelete($CoreHandle) Exit Case $bSTTP Local $Comm = GUICtrlRead($uComm) Local $Model = "6936RFDU.INI" _MemoWrite("Starting TeraTerm on COMM " & $Comm & "." & @CRLF) ShellExecute("C:\Program Files (x86)\teraterm\ttermpro.exe", "/C=" & $Comm & " /F=" & $Model, "C:\Program Files (x86)\teraterm") Global $hWnd = WinWait("[CLASS:VTWin32]", "", 2) WinMove($hWnd, "[CLASS:VTWin32]", 1008, 4, 589, 850, 1) _MemoWrite("Opening Console Mode 2" & @CRLF) Sleep(100) ;Send("{CTRLDOWN}B{CTRLUP}CONSOLE 2{CTRLDOWN}D{CTRLUP}{ENTER}") Sleep(100) Case $bS Local $hWnd = WinWait("[CLASS:VTWin32]", "", 2) ControlFocus($hWnd, "", "") _MemoWrite("Status Command Sent" & @CRLF) ;Send("S{ENTER}") Sleep(100) Case $bR Local $hWnd = WinWait("[CLASS:VTWin32]", "", 2) ControlFocus($hWnd, "", "") _MemoWrite("Reset Command Sent and Reseting Gui" & @CRLF) ;Send("R{ENTER}") ;Reset all variables ----------------------------------------------------------------------------------------------------- Global $HSSLBstatus = 0 ;0 = off, 1 = on Global $A = 2 ;default = 2 / 1 = Calibration Noise Source, 2 = External Noise (J2-/J28) Global $C = 1 ;default = 1 / 1 = Calibration Source Off, 2 = Calibration Source On Global $D = 1 ;default = 1 / 1 = Amp On/In Path, 2 = Amp Off/Bypass Global $AntStat = 1 ;default = 1 / When set, S2A-S2I set to T (DF) Global $CalStat = 0 ;default = 0 / When set, S2A-S2I set to C (CAL) Global $N = 2 ;default = 2 / 1 = LF, 2 = HF1, 3 = HF2 Global $T = 1 ;default = 1 / 1 = Off, 2 = Bit On Global $HLBs = 0 ;-------------------------------------------------------------------------------------------------------------------------- GUIDelete($CoreHandle) main() Case $bHSSLoopBk Local $hWnd = WinWait("[CLASS:VTWin32]", "", 2) ControlFocus($hWnd, "", "") If $HLBs = 0 Then $HLB = "On" $HLBs = 1 $Command = $cHLBon ;_CommandSend() _MemoWrite("HSS LoopBk = On" & @CRLF) GUICtrlSetData($bHSSLoopBk, $HLB) GUICtrlSetBkColor($bHSSLoopBk, $COLOR_RED) Else $HLB = "Off" $HLBs = 0 $Command = $cHLBoff ;_CommandSend() _MemoWrite("HSS LoopBk = Off" & @CRLF) GUICtrlSetData($bHSSLoopBk, $HLB) GUICtrlSetBkColor($bHSSLoopBk, $COLOR_WHITE) EndIf Case $bA If $A = 2 Then $A = 1 $Command = "A1{ENTER}" ;_CommandSend() GUICtrlSetData($bA, "1") GUICtrlSetStyle($bA, $GUI_SS_DEFAULT_BUTTON) Local $CommandSL = StringLeft($Command, 2) _MemoWrite("" & $CommandSL & "" & @CRLF) Else $A = 2 $Command = "A2{ENTER}" ;_CommandSend() GUICtrlSetData($bA, "2") GUICtrlSetBkColor($bA, 0xFF0000) Local $CommandSL = StringLeft($Command, 2) _MemoWrite("" & $CommandSL & "" & @CRLF) EndIf Case $bC If $C = 2 Then $C = 1 $Command = "C1{ENTER}" ;_CommandSend() GUICtrlSetData($bC, "1") GUICtrlSetStyle($bC, $GUI_SS_DEFAULT_BUTTON) Local $CommandSL = StringLeft($Command, 2) _MemoWrite("" & $CommandSL & "" & @CRLF) Else $C = 2 $Command = "C2{ENTER}" ;_CommandSend() GUICtrlSetData($bC, "2") GUICtrlSetBkColor($bC, 0xFF0000) Local $CommandSL = StringLeft($Command, 2) _MemoWrite("" & $CommandSL & "" & @CRLF) EndIf Case $bD If $D = 2 Then $D = 1 $Command = "D1{ENTER}" ;_CommandSend() GUICtrlSetData($bD, "1") GUICtrlSetStyle($bD, $GUI_SS_DEFAULT_BUTTON) Local $CommandSL = StringLeft($Command, 2) _MemoWrite("" & $CommandSL & "" & @CRLF) Else $D = 2 $Command = "D2{ENTER}" ;_CommandSend() GUICtrlSetData($bD, "2") GUICtrlSetBkColor($bD, 0xFF0000) Local $CommandSL = StringLeft($Command, 2) _MemoWrite("" & $CommandSL & "" & @CRLF) EndIf Case $bANT ; Set to ANT (T) If $AntStat = 0 Then $AntStat = 1 $Command = "ANT{ENTER}" ;_CommandSend() GUICtrlSetBkColor($bANT, $COLOR_RED) Local $CommandSL = StringLeft($Command, 3) _MemoWrite("" & $CommandSL & "" & @CRLF) ; Set to CAL (C) = 0 $CalStat = 0 GUICtrlSetBkColor($bCAL, $COLOR_WHITE) MsgBox($MB_SYSTEMMODAL, "SOT/Cal", "(CAL) = Off", 1) Else MsgBox($MB_SYSTEMMODAL, "SOT/Cal", "ANT already On", 1) EndIf Case $bCAL ; Set to ANT (T) If $CalStat = 0 Then $CalStat = 1 $Command = "CAL{ENTER}" ;_CommandSend() GUICtrlSetBkColor($bCAL, $COLOR_RED) Local $CommandSL = StringLeft($Command, 3) _MemoWrite("" & $CommandSL & "" & @CRLF) ; Set to ANT(T) = 0 $AntStat = 0 GUICtrlSetBkColor($bANT, $COLOR_WHITE) MsgBox($MB_SYSTEMMODAL, "SOT/Cal", "(ANT) = Off", 1) Else MsgBox($MB_SYSTEMMODAL, "SOT/Cal", "CAL already On", 1) EndIf Case $bN1 If $N <> 1 Then $N = 1 $Command = "N1{ENTER}" ;_CommandSend() GUICtrlSetBkColor($bN1, $COLOR_RED) GUICtrlSetBkColor($bN2, $COLOR_WHITE) GUICtrlSetBkColor($bN3, $COLOR_WHITE) Local $CommandSL = StringLeft($Command, 2) _MemoWrite("" & $CommandSL & "" & @CRLF) EndIf Case $bN2 If $N <> 2 Then $N = 2 $Command = "N2{ENTER}" _CommandSend() GUICtrlSetBkColor($bN1, $COLOR_WHITE) GUICtrlSetBkColor($bN2, $COLOR_RED) GUICtrlSetBkColor($bN3, $COLOR_WHITE) Local $CommandSL = StringLeft($Command, 2) _MemoWrite("" & $CommandSL & "" & @CRLF) EndIf Case $bN3 If $N <> 3 Then $N = 3 $Command = "N3{ENTER}" _CommandSend() GUICtrlSetBkColor($bN1, $COLOR_WHITE) GUICtrlSetBkColor($bN2, $COLOR_WHITE) GUICtrlSetBkColor($bN3, $COLOR_RED) Local $CommandSL = StringLeft($Command, 2) _MemoWrite("" & $CommandSL & "" & @CRLF) EndIf Case $bT If $T = 2 Then $T = 1 $Command = "T1{ENTER}" ;_CommandSend() GUICtrlSetData($bT, "1") GUICtrlSetBkColor($bT, $COLOR_WHITE) Local $CommandSL = StringLeft($Command, 2) _MemoWrite("" & $CommandSL & " Bit Off" & @CRLF) Else $T = 2 $Command = "T2{ENTER}" ;_CommandSend() GUICtrlSetData($bT, "2") GUICtrlSetBkColor($bT, 0xFF0000) Local $CommandSL = StringLeft($Command, 2) _MemoWrite("" & $CommandSL & " Bit On" & @CRLF) EndIf Case $SStatus Local $hWnd = WinWait("[CLASS:VTWin32]", "", 2) ControlFocus($hWnd, "", "") ;Send("SHOW STAT{ENTER}") _MemoWrite("SHOW STAT" & @CRLF) Sleep(100) Case $abJT[0] To $abJT[8] ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< added this section For $I = 0 To 8 If $nMsg1 = $abJT[$I] Then _MemoWrite("Button J" & $I & " was pressed" & @CRLF) EndIf Next EndSwitch WEnd EndFunc ;==>main ; #FUNCTION# ============================================================================================== ; Name ..........: _CommandSend ; ========================================================================================================= Func _CommandSend() Send($Command) EndFunc ;==>_CommandSend ; ========================================================================================================= Func _MemoWrite($sMessage) GUICtrlSetData($console, $sMessage & @CRLF, 1) EndFunc ;==>_MemoWrite  If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator
Fractured Posted August 1, 2018 Author Posted August 1, 2018 TY! That worked like a champ! I added your change for the J#C buttons (modified the variables to fit) and the script works great! I should be able to do the same for the HSS Send buttons too correct? If so, it will be a quick ending to this script!
BrewManNH Posted August 1, 2018 Posted August 1, 2018 Saves a lot of typing too If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator
Fractured Posted August 2, 2018 Author Posted August 2, 2018 yes it did! The HSS Send buttons are now my next piece....hoping I can do something similar, except as you turn one switch red, the others need to turn white....Not sure if you can compare an array onto itself or create 3 roes of 4 buttons with one array.....reading through forum, wiki, etc this morning to figure it out! Thanks for all the help so far! Â
Fractured Posted August 2, 2018 Author Posted August 2, 2018 just got it out of the blue....omg this is making this so much easier!!Â
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now