Jump to content

Recommended Posts

Posted

So my test Control script acts and runs perfectly when it is in an au3 state...but when I compile it to an exe my combo box shows no set data...anyhelp would be great...

p.s. if you need to see the script let me know. Its about 532 lines...

Posted (edited)
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Compression=3
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
; #INDEX# ================================================================================================
; Name ..........: 10086_Core.au3
; Version Date ..: 2018-08-21
; AutoIt Version : 3.3.14.5
; Author(s) .....: Charles Wright
; Dll(s) ........:
; Error handling :
; ========================================================================================================


#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include "ExtMsgBox.au3"        ; REF - Melba23 - Autoit Forum Moderator - Extended Message Box
#include <CommInterface.au3>    ; https://www.autoitscript.com/wiki/CommAPI_Examples

#include <_10086Commands.au3>
#include <_10086Test.au3>
#include "ExtMsgBox.au3"

Local $ClickConnect = 0

#Region ### START Koda GUI section ### Form=z:\work\macro\autoit scripts\mine\10086\10086_core.kxf
$g_Core = GUICreate("10086 Core", 883, 600, 196, 120)
GUISetBkColor(0xA6CAF0)
; ## Connection Group ##
$Connection = GUICtrlCreateGroup("Connection", 16, 8, 169, 81, BitOR($GUI_SS_DEFAULT_GROUP,$BS_CENTER))
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label1 = GUICtrlCreateLabel("COMM Port", 24, 24, 72, 20)
$i_CommPort = GUICtrlCreateInput("", 24, 48, 73, 24, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
$b_Connect = GUICtrlCreateButton("Connect", 104, 48, 75, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
; ## Connection Group End ##
; ## Commands Group ##
$Commands = GUICtrlCreateGroup("Commands", 8, 96, 257, 473, BitOR($GUI_SS_DEFAULT_GROUP,$BS_CENTER))
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$b_IDNQuery = GUICtrlCreateButton("*IDN?", 24, 144, 43, 25)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
$b_IDN = GUICtrlCreateButton("IDN", 24, 176, 43, 25)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
$i_IDNserno = GUICtrlCreateInput("", 72, 176, 49, 24, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
GUICtrlSetTip(-1, "Serial Number")
$b_ConsoleQuery = GUICtrlCreateButton("CONSOLE?", 24, 208, 75, 25)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
$b_Console = GUICtrlCreateButton("CONSOLE", 24, 240, 75, 25)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
$i_ConsoleMode = GUICtrlCreateInput("", 104, 240, 33, 24, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
GUICtrlSetTip(-1, "0, 1, Off, On")
;$b_ShowStat = GUICtrlCreateButton("SHOW STAT", 168, 144, 75, 25)
;GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
$b_Reboot = GUICtrlCreateButton("REBOOT", 96, 120, 75, 25)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
GUICtrlSetBkColor(-1, 0xFFFFFF)
$b_TempQuery = GUICtrlCreateButton("TEMP?", 24, 272, 75, 25)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
$i_TempQueryChan = GUICtrlCreateInput("", 104, 272, 33, 24, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
GUICtrlSetTip(-1, "0 - Internal, 1 - Attenuator")
$b_HPLockQuery = GUICtrlCreateButton("HPLOCK?", 24, 304, 75, 25)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
$i_HPLockQueryName = GUICtrlCreateInput("", 104, 304, 33, 24, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
GUICtrlSetTip(-1, "Switch Id")
$b_ADCQuery = GUICtrlCreateButton("ADC?", 152, 240, 43, 25)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
$i_ADCQueryChan = GUICtrlCreateInput("", 200, 240, 41, 24, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
GUICtrlSetTip(-1, "Channel Number")
$b_ADCHelp = GUICtrlCreateButton("?", 240, 240, 19, 25)
GUICtrlSetBkColor(-1, 0xFFFF00)
$b_LLOQuery = GUICtrlCreateButton("LLO?", 152, 272, 43, 25)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
$b_LLO = GUICtrlCreateButton("LLO", 152, 304, 43, 25)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
$i_LLO = GUICtrlCreateInput("", 200, 304, 41, 24, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
GUICtrlSetTip(-1, "0, 1, Off, On")
$b_Switch = GUICtrlCreateButton("SWITCH", 24, 352, 75, 25)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
$i_SwNmStName = GUICtrlCreateInput("", 104, 352, 73, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
GUICtrlSetTip(-1, "Switch Name")
$i_SwNmStSetting = GUICtrlCreateInput("", 184, 352, 49, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
GUICtrlSetTip(-1, "Setting")
$b_SwitchQuery = GUICtrlCreateButton("SWITCH?", 24, 384, 75, 25)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
$b_Help2 = GUICtrlCreateButton("?", 184, 384, 19, 25)
GUICtrlSetBkColor(-1, 0xFFFF00)
$i_SwitchNameQuery = GUICtrlCreateInput("", 104, 384, 73, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
GUICtrlSetTip(-1, "Switch Name")
$b_Help1 = GUICtrlCreateButton("?", 240, 352, 19, 25)
GUICtrlSetBkColor(-1, 0xFFFF00)
$b_SetTempSenseLimit = GUICtrlCreateButton("SET TEMPSENSE LIMIT", 24, 432, 139, 25)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
$i_SetTempSenseLimit = GUICtrlCreateInput("", 168, 432, 81, 24, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
GUICtrlSetTip(-1, "Temp in degC")
$b_SetSerialBaudRate = GUICtrlCreateButton("SET SERIAL BAUDRATE", 24, 464, 139, 25)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
$i_SetSerialBaudRate = GUICtrlCreateCombo("", 168, 464, 81, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "9600|19200|38400|57600|115200|230400")
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
$b_CLS = GUICtrlCreateButton("*CLS", 16, 512, 43, 25)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
$b_OPC = GUICtrlCreateButton("*OPC?", 64, 512, 43, 25)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
$b_RST = GUICtrlCreateButton("*RST", 112, 512, 43, 25)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
$b_TST = GUICtrlCreateButton("*TST?", 160, 512, 43, 25)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
$b_ERR = GUICtrlCreateButton("ERR?", 208, 512, 43, 25)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
$b_ShowSet = GUICtrlCreateButton("SHOW SET", 176, 176, 75, 25)
$b_TempSensorQuery = GUICtrlCreateButton("TEMPSENSOR?", 168, 208, 91, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
; ## Commands Group End ##
; ## Test Group ##
$Group1 = GUICtrlCreateGroup("Test", 272, 96, 185, 489, BitOR($GUI_SS_DEFAULT_GROUP,$BS_CENTER))
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$b_SWHF11 = GUICtrlCreateButton("SW HF1 1", 288, 120, 75, 25)
$b_SWHF12 = GUICtrlCreateButton("SW HF1 2", 368, 120, 75, 25)
$b_SWVUHF11 = GUICtrlCreateButton("SW VUHF1 1", 288, 168, 75, 25)
$b_SWVUHF21 = GUICtrlCreateButton("SW VUHF2 1", 288, 200, 75, 25)
$b_SWVUHF31 = GUICtrlCreateButton("SW VUHF3 1", 288, 232, 75, 25)
$b_SWVUHF12 = GUICtrlCreateButton("SW VUHF1 2", 368, 168, 75, 25)
$b_SWVUHF22 = GUICtrlCreateButton("SW VUHF2 2", 368, 200, 75, 25)
$b_SWVUHF32 = GUICtrlCreateButton("SW VUHF3 2", 368, 232, 75, 25)
$b_SWVUHFACQ1 = GUICtrlCreateButton("SW VUHFACQ 1", 296, 272, 139, 25)
$b_SWVUHFACQ2 = GUICtrlCreateButton("SW VUHFACQ 2", 296, 304, 139, 25)
$b_SWVUHFACQ3 = GUICtrlCreateButton("SW VUHFACQ 3", 296, 336, 139, 25)
$b_SWVUHFACQ4 = GUICtrlCreateButton("SW VUHFACQ 4", 296, 368, 139, 25)
$b_SWIO11 = GUICtrlCreateButton("SW IO1 1", 288, 408, 75, 25)
$b_SWIO21 = GUICtrlCreateButton("SW IO2 1", 288, 440, 75, 25)
$b_SWIO31 = GUICtrlCreateButton("SW IO3 1", 288, 472, 75, 25)
$b_SWIO12 = GUICtrlCreateButton("SW IO1 2", 368, 408, 75, 25)
$b_SWIO22 = GUICtrlCreateButton("SW IO2 2", 368, 440, 75, 25)
$b_SWIO32 = GUICtrlCreateButton("SW IO3 2", 368, 472, 75, 25)
$b_ShowStat = GUICtrlCreateButton("SHOW STAT", 288, 512, 155, 25)
$b_SetTempSenseLimit60 = GUICtrlCreateButton("SET TEMPSENSE LIMIT 60", 288, 544, 155, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
; ## Test Group Ends ##
$Edit1 = GUICtrlCreateEdit("", 472, 16, 393, 529)
GUICtrlSetData(-1, "")
$b_OutFile = GUICtrlCreateButton("Output to File", 616, 552, 75, 25)
$i_Manual = GUICtrlCreateInput("", 200, 16, 265, 21)
$b_SendManual = GUICtrlCreateButton("Manual Send", 296, 40, 75, 25)

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $msg = GUIGetMsg()
    Switch $msg

        Case $GUI_EVENT_CLOSE
            Exit

        Case $b_Connect
            If $ClickConnect = 0 then
                _Connect()
            Else
                _GUICtrlEdit_AppendText($Edit1, "You are already Connected." & @CRLF & @CRLF)
                GUICtrlSetState($b_SendManual, $GUI_FOCUS)
            Endif

        Case $b_IDNQuery
            _IDNQuery()
            _uSend($uInput)

        Case $b_IDN
            _IDNAssign()
            _uSend($uInput)

        Case $b_ConsoleQuery
            _ConsoleQuery()
            _uSend($uInput)

        Case $b_Console
            _ConsoleMode()
            _uSend($uInput)

        Case $b_ShowStat
            _ShowStat()
            _uSend($uInput)

        Case $b_Reboot
            _Reboot()
            _uSend($uInput)

        Case $b_TempQuery
            _TempQuery()
            _uSend($uInput)

        Case $b_HPLockQuery
            _HPLockQuery()
            _uSend($uInput)

        Case $b_ADCQuery
            _ADCQuery()
            _uSend($uInput)

        Case $b_LLOQuery
            _LLOQuery()
            _uSend($uInput)

        Case $b_LLO
            _LLO()
            _uSend($uInput)

        Case $b_Switch
            _SwitchNameSetting()
            _uSend($uInput)

        Case $b_SwitchQuery
            _SwitchNameQuery()
            _uSend($uInput)

        Case $b_SetTempSenseLimit
            _SetTempSenseLimit()
            _uSend($uInput)

        Case $b_SetSerialBaudRate
            _SetSerialBaudRate()
            _uSend($uInput)

        Case $b_CLS
            _CLS()
            _uSend($uInput)

        Case $b_OPC
            _OpCompleteQuery()
            _uSend($uInput)

        Case $b_RST
            _Reset()
            _uSend($uInput)

        Case $b_TST
            _SelfTest()
            _uSend($uInput)

        Case $b_ERR
            _ERRQuery()
            _uSend($uInput)

        Case $b_ShowSet
            _ShowSet()
            _uSend($uInput)

        Case $b_TempSensorQuery
            _TempSensorQuery()
            _uSend($uInput)

        Case $b_Help1
            _Help1()

        Case $b_Help2
            _Help1()

        Case $b_ADCHelp
            _ADCHelp()

; ## Test ##
; ## Test ##
        Case $b_SWHF11
            _SWHF11()
            _uSend($uInput)

        Case $b_SWHF12
            _SWHF12()
            _uSend($uInput)

        Case $b_SWVUHF11
            _SWVUHF11()
            _uSend($uInput)

        Case $b_SWVUHF21
            _SWVUHF21()
            _uSend($uInput)

        Case $b_SWVUHF31
            _SWVUHF31()
            _uSend($uInput)

        Case $b_SWVUHF12
            _SWVUHF12()
            _uSend($uInput)

        Case $b_SWVUHF22
            _SWVUHF22()
            _uSend($uInput)

        Case $b_SWVUHF32
            _SWVUHF32()
            _uSend($uInput)

        Case $b_SWVUHFACQ1
            _SWVUHFACQ1()
            _uSend($uInput)

        Case $b_SWVUHFACQ2
            _SWVUHFACQ2()
            _uSend($uInput)

        Case $b_SWVUHFACQ3
            _SWVUHFACQ3()
            _uSend($uInput)

        Case $b_SWVUHFACQ4
            _SWVUHFACQ4()
            _uSend($uInput)

        Case $b_SWIO11
            _SWIO11()
            _uSend($uInput)

        Case $b_SWIO21
            _SWIO21()
            _uSend($uInput)

        Case $b_SWIO31
            _SWIO31()
            _uSend($uInput)

        Case $b_SWIO12
            _SWIO12()
            _uSend($uInput)

        Case $b_SWIO22
            _SWIO22()
            _uSend($uInput)

        Case $b_SWIO32
            _SWIO32()
            _uSend($uInput)

        Case $b_ShowSet
            _ShowSet()
            _uSend($uInput)

        Case $b_SetTempSenseLimit60
            _SetTempSense()
            _uSend($uInput)

        Case $b_SendManual
            _ManualSend()

        Case $b_OutFile
            _OutFile()
    EndSwitch
WEnd
; ### Internal Functions ##################################################################################

; #FUNCTION# ==============================================================================================
; Name ..........: Main
; =========================================================================================================
Func _Main()
    Local $sResult = _Connect()

    Switch @error
        Case 0
            GUICtrlSetColor($b_Connect, 0x33FF00)
        Case -1
            MsgBox(32, "Error", _WinAPI_GetLastErrorMessage())
        Case -2
            MsgBox(32, "Timeout", $sResult)
        Case Else
            MsgBox(32, "Error", "Error " & @error & " in line " & @extended)
    EndSwitch
EndFunc   ;==>_Main

; #FUNCTION# ==============================================================================================
; Name ..........: Connect
; =========================================================================================================
Func _Connect()

    Global $uPort = GUICtrlRead($i_CommPort)

    If $uPort = "" Then
        _GUICtrlEdit_AppendText($Edit1, "Please Enter a Model Number." & @CRLF & @CRLF)
        $ClickConnect = 0
        GUICtrlSetState($b_SendManual, $GUI_FOCUS)
        Return
    EndIf

    Local Const $iPort = "" & $uPort & ""
    Local Const $iBaud = "115000"
    Local Const $iParity = "0"
    Local Const $iByteSize = "8"
    Local Const $iStopBits = "1"

    GUICtrlSetState($b_SendManual, $GUI_FOCUS)
    $ClickConnect = 1

    Global Const $hFile = _CommAPI_OpenCOMPort($iPort, $iBaud, $iParity, $iByteSize, $iStopBits)

    Local $sResult = _CommAPI_ReceiveString($hFile, 3000)
    If @error Then Return SetError(@error, @ScriptLineNumber, $sResult)

EndFunc   ;==>_Connect

; #FUNCTION# ==============================================================================================
; Name ..........: _uSend
; =========================================================================================================
Func _uSend($uInput)

    _CommAPI_TransmitString($hFile, $uInput & @CRLF)
    If @error Then Return SetError(@error, @ScriptLineNumber)
    GUICtrlSetData($uInput, "")

    Local $sResult = _CommAPI_ReceiveString($hFile, 3000)
    If @error Then Return SetError(@error, @ScriptLineNumber, $sResult)

    _GUICtrlEdit_AppendText($Edit1, $sResult)

    Return $sResult

EndFunc   ;==>_uSend

; #FUNCTION# ==============================================================================================
; Name ..........: _ManualSend
; =========================================================================================================
Func _ManualSend()

    _CommAPI_TransmitString($hFile, GUICtrlRead($i_Manual) & @CRLF)
    If @error Then Return SetError(@error, @ScriptLineNumber)
    GUICtrlSetData($i_Manual, "")

    Local $sResult = _CommAPI_ReceiveString($hFile, 3000)
    If @error Then Return SetError(@error, @ScriptLineNumber, $sResult)

    _GUICtrlEdit_AppendText($Edit1, $sResult)

    Return $sResult

EndFunc   ;==>_ManualSend

; #FUNCTION# ==============================================================================================
; Name ..........: _Help1
; =========================================================================================================
Func _Help1()
            ; Hide the main GUI to centre the message box on screen
            GUISetState(@SW_HIDE, $g_Core)

            ; Change font and justification, leaving colours unchanged
            _ExtMsgBoxSet(1 + 4, $SS_LEFT, -1, -1, 12, "Arial")

            $sMsg = "Valid switch identifiers include:" & @CRLF & @CRLF
            $sMsg &= "HF1 / HF2 1-2" & @CRLF
            $sMsg &= "VUHFACQ 1-4" & @CRLF
            $sMsg &= "VUHF1 1-2" & @CRLF
            $sMsg &= "VUHF2 1-2" & @CRLF
            $sMsg &= "VUHF3 1-2" & @CRLF
            $sMsg &= "IO1 1-2" & @CRLF
            $sMsg &= "IO2 1-2" & @CRLF
            $sMsg &= "IO3 1-2" & @CRLF & @CRLF

            ; Use $MB_ constants and set timeout value
            $iRetValue = _ExtMsgBox($EMB_ICONINFO, "Close", "Switch Help", $sMsg, 5, $g_Core)
            ;ConsoleWrite("Test 2 returned: " & $iRetValue & @CRLF)

            ; Reset to default
            _ExtMsgBoxSet(Default)

            ; Show the main GUI again
            GUISetState(@SW_SHOW, $g_Core)
            WinSetOnTop($g_Core, "", 1)
            WinSetOnTop($g_Core, "", 0)
EndFunc

; #FUNCTION# ==============================================================================================
; Name ..........: _ADCHelp
; =========================================================================================================
Func _ADCHelp()
            ; Hide the main GUI to centre the message box on screen
            GUISetState(@SW_HIDE, $g_Core)

            ; Change font and justification, leaving colours unchanged
            _ExtMsgBoxSet(1 + 4, $SS_LEFT, -1, -1, 12, "Arial")

            $sMsg = "Valid ADC? Channels:" & @CRLF & @CRLF
            $sMsg &= "0 – Internal Temp Sensor" & @CRLF
            $sMsg &= "6 – Power Sensor #1" & @CRLF
            $sMsg &= "7 – Power Sensor #2" & @CRLF
            $sMsg &= "8 – Power Sensor #3" & @CRLF
            $sMsg &= "10 – Attenuator Heatsink Temp Sensor" & @CRLF

            ; Use $MB_ constants and set timeout value
            $iRetValue = _ExtMsgBox($EMB_ICONINFO, "Close", "ADC? Help", $sMsg, 5, $g_Core)
            ;ConsoleWrite("Test 2 returned: " & $iRetValue & @CRLF)

            ; Reset to default
            _ExtMsgBoxSet(Default)

            ; Show the main GUI again
            GUISetState(@SW_SHOW, $g_Core)
            WinSetOnTop($g_Core, "", 1)
            WinSetOnTop($g_Core, "", 0)
EndFunc


; #FUNCTION# ==============================================================================================
; Name ..........: _OutFile
; =========================================================================================================
;Func _OutFile()
;
;   $TempEdit = GUICtrlRead($Edit1)
;   $OutEdit = StringReplace($TempEdit, @LF, "")
;
;   Run("notepad.exe")
;
;   WinWaitActive("Untitled - Notepad")
;   Sleep(1000)
;   ;Send("Untitled - Notepad", "", "Edit1", $OutEdit)
;   Send($OutEdit)
;EndFunc
Func _OutFile()

    $TempEdit = GUICtrlRead($Edit1)
    $OutEdit = $TempEdit

    Run("notepad.exe")

    WinWaitActive("Untitled - Notepad")
    Sleep(1000)
    ControlSetText("Untitled - Notepad", "", "Edit1", $OutEdit)
EndFunc

Removes 2nd ExtMsgBox.au3 from includes....cuz I forgot to earlier!

Edited by Fractured
Posted

Just to close this. it was a user error on my part....im learning i need to save my au3 before running it. My changes dont always take effect till saved...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...