200 posts in this topic
In my work place they blocked the application movemouse. so y decided to do one by myself , to cheat the system.
I have used some peaces of code from another scripts I have, and also I have found in this forum
Hope this helps
$version="0.2" #include <Misc.au3> If _Singleton(@ScriptName, 1) = 0 Then ; allow only one instance MsgBox(0, "Warning", "An occurence of " & @ScriptName & " is already running") Exit EndIf #region tray icon #NoTrayIcon Opt("TrayIconHide", 0) Opt("TrayMenuMode", 1) TraySetToolTip("Ratoner "& $version) Local $exititem = TrayCreateItem("Exit") TraySetState(1) ; Show the tray menu. #endregion #region variables $BlockScreensaver=1 $flagMouse=1 $MouseNotMovedCounter=0 $posMouseMovedX=0 $posMouseMovedY=0 $Counter= 0 #endregion #region main Local $hTimer = TimerInit() while 1 $Counter=$Counter+1 if $Counter>1000 then CheckifMouseMove() if $MouseNotMovedCounter>2 then moveMouse() $Counter= 0 endif Switch TrayGetMsg() Case $exititem exit EndSwitch sleep(50) wend #endregion #region functions func CheckifMouseMove() ;~ ConsoleWrite("+CheckifMouseMove()" & @crlf) $posMouseMoved = MouseGetPos() if $posMouseMovedX<>$posMouseMovedor $posMouseMovedY <> $posMouseMoved then $posMouseMovedX=$posMouseMoved $posMouseMovedY=$posMouseMoved $MouseNotMovedCounter=0 ;~ ConsoleWrite('>$MouseNotMovedCounter = ' & $MouseNotMovedCounter & @crlf ) Else ;$MouseMoved=0 $MouseNotMovedCounter=$MouseNotMovedCounter+1 ;~ ConsoleWrite('--$MouseNotMovedCounter = ' & $MouseNotMovedCounter & @crlf ) endif EndFunc func moveMouse() ;~ ConsoleWrite("+moveMouse" & @crlf) Local $posMouse = MouseGetPos() $flagMouse=$flagMouse*-1 Local $new_y = $posMouse + $flagMouse ; + (10*$flagMouse) MouseMove($posMouse,$new_y) $MouseNotMovedCounter=0 ;~ ConsoleWrite("+mouseMove $MouseNotMovedCounter" & $MouseNotMovedCounter & @crlf) endfunc #endregion
I'm really new to AutoIT, and I have little experience with scripting or any sort of programming. But I'm trying to learn!
Right now, what I'm trying to do is make a quick script that repeats a few functions while a key is held down. I want to see if I can make a quick-burst script that might work in Fallout 4 with machine guns
#include <Misc.au3> $dll = DllOpen("user32.dll") While 1 Sleep(100) If _IsPressed("01", $dll) Then MouseDown("left") Sleep(320) MouseUp("left") Sleep(25) EndIf WEnd DllClose($dll) Right now, when I hold down my left mouse button, it just repeats the script once - then I have to release and hold again to enable it again. Is it possible to to start it from the top and basically just repeats itself while I'm holding down my mouse button?
In advance, thank you!
I want that when mouse cursor is in GUI, cursor would hide, and when cursor is outside GUI it would appear again.
(Sorry for my bad English)
Searching inside the forum, I don't succeed to get any explanation about a strange (for me !) phenomena:
Using AutoIt, I have coded a "cortex of neurons Simulator" for which I handle several neurons activity (Action Potential and Postsynaptic Potential) which take a long time, about 20 ms per neuron to be processed. This is why I need a global loop running about 1s for a global cortex of 50 neurons.
But when I move the mouse (in any direction, like rotating above the GUI) the speed of the loop increase significantly : around x8 times more ... !
This happens only if the GUI has the focus. I did a check with the "Windows Task Manager" where I can see the CPU usage changing every time the mouse is moving (growing from 3% to 15%).
I believe to remember some lecture about the influence of the user events regarding the "Application" capability to anticipate user actions by changing it's rate of pooling events, but I'm not sure it was in an AutoIt forum, or maybe it was in an other "developer forum" (like "Code Project", "Stackoverflow" , or ...?
Could somebody help me to understand this behaviour ?
If possible, is there a programmatic method to manage the speed of a simple "For, Next" loop ? I try to change the Application priority (setting to level 4 with "ProcessSetPriority"), but this seems not very efficient ....
FYI: I'm using :
Autoit 22.214.171.124 Windows 7 Home Premium Service Pack 1 Computer ASUS N56V Screen resolution: 1920x1080 (recommended) Theme :Windows Classic
I'm gonna share this UDF I made today.
It allows you to easily create TCP servers and set actions depending on three events: OnConnect, OnDisconnect and OnReceive.
It is also multi client (you can set the clients limit) and you can also bind a Console-based executable to the socket (similar to -e parameter in NetCat). This feature is useful if you want to use some Console UDF to create your TCP server and don't want to mix it with the TCP functions. Also, as it runs on background just firing events, it won't pause your script while listening/receiving, so you can do anything else (stop and restart the server, allow the user to click buttons or just wait on an infinite loop) that your callbacks will be called once the event is fired.
It's also very easy to use. See this examples:
Example #1: A basic server
By running this (then connecting to the server using Netcat), you will receive a message box telling you when some user connects or disconnects (the socket ID and his IP address is passed as parameter to your callback function) and also when the user sends something over the TCP socket (the data sent is passed as parameter).
#cs Download netcat at https://eternallybored.org/misc/netcat/ Execute this script Run in CMD: nc -vv 127.0.0.1 8081 #ce #include "TCPServer.au3" ; First we set the callback functions for the three events (none of them is mandatory) _TCPServer_OnConnect("connected") _TCPServer_OnDisconnect("disconnect") _TCPServer_OnReceive("received") ; And some parameters _TCPServer_DebugMode(True) _TCPServer_SetMaxClients(10) ; Finally we start the server at port 8081 at any interface _TCPServer_Start(8081) Func connected($iSocket, $sIP) MsgBox(0, "Client connected", "Client " & $sIP & " connected!") _TCPServer_Broadcast('new client connected guys', $iSocket) _TCPServer_Send($iSocket, "Hey! Write something ;)" & @CRLF) _TCPServer_SetParam($iSocket, "will write") EndFunc ;==>connected Func disconnect($iSocket, $sIP) MsgBox(0, "Client disconnected", "Client " & $sIP & " disconnected from socket " & $iSocket) EndFunc ;==>disconnect Func received($iSocket, $sIP, $sData, $sPar) MsgBox(0, "Data received from " & $sIP, $sData & @CRLF & "Parameter: " & $sPar) _TCPServer_Send($iSocket, "You wrote: " & $sData) _TCPServer_SetParam($iSocket, 'will write again') EndFunc ;==>received While 1 Sleep(100) WEnd Example #2: A basic HTTP server (just one page, as it is just an example)
In this example, we run this code and point our browser to the address mentioned on the comments. A basic "It works!" page is show.
#cs Run this script Point your browser to http://localhost:8081/ #ce #include "TCPServer.au3" _TCPServer_OnReceive("received") _TCPServer_DebugMode(True) _TCPServer_SetMaxClients(10) _TCPServer_Start(8081) Func received($iSocket, $sIP, $sData, $sParam) _TCPServer_Send($iSocket, "HTTP/1.0 200 OK" & @CRLF & _ "Content-Type: text/html" & @CRLF & @CRLF & _ "<h1>It works!</h1>" & @CRLF & _ "<p>This is the default web page for this server.</p>" & @CRLF & _ "<p>However this server is just a 26-lines example.</p>") _TCPServer_Close($iSocket) EndFunc ;==>received While 1 Sleep(100) WEnd Example #3: A telnet-like server (Command Prompt bound to the socket after password requesting)
By running this example and connecting with Netcat, we will be asked for a password, which is 12345 as we set on the script. If the password is correct, we will see the Command Prompt live-updated (try running a ping to some server, for example).
#cs Download netcat at https://eternallybored.org/misc/netcat/ Execute this script Run in CMD: nc -vv 127.0.0.1 8081 #ce #include "TCPServer.au3" Global $sPassword = "12345" ; input server password here _TCPServer_OnConnect("connected") _TCPServer_OnDisconnect("disconnect") _TCPServer_OnReceive("received") _TCPServer_DebugMode(True) _TCPServer_SetMaxClients(10) _TCPServer_Start(8081) Func connected($iSocket, $sIP) _TCPServer_Send($iSocket, "Welcome! Please input password: ") _TCPServer_SetParam($iSocket, 'login') EndFunc ;==>connected Func disconnect($iSocket, $sIP) MsgBox(0, "Client disconnected", "Client " & $sIP & " disconnected from socket " & $iSocket) EndFunc ;==>disconnect Func received($iSocket, $sIP, $sData, $sParam) If $sParam = "login" Then If $sData <> $sPassword Then _TCPServer_Send($iSocket, "Wrong password. Try again: ") Return Else _TCPServer_SetParam($iSocket, 'command') _TCPServer_BindAppToSocket($iSocket, 'cmd.exe') EndIf ElseIf $sParam = "command" Then _TCPServer_SendToBound($iSocket, $sData) EndIf EndFunc ;==>received While 1 Sleep(100) WEnd The limit is your imagination? Well, no sure. We have this limit:
You can't create more than one server with this UDF in the same script. However, you can pause and resume (read 'stop and start again') your server at any time in your script, without having to reset the server settings. And of course you can have many clients (or just one, it's your choice!) in the same server. Or run multiple instances. Functions list:
Help file and more examples included!
Latest version: 126.96.36.199
Download: TCPServer UDF.rar
1.0 - First release - 18/04/2015 188.8.131.52 - Bug fix __TCPServer_Accept internal function / help file recompiled - 26/04/2015 Perhaps you will need to uncompress the file first, so the help file will work.
Fork this on Github: http://github.com/jesobreira/TCPServerUDF