Travis Posted March 23, 2015 Posted March 23, 2015 Hello I am scripting a simple application using TCP functionality. I encountered a problem that I thought I could I fix by switching to GUI OnEvent mode, however, I still have the same issue. I can walk you through how my script works: Upon starting the program, the user is presented with a dialog box and asked to choose to start the server or client mode. I'm working on the server mode at the moment so I choose to start the Server mode. The selection dialog is then hidden and my main GUI comes up. I have some text labels that show me the status, it starts with "Program started, attempting to run as server." Then I go through the process of setting up my TCP sockets and such. Then, I get to a Do...While loop to get the server to wait for a client to connect. GUICtrlSetData($dev_connection_status_text,"Awaiting client connection...") Do $socketB = TCPAccept($socketA) Until $socketB <> - 1 Now the problem is here. While I am waiting for a client to connect, I noticed that I cannot close the program using the Close button on the menu. It seems that my gui is no longer listening for $GUI_EVENT_CLOSE? I had thought switching to OnEvent mode would fix this. But how can I still have my GUI respond to user input while awaiting this connection?
JohnOne Posted March 24, 2015 Posted March 24, 2015 (edited) GUICtrlSetData($dev_connection_status_text,"Awaiting client connection...") Do If GuiGetMsg() = -3 Then Exit $socketB = TCPAccept($socketA) Until $socketB <> - 1 Edited March 24, 2015 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
JohnOne Posted March 24, 2015 Posted March 24, 2015 Then I suspect you have other code issues. $hGui = GUICreate("GUI") $dev_connection_status_text = GUICtrlCreateLabel("idle", 20, 20, 300) GUISetState() While 3 Switch GUIGetMsg() Case -3 Exit Case $dev_connection_status_text _Func() EndSwitch WEnd Func _Func() GUICtrlSetData($dev_connection_status_text, "Awaiting client connection...") TCPStartup() $socketA = TCPConnect("127.0.0.1", 7656) Do If GUIGetMsg() = -3 Then Exit $socketB = TCPAccept($socketA) Until $socketB <> -1 GUICtrlSetData($dev_connection_status_text, "connected") Beep(400, 100) EndFunc ;==>_Func AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
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