dc740 / autohotpy Goto Github PK
View Code? Open in Web Editor NEWAutoHotKey replacement using Incerception driver
License: GNU Lesser General Public License v3.0
AutoHotKey replacement using Incerception driver
License: GNU Lesser General Public License v3.0
Hi! That's a really great tool.
But i have a question: can I sen keys to inactive window, e.g. show AutoHotPy hwnd to which i want send keys?
Thanks!
Guys, i need your help, i cannot understand how can i call left button mouse click not binding it to any button.
I have this:
def exitAutoHotKey(autohotpy, event):
"""
exit the program when you press ESC
"""
autohotpy.stop() # makes the program finish successfully. Thisis the right way to stop it
def superCombo(autohotpy, event):
stroke = InterceptionMouseStroke()
stroke.state = InterceptionMouseState.INTERCEPTION_MOUSE_RIGHT_BUTTON_DOWN
autohotpy.sendToDefaultMouse(stroke)
stroke.state = InterceptionMouseState.INTERCEPTION_MOUSE_RIGHT_BUTTON_UP
autohotpy.sendToDefaultMouse(stroke)
if name == "main":
auto = AutoHotPy() # Initialize the library
auto.registerExit(auto.ESC, exitAutoHotKey)
auto.registerForKeyDown(auto.A, superCombo)
auto.start() # Now that everything is registered we should start runnin the program
When i press A, everithing is working, right mouse button is pushed. But i want to do this not pushing A or any button, but just calling the function superCombo(). How can i do this?
I call function ==> left click is working (once or in endless loop, that doesnt matter).
Hi!
\AutoHotPy.py", line 103, in init
self.kb_queue = Queue.Queue()
AttributeError: 'function' object has no attribute 'Queue'
what could be the cause of the error?
Hello, I studied multiprocessing, but I could not find complex examples to study this topic well. Now I have an idea of how you run the macro in AutoHotPy.py, and after reading the code from AutoHotPy.py, I discovered how you can run the macro using this method.
I found this function here.
def fireLastRecordedMacro(self):
self.recording_macro = False
self.macro_queue.put(Task(self,self.runMacro,self.last_macro))
I realized that it runs a macro, which is written to last_macro (my guess). After that, I tried to understand what is written in last_macro after recording the macro through the macroStartStop () function using
print (self.last_macro)
But, alas, it gives me information about InterceptionWrapper.InterceptionMouseStroke and its object, because last_macro is specified in def __init __ (self)
.
Sample message from print (self.last_macro)
:
[(1558182004.8547325, <InterceptionWrapper.InterceptionMouseStroke object at 0x00000129F8942E48>),
(1558182004.8608642, <InterceptionWrapper.InterceptionMouseStroke object at 0x00000129F8942EC8>),
(1558182004.8618531, <InterceptionWrapper.InterceptionMouseStroke object at 0x00000129F8942DC8>),
(1558182004.8669028, <InterceptionWrapper.InterceptionMouseStroke object at 0x00000129F8B95248>)]
I tried to translate last_macro to __str__, __repr__, __dict__
(failed)
You may have some recommendations.
I've got a setup with 3 monitors where my primary monitor is in the middle. I have a loop that's something like:
def get_mouse_position():
pos = autohotpy.getMousePosition()
return {'x': pos[0], 'y': pos[1]}
while True:
time.sleep(0.01)
mouse = get_mouse_position()
message = "\rMouse is at x: {}, y: {}".format(mouse['x'], mouse['y']) + ' ' * 10
print(message, end='', flush=True)
sys.stdout.flush()
This shows that on my primary monitor, the mouse coordinates range from:
x:0 -> x:1919
y:0 -> y:1199
Which makes sense, considering the monitor is 1920 x 1200.
If I go to my left-most monitor, the x
values returned are negative, from -1
to -3840
which makes sense because it is a 4k monitor. The y
values only go to 864 though, which is odd.. Not sure if that is due to UI scaling?
Anyways, given all this, if I do:
autohotpy.moveMouseToPosition(500, 500)
I would expect it to land in the same spot where my loop above would show 500,500.
What actually happens is the mouse ends up on my leftmost monitor at -3040, 360
.
Do you have any idea why this is happening?
This is on a Windows 10 environment.
Hey,
I'm coming over from C++ to Python to write a simple bot for Lineage II. I'm using this AutoHotPy because the game blocks artificial input and I'm hoping this could fix this. Problem is, I'm getting a lot of different errors (some I've fixed and some are beyond my knowledge at the moment). As a last attempt, I'm trying this.
The error is:
Game window found.
Traceback (most recent call last):
File "C:\Users\klaud\source\repos\ClaudBot\main.py", line 88, in
main()
File "C:\Users\klaud\source\repos\ClaudBot\main.py", line 77, in main
action.attack()
File "C:\Users\klaud\source\repos\ClaudBot\main.py", line 61, in attack
self.autohotpy.moveMouseToPosition(x, y)
AttributeError: 'Bot' object has no attribute 'autohotpy'
I'm not sure how to fix this, maybe someone could help? Attaching zip file.
main.zip
Offtopic: I've learned a hella lot of Python these couple of days.
Hi. Thank You for your job. I find one problem.
Description Bug:
Expected Result: The script stopped
Actual Result: The script continues to run. And now I can't stop the macros by pressing on F1. And can't stop script by pressing Escape. I can't move cursor mouse.
The macro continues to run indefinitely. Computer control lost.
I can only press "reset"
C:\Users\MagusDickus\Downloads\AutoHotPy-master\AutoHotPy-master>python3 Example1-GameCombo.py
Traceback (most recent call last):
File "C:\Users\MagusDickus\Downloads\AutoHotPy-master\AutoHotPy-master\Example1-GameCombo.py", line 50, in
auto.start() #Now that everything is registered we should start runnin the program
File "C:\Users\MagusDickus\Downloads\AutoHotPy-master\AutoHotPy-master\AutoHotPy.py", line 546, in start
self.interception = InterceptionWrapper()
File "C:\Users\MagusDickus\Downloads\AutoHotPy-master\AutoHotPy-master\InterceptionWrapper.py", line 171, in init
self.interceptionDll = ctypes.WinDLL ("./interception.dll")
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\ctypes_init_.py", line 374, in init
self._handle = _dlopen(self._name, mode)
OSError: [WinError 193] %1 is not a valid Win32 application
hello
Anyway to bypass the above problem just trying to run your examples?
I'm not a programmer, but I do need to enable sleep timers in the automatic macro example. I have tried for days and cannot do it. Can you implement that into the example or tell me how to do it? I have read the other comments here but I will probably need to see it before I can understand it. I don't know how else to ask besides right here.
Hello, thank your for this great program, I am trying to improve the speed of the mouse, and I was doing some tests to find somehow where is the part where the speed of the mouse does not reproduce the actual times of the original ones.
My first impression was that maybe at the AutoHotpy.py,
the time.sleep(interval) is a little bigger than the original ones.
I have tried to reduce the time.sleep(interval) for example, 0.0001*interval
in the part in the runMacro definition
self.sleep(getTimeDifference(last_time,event[0])) #wait before firing the event
To see if this can reduce the overall running time of the program, but unfortunately, this does not increase the speed.
Do you know at which point can I control the speed of the program,
or in which part of the program maybe there is a bottleneck that makes the program makes the reproduction not exactly with the same times of the recording.
Any hint or suggestion is welcomed. In this way, I can try to find a small improvement in this part.
I need to reproduce the recording with the same times as the real ones.
Best regards
Ruslan
Traceback (most recent call last):
File "", line 1, in
File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.3.3\plugins\python-ce\helpers\pydev_pydev_bundle\pydev_umd.py", line 197, in runfile
pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.3.3\plugins\python-ce\helpers\pydev_pydev_imps_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "C:/Users/klaud/source/repos/ClaudBot/main.py", line 69, in
auto = AutoHotPy()
File "C:\Users\klaud\source\repos\ClaudBot\venv\lib\site-packages\AutoHotPy\AutoHotPy.py", line 98, in init
self.user32.GetCursorPos.restype = ctypes.POINTER(Point)
NameError: name 'Point' is not defined
How do I solve this?
main.zip
Actually the problem is shown in the screenshot, when saving the macro, the coordinates are saved incorrectly because of its launch, the mouse flies to the edge of the monitor. Help please, very necessary thing, but does not work. Pure recording and playback work fine, but saving doesn't play well. I hope for your support.Actually the problem is shown in the screenshot, when saving the macro, the coordinates are saved incorrectly because of its launch, the mouse flies to the edge of the monitor. Help please, very necessary thing, but does not work. Pure recording and playback work fine, but saving doesn't play well. I hope for your support.
Hey. How can I call a function with a macro without pressing a key? I experimented quite a lot with the code, and everything was not crowned with success. I would be grateful for the help.
When I run scripts, I get similar errors:
Traceback (most recent call last):
File "C:\Users\Alex\AppData\Local\Programs\Python\Python37\Tools\scripts\Example1-GameCombo.py", line 51, in
auto.start() #Now that everything is registered we should start runnin the program
File "C:\Users\Alex\AppData\Local\Programs\Python\Python37\Tools\scripts\AutoHotPy.py", line 554, in start
self.interception.interception_set_filter(self.context, self.interception.interception_is_keyboard, InterceptionFilterKeyState.INTERCEPTION_FILTER_KEY_ALL);
File "C:\Users\Alex\AppData\Local\Programs\Python\Python37\Tools\scripts\InterceptionWrapper.py", line 210, in interception_set_filter
return self.interceptionDll.interception_set_filter(context, predicate, filter1)
ctypes.ArgumentError: argument 1: <class 'OverflowError'>: int too long to convert
What am I doing wrong?
Hi. How to simulate a keystroke, for example, key 1?
Hello I'm getting this error when I try to run Example-GameCombo.py and others Examples.
Traceback (most recent call last):
File "C:\Python\AutoHotPy-master\Example1-GameCombo.py", line 51, in
auto.start() #Now that everything is registered we should start runnin the program
File "C:\Python\AutoHotPy-master\AutoHotPy.py", line 546, in start
self.interception = InterceptionWrapper()
File "C:\Python\AutoHotPy-master\InterceptionWrapper.py", line 171, in init
self.interceptionDll = ctypes.WinDLL ("./interception.dll")
File "C:\Python27\lib\ctypes_init_.py", line 362, in init
self._handle = _dlopen(self._name, mode)
WindowsError: [Error 126] The specified module could not be found.
UPD: issue fixed by installing python 2.7 x64
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.