Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <GUIConstantsEx.au3>
- #include <MsgBoxConstants.au3>
- #include <Misc.au3>
- Local $hDLL = DllOpen("user32.dll")
- ; Start First clicking on "1. Server"
- ; Then start a second instance of the script selecting "2. Client"
- Example()
- Func Example()
- UDPStartup() ; Start the UDP service.
- ; Register OnAutoItExit to be called when the script is closed.
- OnAutoItExitRegister("OnAutoItExit")
- ; Assign Local variables the loopback IP Address and the Port.
- Local $sIPAddress = "192.168.1.92" ; This IP Address only works for testing on your own computer.
- Local $iPort = 65532 ; Port used for the connection.
- While 1
- ; Assign a Local variable the socket and bind to the IP Address and Port specified.
- Local $iSocket = UDPBind($sIPAddress, $iPort)
- ; Assign a Local variable to store the data received.
- Local $sReceived = ""
- Local $mousePosX = 0
- Local $mousePosY = 0
- Local $moveGap = 20
- Local $mouseSpeed = 2
- Do
- ; We are waiting for the string "toto" OR "tata" (example script UDPSend): 4 bytes length.
- $sReceived = UDPRecv($iSocket, 2)
- Until $sReceived <> ""
- ; Notes: If you don't know how much length will be the data,
- ; use e.g: 2048 for maxlen parameter and call the function until the it returns nothing/error.
- While 1
- $sReceived = UDPRecv($iSocket, 2) ;we're waiting for the string "tata" OR "toto" (example script TCPRecv): 4 bytes length.
- If $sReceived = "ta" Then
- MouseMove(700, 700, 20)
- EndIf
- If $sReceived = "up" Then
- $mousePosY = $mousePosY - $moveGap
- MouseMove($mousePosX, $mousePosY, $mouseSpeed)
- EndIf
- If $sReceived = "dn" Then
- $mousePosY = $mousePosY + $moveGap
- MouseMove($mousePosX, $mousePosY, $mouseSpeed)
- EndIf
- If $sReceived = "le" Then
- $mousePosX = $mousePosX - $moveGap
- MouseMove($mousePosX, $mousePosY, $mouseSpeed)
- EndIf
- If $sReceived = "ri" Then
- $mousePosX = $mousePosX + $moveGap
- MouseMove($mousePosX, $mousePosY, $mouseSpeed)
- EndIf
- If $sReceived = "dc" Then
- MouseClick("left", $mousePosX, $mousePosY, 2) ;mouse double click
- EndIf
- If $sReceived = "rc" Then
- MouseClick("right", $mousePosX, $mousePosY, 1) ;mouse double click
- EndIf
- WEnd
- ; Close the socket.
- UDPCloseSocket($iSocket)
- WEnd
- #EndRegion GUI
- EndFunc ;==>Example
Add Comment
Please, Sign In to add comment