Code Monkey home page Code Monkey logo

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

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!

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

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?

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.

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.

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"

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

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

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.

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.

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?

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.