Jump to content

how to make 2 loops in a script ? -need help-


Recommended Posts

hi all anyone knows why i can't but 2 thing in one loop ?
i tried to make 2 while loops but the first one is the only running one.
here is the code:

‪#‎include‬ <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
‪#‎region‬ ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 237)
GUISetState(@SW_SHOW)
‪#‎endregion‬ ### END Koda GUI section ###

TCPStartup()
$TCPListen = TCPListen(@IPAddress1, 403)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
Do
$TCPAccept = TCPAccept($TCPListen)
Until $TCPAccept <> -1

Do
$TCPRecive = TCPRecv($TCPAccept, 1000000)
Until $TCPRecive <> ""
MsgBox(0, "hi", $TCPRecive)
WEnd

any ideas ?

Edited by alexander95

Link to comment
Share on other sites

Hi alexander95

your script works for me.

where is the problem?

to use your script yo need to send a messag to it from another script

1) compile your script and execute the resulting executable

2) then, while your script (exe) is running,  run this second script from sciTE to send messages to your first sciript and you will see popup "hi" response.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 623, 153, 280, 165)
$Edit1 = GUICtrlCreateEdit("", 8, 8, 593, 113)
GUICtrlSetData(-1, "Edit1")
$Button1 = GUICtrlCreateButton("Button1", 8, 128, 593, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

TCPStartup()

Local $g_IP = @IPAddress1 ; same as server this example

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1

$Socket = TCPConnect($g_IP, 403) ; call the server

If @error Then
ConsoleWrite('!--> TCPConnect error number ( ' & @error & ' ).' & @CRLF)
Exit
EndIf

TCPSend($Socket, GUICtrlRead($Edit1)) ; send the content of upper Edit1

EndSwitch
WEnd

bye

Edited by Pincopanco

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

hi all anyone knows why i can't but 2 thing in one loop ?

i tried to make 2 while loops but the first one is the only running one.

 

Use AdlibRegister to the function of the second loop.

Link to comment
Share on other sites

the script have to codes the first is the GUI close

the second is the tcp functions

when i run them to gather in 1 loop only the tcp will work and the close func will never work

and if u runned them in 2 loops the second 1 will never work

!!!!!!!!!!

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...