;Run this script on the main system computer to start/stop software recording and to send TCP messages that initiate recording on client computers. #include #include #include #include #include #include #include #include ;Network Settings $ipAddress_host = "192.168.0.201" ;Main host computer $ipAddress_client1 = "192.168.0.202" ;Client computer #1 $ipAddress_client2 = "192.168.0.203" ;Client computer #2 $portAddress = 666 ;GUI info GUICreate("MASS System Recording", 260, 116, 100, 100) ;overall window $status = GUICtrlCreateButton("Click to Start Recording", 45, 20, 170, 40) ;start/stop button GUICtrlCreateLabel("Red Background = Recording", 59, 66, 150, 15) ;text GUICtrlCreateLabel("White Background = Listening", 59, 82, 150, 15) ;text GUICtrlCreateLabel("Close Window to Exit Program", 59, 98, 150, 15) ;text GUISetState(@SW_SHOW) ;bring window to front ;TCP Commands to read $message_start = "START" $message_stop = "STOP" $message_exit = "EXIT" ;Software specific window name and stop/start constants $window_host1 = "RiACQUIRE" $start_host1 = "{F7}" $stop_host1 = "^{F7}" $window_host2 = "FLIR" $start_host2 = "{F6}" $start_host2 = "{F6}" ;Establish socket connections with client computers TCPStartup() $socket_client1 = TCPConnect($ipAddress_client1, $portAddress) ;Connect with client1 computer If @error OR $connectedSocket < 1 Then ;If there was a problem connecting, notify the user. MsgBox(0, "GUI Event", "Could not connect to IP: " & $ipAddress_client1 & " and PORT: " & $portAddress) Exit EndIf $socket_client2 = TCPConnect($ipAddress_client2, $portAddress) ;Connect with client2 computer If @error OR $connectedSocket < 1 Then ;If there was a problem connecting, notify the user. MsgBox(0, "GUI Event", "Could not connect to IP: " & $ipAddress_client2 & " and PORT: " & $portAddress) Exit EndIf ;Check for change in GUI and trigger events if detected $count = 0 While 1 ;Run continuously $nMsg = GUIGetMsg() ;polls GUI to see if any events have occurred. GUI_EVENT_CLOSE = closed window, Switch $nMsg Case $GUI_EVENT_CLOSE ; if GUI closed, close program RecExit() ;send EXIT command before exiting loop Exit Case $status ; if button is clicked toggle status If $count = 1 Then GUISetBkColor($COLOR_WHITE) GUICtrlSetData($status, "Click to Start MASS Recording") RecStop() ;activate appropriate windows and send keystrokes $count = 0 ElseIf $count = 0 Then GUISetBkColor($COLOR_RED) GUICtrlSetData($status, "Click to Stop MASS Recording") RecStart() ;activate appropriate windows and send keystrokes $count = 1 EndIf EndSwitch WEnd Func RecStart() ; If partial RiAcquire window title exists, make it active and send keystrokes to turn recording on If WinExists($window_host1) Then WinActivate($window_host1) ;Sleep(10) Send($start_host1) EndIf ; If partial ResearchIR window title exists, make it active and send keystrokes to turn recording on If WinExists($window_host2) Then WinActivate($window_host2) ;Sleep(10) Send($start_host2) EndIf ;Send start message to other computers TCPSend($socket_client1, $message_start) TCPSend($socket_client2, $message_start) EndFunc Func RecStop() ; If partial RiAcquire window title exists, make it active and send keystrokes to turn recording off If WinExists($window_host1) Then WinActivate($window_host1) ;Sleep(10) Send($stop_host1) EndIf ; If partial ResearchIR window title exists, make it active and send keystrokes to turn recording off If WinExists($window_host2) Then WinActivate($window_host2) ;Sleep(10) Send($start_host2) EndIf ;Send start message to other computers TCPSend($socket_client1, $message_stop) TCPSend($socket_client2, $message_stop) EndFunc Func RecExit() ;Send start message to other computers TCPSend($socket_client1, $message_exit) TCPSend($socket_client2, $message_exit) TCPShutdown() End Func