#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 375, 167, 192, 124)
$Button1 = GUICtrlCreateButton("打开串口", 40, 16, 75, 25)
$Edit1 = GUICtrlCreateEdit("", 176, 24, 185, 89)
GUICtrlSetData(-1, "Edit1")
$Button2 = GUICtrlCreateButton("发送数据", 40, 56, 65, 25)
$Button3 = GUICtrlCreateButton("关闭串口", 32, 96, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
DllOpen(@ScriptDir&'\CameraDll.dll')
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$com =1
$Comm=ObjCreate("MSCOMMLib.MSComm")
$Comm.CommPort=$com;设定要使用的端口1~16
$Comm.Handshaking=0
$Comm.RThreshold=0
$Comm.Settings="9600,N,8,1"
$Comm.InputLen=0
$Comm.RTSEnable=False
$Comm.InputMode=1;0文本传输
$Comm.PortOpen=TRUE
Case $Button2
$temp="this a test!"
$Comm.Output=$temp
$inp=$Comm.Input
GUICtrlSetData($Edit1,$inp)
EndSwitch
WEnd |