Advertisement
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.108" ; 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 connect to a listening socket with the IP Address and Port specified.
- Local $iSocket = UDPOpen($sIPAddress, $iPort)
- Local $defaultKeyRepeatTime = 50
- While 1
- If _IsPressed("68", $hDLL) Then ;up key
- While _IsPressed("68", $hDLL)
- Sleep($defaultKeyRepeatTime)
- UDPSend($iSocket, StringToBinary("up")) ;move mouse up
- WEnd
- EndIf
- If _IsPressed("62", $hDLL) Then ;down key
- While _IsPressed("62", $hDLL)
- Sleep($defaultKeyRepeatTime)
- UDPSend($iSocket, StringToBinary("dn")) ;move mouse down
- WEnd
- EndIf
- If _IsPressed("64", $hDLL) Then ;left key
- While _IsPressed("64", $hDLL)
- Sleep($defaultKeyRepeatTime)
- UDPSend($iSocket, StringToBinary("le")) ;move mouse left
- WEnd
- EndIf
- If _IsPressed("66", $hDLL) Then ;right key
- While _IsPressed("66", $hDLL)
- Sleep($defaultKeyRepeatTime)
- UDPSend($iSocket, StringToBinary("ri")) ;move mouse right
- WEnd
- EndIf
- If _IsPressed("67", $hDLL) Then ;space key
- While _IsPressed("67", $hDLL)
- Sleep($defaultKeyRepeatTime)
- WEnd
- UDPSend($iSocket, StringToBinary("dc")) ;mouse double click
- EndIf
- If _IsPressed("69", $hDLL) Then ;space key
- While _IsPressed("69", $hDLL)
- Sleep($defaultKeyRepeatTime)
- WEnd
- UDPSend($iSocket, StringToBinary("rc")) ;mouse double click
- EndIf
- Sleep(50)
- WEnd
- ; Close the socket.
- UDPCloseSocket($iSocket)
- WEnd
- #EndRegion GUI
- EndFunc ;==>Example
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement