GithubHelp home page GithubHelp logo

autohotpy's Introduction

AutoHotPy

It started as an AutoHotKey replacement using Incerception driver, but now its a fully working automation tool. You can record activities to repeat them, or you can manually program them.

FAQ

Why? just... why?

AutoHotKey is great, but many games and programs don't work with it. And the ones that work have many counter-measures to stop it (because many script kiddies use it to cheat!). I'm against cheating in games, but I'm also against discrimination. Many players have different kinds of disabilities, and they need helping tools to play. I believe everyone deserves the right to choose which game, or program they want to use without limitations.

How is it different?

AutoHotPy is a scripting tool, just like AutoHotKey, but it uses Interception library (https://github.com/oblitum/Interception). The great thing is that Interception uses a very low level driver to capture keyboard and mouse events, which makes it perfect for games that have problems with AutoHotKey

Why python?

Because when you write AutoHotPy scripts, you learn a real programming language that you can later use to write your own programs.

Installation

AutoHotPy doesn't really need any. You just place the scripts in the same folder and they just work. However, the libraries needed for it to run are not installed by default in any operative system.

  1. Verify you have Python installed, if not, please install python to proceed
  2. Install interception driver (and restart your computer): http://oblita.com/Interception.html hint: if double clicking in the executable doesn't install the driver (you will see an error message when you start AutoHotPy), try running a command line as administrator from the windows menu (right clicking on the program and selecting "Run as administrator"), and then go to your download location from the command line and run "install-interception.exe /install"
  3. Place the .dll in the same place were you downloaded AutoHotPy. We need interception.dll to work!

Intro

Python is a real programming language, so remember: everything you learn while you write the scripts can be used to write your own programs! To use AutoHotPy you only have to write a script (patience!) and place it in the same folder where you installed the app. I will add more documentation later but lets get you working fast.

Open "Example1-GameCombo.py". The first paragraph is the license, you don't need it in your scripts. Follow the comments (everything that is placed after #) to understand what's happening.

"Example2-MultipleKeys.py": this example shows how to handle multiple keys pressed at the same time. The example opens the windows task manager (in windows 7) directly when you hit Ctr+Alt+Supr instead of taking you to the options screen. The trick is to remap Ctrl+Alt+Supr to Ctrl+Shift+Escape (that opens the task manager directly) There is literally no limit on how many pressed keys you can handle from AutoHotPy, but that doesn't mean the operative system won't have his own limitations.

"Example3-MouseButtons.py": Handling mouse movement and clicks is the hardest part in AutoHotPy, but because you have to do each movement or click manually.

"Example4-MouseMovement.py": Invert mouse axis

"Example5-Macros.py": Shows how to record macros for keyboard and mouse

"Example6-Macros2 - Gaming macros.py": Shows how to record macros for games, where the mouse starting position is important for the macro to success.

"Example7-Macros3 - Saving macro to file.py": the title is quite descriptive.

"Example8-Macros4 - Auto-repeating macros.py": what if you want to always repeat a macro in a game. Imagine something very boring, like a fishing in Argentum Online: U.press() -> click on water... repeat until you get tired, or bored. This example shows you how to repeat a macro automatically, until you disable it again, of course.

"Example9-Macros5 - Record mouse only.py": You can record a macro saving only mouse activity if you want. when you replay it, it will start from the first keyboard event automatically, and your gestures will me repeated, ignoring all mouse activity.

"Example10-Macros6 - Record keyboard only.py": Same as Example9, but this time the mouse is ignored and we only record the keyboard activity.

IMPORTANT NOTE: Known bugs:

  • the script crashes after saving a macro to a file and then trying to run the macro again. Workaround: restart the application after saving a macro to a file.

Running the scripts

To run any of the scripts open a command line and run "python .py". That's all you need.

Be patient! Don't panic if you need help with the language, there are many python developers around the world. You will find help in any language you can image.

Copyright 2012-2019 Emilio Moretti <emilio.morettiATgmailDOTcom> This program is distributed under the terms of the GNU Lesser General Public License.

autohotpy's People

Contributors

dc740 avatar fedyuninv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

autohotpy's Issues

WinError 193

I keep getting this error while trying to run the examples, i have tried to reinstall python and interception but it didn't work

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

Unable to create threads

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.

mouse click that called from function

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).

moveMouseToPosition() doesn't move mouse to correct position

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.

AttributeError: 'Bot' object has no attribute 'autohotpy'

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.

Activate Macro Without Key 2

#6

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.

Python 3: Queue import error

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?

Mouse speed is not real- it is very slow.

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

Please, help. <class 'OverflowError'>: int too long to convert

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?

Activate Macro Without Key

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.

Inactive window

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!

Recording a macro to a file does not work well.

image
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.

Loss of control over a computer when a macro is playing

Hi. Thank You for your job. I find one problem.

Description Bug:

  1. I run script Example8-Macros4 - Auto-repeating macros.py
  2. Press F1 for macros start playng. I see in console sequence ABCABCABC....
  3. Press Escape

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"

Point is not defined in AutoHotPy.py

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

WindowsError: [Error 126] The specified module could not be found.

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.