Hey.
Ich habe ein Script welches sobald es daten via. TCP recieved eine GUI darstellt mit dem Inhalt.
Darauf befindet sich ein Button, der heißt "OK".
Sprich
if $recv <> "" then
showgui()
Endif
Wenn man Ok drückt wird ein GUIdelete ausgeführt.
Aber irgendwie hängt er dann noch in der func. Ich sag dem nämlich am das der der Func eine msgbox auftauchen soll.
Spoiler anzeigen
#include <GUIConstantsEx.au3>
#include <Constants.au3>
#include <EditConstants.au3>
#include <Array.au3>
Opt("TrayOnEventMode",1)
Opt("TrayMenuMode", 1)
Traysetonevent($TRAY_EVENT_SECONDARYDOWN,"SpecialEvent")
Traysetonevent($TRAY_EVENT_PRIMARYDOWN,"SpecialEvent")
TraySetState()
global $tcp,$corner,$xD, $recv
;==============================================
;==============================================
;SERVER!! Start Me First !!!!!!!!!!!!!!!
;==============================================
;==============================================
test()
Func test()
; Set Some reusable info
; Set your Public IP address (@IPAddress1) here.
; Local $szServerPC = @ComputerName
; Local $szIPADDRESS = TCPNameToIP($szServerPC)
Local $szIPADDRESS = @IPAddress1
Local $nPORT = 33891
Local $MainSocket, $GOOEY, $edit, $ConnectedSocket, $szIP_Accepted
Local $msg
; Start The TCP Services
;==============================================
TCPStartup()
; Create a Listening "SOCKET".
; Using your IP Address and Port 33891.
;==============================================
$MainSocket = TCPListen($szIPADDRESS, $nPORT)
; If the Socket creation fails, exit.
If $MainSocket = -1 Then Exit
; Initialize a variable to represent a connection
;==============================================
$ConnectedSocket = -1
;Wait for and Accept a connection
;==============================================
Do
$ConnectedSocket = TCPAccept($MainSocket)
Until $ConnectedSocket <> -1
; Get IP of client connecting
$szIP_Accepted = SocketToIP($ConnectedSocket)
while 1 ; GUI Message Loop
;==============================================
$msg = GUIGetMsg()
; GUI Closed
;--------------------
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
; Try to receive (up to) 2048 bytes
;----------------------------------------------------------------
$recv = TCPRecv($ConnectedSocket, 2048)
; If the receive failed with @error then the socket has disconnected
;----------------------------------------------------------------
If @error Then ExitLoop
; Update the edit control with what we have received
;----------------------------------------------------------------
If $recv <> "" Then
display()
Endif
If $ConnectedSocket <> -1 Then TCPCloseSocket($ConnectedSocket)
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]TCPShutdown()
[/autoit] [autoit][/autoit] [autoit]Wend
test()
Endfunc
; Function to return IP Address from a connected socket.
;----------------------------------------------------------------------
Func SocketToIP($SHOCKET)
Local $sockaddr, $aRet
$sockaddr = DllStructCreate("short;ushort;uint;char[8]")
[/autoit] [autoit][/autoit] [autoit]$aRet = DllCall("Ws2_32.dll", "int", "getpeername", "int", $SHOCKET, _
"ptr", DllStructGetPtr($sockaddr), "int*", DllStructGetSize($sockaddr))
If Not @error And $aRet[0] = 0 Then
$aRet = DllCall("Ws2_32.dll", "str", "inet_ntoa", "int", DllStructGetData($sockaddr, 3))
If Not @error Then $aRet = $aRet[0]
Else
$aRet = 0
EndIf
$sockaddr = 0
[/autoit] [autoit][/autoit] [autoit]Return $aRet
EndFunc ;==>SocketToIP
func display()
Guicreate("* Message Info",450,300)
GuictrlcreateLabel("Message from *",10,30,400)
Guictrlsetfont(-1,12)
Guictrlsetstate(-1,$GUI_DISABLE)
Guictrlcreatepic(@scriptdir & "\*.jpg",310,10,130,38)
$mess = GuictrlcreateEdit("",10,70,430,150,$ES_LEFT)
Guictrlsetstate(-1,$GUI_DISABLE)
Guictrlcreatelabel(" For More Information please call * or write an Email to *",10,230,400)
Guictrlsetstate(-1,$GUI_DISABLE)
$exit = Guictrlcreatebutton("Okay, I've read !",160,270,120,25)
GUISetState(@SW_SHOW) ; Zeigt das leere GUI-Fenster
Guictrlsetdata($mess,$recv)
While 1
$msg = GUIGetMsg()
switch $msg
case $exit
test()
Guidelete()
Endswitch
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
Endfunc
Ach anders der soll einfach wenn das guideleted worden ist, wieder mit dem listen anfangen und abfragen ob er daten via. tcp bekommt un wenn dann wieder die gui. usw. usw.
aber sobald ichn guidelete mache geht das script aus. bzw wenn ich sage ruf die func nach dem del wieder auf. bleibts script zwar da aber es passiert nichts. sobald ich neu sende.