paulie-g / autopy2 Goto Github PK
View Code? Open in Web Editor NEWThis project forked from autopilot-rs/autopy-legacy
A simple, cross-platform GUI automation toolkit for Python.
Home Page: www.autopy.org
License: Other
This project forked from autopilot-rs/autopy-legacy
A simple, cross-platform GUI automation toolkit for Python.
Home Page: www.autopy.org
License: Other
Issue by cool-RR
Wednesday Jul 25, 2012 at 22:36 GMT
Originally opened as autopilot-rs#36
When I try to use Autopy to move the mouse to any monitor except my primary, I get "ValueError: Point out of bounds:.
Is Autopy able to move the mouse to multiple monitors?
Issue by nickehallgren
Saturday Jan 24, 2015 at 17:15 GMT
Originally opened as autopilot-rs#65
Hi,
I installed autopy on debian 7 using your instructions (compile from git)) and the Hello World example works but when I try to send CTRL + 1 I get an error, this is my code:
import autopy, time
def key_demo():
autopy.key.toggle('1', True, autopy.key.MOD_CONTROL)
time.sleep(2)
autopy.key.toggle('1', False, autopy.key.MOD_CONTROL)
def hello_there_world():
autopy.alert.alert("Hello, world")
hello_there_world()
key_demo()
and the result is this:
Traceback (most recent call last):
File "autopy_demo.py", line 12, in
key_demo()
File "autopy_demo.py", line 4, in key_demo
autopy.key.toggle('1', True, autopy.key.MOD_CONTROL)
TypeError: argument 1 must be integer or char, not str
I'm pretty sure I have used the same code in another project so can this be that some library or something is missing?
Issue by gitfoxi
Saturday Mar 21, 2015 at 00:27 GMT
Originally opened as autopilot-rs#66
mouse.click works great. But i can't figure out how to do a double-click. I've tried various ways. I'm on the mac platform.
for _ in range(times):
print "calling mouseclick"
mouse.toggle(True, button)
# sleep(0.1)
mouse.toggle(False, button)
# sleep(0.1)
For example, this doesn't work with or without the sleep calls.
I'd also be interested in being able to click and hold to drag a window for example.
If you want to try dragging then you might try something like mouse.toggle(True)
and then later mouse.toggle(False)
. This does not have the effect of dragging the window smoothly. The window does jump from where it was to Where the mouse is when you you called the second toggle.
Issue by gitfoxi
Thursday Apr 02, 2015 at 23:37 GMT
Originally opened as autopilot-rs#71
Using the method key_tap
, it seems like all of the normal keys are getting passed through from my Mac host to my Linux guest using virtual box. But none of the modifier keys – control, option, shift, command – seem to get passed through. Does anyone know why that could be?
Issue by cool-RR
Thursday Jan 16, 2014 at 16:55 GMT
Originally opened as autopilot-rs#45
I'd really love for my autopy
scripts to be run under Python 3 instead of Python 2. If autopy
could support Python 3, that's be great.
Issue by Bechsen
Tuesday Jul 15, 2014 at 19:59 GMT
Originally opened as autopilot-rs#54
Im trying to detect the color at at special point, however trying to use screen.get_color(x,y) just returns a 0 when i was expecting a hexidecimal, is there a fix for this?
Issue by jner14
Thursday Jun 05, 2014 at 22:37 GMT
Originally opened as autopilot-rs#50
I get this error when trying to build it. I've tried it on both a Windows 7 and 8 machine. Both 64bit. It's the same error as issue 24 autopilot-rs#24 but I tried installing Visual Studio 2008 Express and it didn't help.
gcc: error: user32.lib: No such file or directory
gcc: error: Gdi32.lib: No such file or directory
D:\Software Development\Anaconda\Scripts\dllwrap.bat....\MinGW\bin\dllwrap.exe: D:\Software Development\Anaconda\Scripts\dllwrap.bat....\MinGW\bin\gcc exited with status 1
Issue by bmcarter
Tuesday Feb 04, 2014 at 22:28 GMT
Originally opened as autopilot-rs#46
Quick fix for Mac OS users.
bmcarter included the following code: https://github.com/msanders/autopy/pull/46/commits
Issue by mherkazandjian
Thursday Sep 10, 2015 at 13:34 GMT
Originally opened as autopilot-rs#76
running build
running build_py
running build_ext
building 'screen' extension
gcc -fno-strict-aliasing -I/progs/anaconda/anaconda/include -arch x86_64 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -DNDEBUG=1 -DMM_LITTLE_ENDIAN -DIS_MACOSX -I/progs/anaconda/anaconda/include/python2.7 -c src/autopy-screen-module.c -o build/temp.macosx-10.5-x86_64-2.7/src/autopy-screen-module.o -Wall -Wparentheses -Winline -Wbad-function-cast -Wdisabled-optimization -Wshadow
gcc -fno-strict-aliasing -I/progs/anaconda/anaconda/include -arch x86_64 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -DNDEBUG=1 -DMM_LITTLE_ENDIAN -DIS_MACOSX -I/progs/anaconda/anaconda/include/python2.7 -c src/screen.c -o build/temp.macosx-10.5-x86_64-2.7/src/screen.o -Wall -Wparentheses -Winline -Wbad-function-cast -Wdisabled-optimization -Wshadow
In file included from /usr/include/dispatch/dispatch.h:51:0,
from /System/Library/Frameworks/CoreFoundation.framework/Headers/CFStream.h:15,
from /System/Library/Frameworks/CoreFoundation.framework/Headers/CFPropertyList.h:13,
from /System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:55,
from /System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:19,
from /System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.h:23,
from src/screen.c:5:
/usr/include/dispatch/object.h:143:15: error: expected identifier or '(' before '^' token
typedef void (^dispatch_block_t)(void);
^
/usr/include/dispatch/object.h:362:3: error: unknown type name 'dispatch_block_t'
dispatch_block_t notification_block);
^
In file included from /usr/include/Availability.h:153:0,
from /System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.h:19,
from src/screen.c:5:
/System/Library/Frameworks/CoreServices.framework/Frameworks/FSEvents.framework/Headers/FSEvents.h:262:38: error: expected ',' or '}' before 'attribute'
kFSEventStreamCreateFlagIgnoreSelf OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_6_0) = 0x00000008,
^
/System/Library/Frameworks/CoreServices.framework/Frameworks/FSEvents.framework/Headers/FSEvents.h:414:38: error: expected ',' or '}' before '__attribute'
kFSEventStreamEventFlagItemCreated __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_6_0) = 0x00000100,
^
error: command 'gcc' failed with exit status 1
Issue by Kcmamu
Wednesday Nov 04, 2015 at 19:44 GMT
Originally opened as autopilot-rs#79
Fixed autopy.bitmap.capture_screen(rect) behavior on Windows. Wrong parameters order in BitBlt
function.
BitBlt signature on MSDN
Kcmamu included the following code: https://github.com/msanders/autopy/pull/79/commits
Issue by gitfoxi
Sunday Mar 22, 2015 at 16:27 GMT
Originally opened as autopilot-rs#67
Ubuntu 14.10
Python 2.7.8 (default, Oct 20 2014, 15:05:19)
Type "copyright", "credits" or "license" for more information.
In [3]: key.tap(key.K_DELETE, key.MOD_SHIFT)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-3-29f35e2471fe> in <module>()
----> 1 key.tap(key.K_DELETE, key.MOD_SHIFT)
TypeError: argument must be integer<H>, not int
In [4]: key.toggle(key.K_DELETE, True)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-4-a7e85dfd8e04> in <module>()
----> 1 key.toggle(key.K_DELETE, True)
TypeError: argument must be integer<H>, not int
In [5]: key.type_string("asdf")
In [6]: asdf
Issue by gitfoxi
Sunday Mar 22, 2015 at 17:52 GMT
Originally opened as autopilot-rs#68
In [2]: key.type_string("+=")
In [3]: ==
Issue by daluu
Wednesday Dec 31, 2014 at 04:50 GMT
Originally opened as autopilot-rs#63
Looking over current docs:
Issue/Item 1:
mouse.toggle(down, button=LEFT_BUTTON)
Holds down or releases the given mouse button in the current position. button can be LEFT_BUTTON, RIGHT_BUTTON, or CENTER_BUTTON. If no button is given, the left button is defaulted to.
Clarification to make: down should be a boolean, True = hold down, False = release up, based on similar doc for
key.toggle(key, down_or_up, [modifiers])
Holds down the given key or keycode if down_or_up is True, or releases it if not. Integer keycodes and modifiers should be taken from module constants (e.g., key.K_DELETE or key.MOD_META). If the given key is a character, it is automatically converted to a keycode corresponding to the current keyboard layout.
Issue/Item 2:
mouse.move(x, y) VS mouse.smooth_move(x, y)
There is some mention of this on the intro/tutorial readme page but not so much on the API docs page. May want to standardize the docs on both to say the same thing to the user to cause less confusion, for novices, etc.
Basically what I suggest to document is that for typical GUI automation (driving an app to do stuff or to test an app), one should use mouse.smooth_move() as it most realistically simulates a user mouse movement, and if mouse.move() doesn't seem to work, use smooth_move().
I say this because I prefer using most optimal/efficient method for (test) automation, but in a simple test using AutoPy to drive HTML5 drag & drop (http://html5demos.com/drag), when I have the coordinates of the source and target locations to perform it at, mouse.move() didn't work, or was too fast to trigger an OS/browser response for the drag & drop. Using smooth_move() worked nicely. On the otherhand, mouse.move() works fine if one does something like a right-click at a location, when I was debugging the issue.
Issue by lazybios
Thursday Apr 10, 2014 at 13:13 GMT
Originally opened as autopilot-rs#47
I have write a mouse control script by autopy module ,and it works well.But when I want to stop the script ,the problem is appear. I can't get the mouse focus ! when I move the mouse cursor,it will quickly return the before position.
Now I have to use shortcut key to launch a terminal to use command ps -aux | grep script.py
to get the script pid_num and use kill pid_num
to terminated the script. In addition,when the autopy script running the C-c
is doesn't works.
So how can I stop this script ! Is there a elegant sulution ?
Issue by pvilhelm
Friday Nov 23, 2012 at 00:09 GMT
Originally opened as autopilot-rs#38
Hi,
If two or more bitmaps u are searching for are on the same row, find_all_bitmaps will only find one.
Fix:
//++pointOffset.x;
//++pointOffset.y;
in bitmap_find.c
Cheers!
Issue by shula
Saturday Jun 01, 2013 at 15:34 GMT
Originally opened as autopilot-rs#42
"alert" doesn't work with unicode, but with current local encoding:
running python2.7.3, 64bit, from PythonWin,
autopy.alert.alert("thmhe איציק") # img 1
True
autopy.alert.alert(title=u"Hello, איציק", msg="string from pythonwin")
Traceback (most recent call last):
File "", line 1, in
UnicodeEncodeError: 'ascii' codec can't encode characters in position 7-11: ordinal not in range(128)
... (tried all kinds of unicode/utf - all gives errors) ...
Last test, non-unicode encoding, img 2:
autopy.alert.alert(title=s.encode('cp1255'), msg="string from pythonwin")
True
Issue by c24b
Friday Apr 17, 2015 at 14:13 GMT
Originally opened as autopilot-rs#72
/local/lib/python2.7/site-packages/autopy/bitmap.so: undefined symbol: png_set_longjmp_fn
Issue by msanders
Sunday Jan 10, 2010 at 23:11 GMT
Originally opened as autopilot-rs#2
E.g., the output of the following should be 'A':
key.toggle(key.K_SHIFT, True)
key.tap('a')
key.toggle(key.K_SHIFT, False)
But on OS X, it is merely 'a'.
This appears to be a bug with CGEventCreateKeyboardEvent(); see: http://lists.apple.com/archives/quartz-dev/2009/Dec/msg00067.html
Is there an alternative (Carbon, maybe?) function we can use in the meantime?
Issue by lecheel
Monday Feb 13, 2012 at 02:32 GMT
Originally opened as autopilot-rs#31
from PIL import Image
possible add following api for rect compare using native autopy instead PIL
def compare_rect((ax,ay),bmp_name):
im=Image.open(bmp_name)
rect = ((ax-1,ay-1),(im.size[0]+2,im.size[1]+2))
tst = bitmap.Bitmap.open(bmp_name)
scr = bitmap.capture_screen(rect)
pos = scr.find_bitmap(tst)
if pos:
return 1
else:
return 0
Issue by slremy
Monday Jun 27, 2011 at 14:46 GMT
Originally opened as autopilot-rs#22
Hi all, and thanks again for the time and brain power dedicated towards this project!
Now that I've pulled a more recent update, I noticed that another cast conversion warning/error exists in keycode.c.
error: invalid conversion from ‘void*’ to ‘const __CFData*’
I believe that this should be rectified with the following.
(CFDataRef) TISGetInputSourceProperty(currentKeyboard,
Issue by treeform
Thursday Feb 09, 2012 at 07:56 GMT
Originally opened as autopilot-rs#30
When setting mouse position in another screen ValueError: Point out of bounds happens.
Issue by rasteron
Tuesday Jul 15, 2014 at 16:20 GMT
Originally opened as autopilot-rs#53
When trying to use the bitmap.capture_screen() function, I'm getting this error and it crashes:
This application has requested the runtime to terminate it in an unusual way please contact the application's support
The screen grab still works though and it saves ok.
Setup: Win7/Python 2.5/MinGW
Issue by Chronnox
Monday Aug 02, 2010 at 19:29 GMT
Originally opened as autopilot-rs#15
Whenever I try to make a screen capture of a specific region I get a black bitmap.
It looks like rect = ((100,100),(100,200)) does not work properly.
Instead of going 100x,100y into the screen it goes backward i.e. the 100,100 is -100,-100.
But when I enter -100,-100 I get a "out of bound" error.
Issue by iulica
Sunday Jun 10, 2012 at 21:32 GMT
Originally opened as autopilot-rs#35
Fixed find_bitmap to give proper coordinates (not incremented by 1).
Fixed find_bitmap to work properly with rect parameter.
iulica included the following code: https://github.com/msanders/autopy/pull/35/commits
Issue by demanLiu
Tuesday Dec 16, 2014 at 07:52 GMT
Originally opened as autopilot-rs#61
when i imoprt autopy,then
import autopy.bitmap
ImportError: /usr/local/lib/python2.7/dist-packages/autopy/bitmap.so: undefined symbol: png_set_longjmp_fn
ldd /usr/local/lib/python2.7/dist-packages/autopy/bitmap.so
linux-vdso.so.1 => (0x00007fff57ffe000)
libpng12.so.0 => /lib/x86_64-linux-gnu/libpng12.so.0 (0x00007f954e7c2000)
libz.so.1 => /usr/local/lib/libz.so.1 (0x00007f954e5a9000)
libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007f954e273000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f954e055000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f954dc8f000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f954d988000)
libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007f954d769000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f954d565000)
/lib64/ld-linux-x86-64.so.2 (0x00007f954ec14000)
libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007f954d360000)
libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007f954d15a000)
i had installed libpng
Issue by frafra
Monday Feb 28, 2011 at 00:27 GMT
Originally opened as autopilot-rs#18
Would be very useful write code like this
screen.focus("Firefox")
name = screen.getNameByPos(100, 150)
screen.focus(name)
Issue by behrisch
Wednesday Dec 28, 2011 at 18:08 GMT
Originally opened as autopilot-rs#29
The coordinates of bitmaps found are always off by one in x and y direction,
best illustrated by the following code:
ARROW = autopy.bitmap.Bitmap.open("arrows.png")
print ARROW.find_bitmap(ARROW)
results in (1,1) instead of the expected (0,0) possibly due to
findBitmapInRectAt, which does 8ofr an unknown reason)
increment the point offset before return:
if (needleAtOffset(needle, haystack, pointOffset, tolerance)) {
++pointOffset.x;
++pointOffset.y;
*point = pointOffset;
return 0;
this has the additional side effect, that the find all bitmaps code does not work properly since it does not find identical bitmaps with the same y coordinate because it starts looking at the coordinates returned by the code above.
Issue by avi
Wednesday Jan 27, 2010 at 17:28 GMT
Originally opened as autopilot-rs#12
I hope this is quicker than forking/submitting a patch
please add TAB to the list of keys supported by autopy
keycode.h: K_TAB = kVK_Tab
keycode.h: K_TAB = XK_Tab
keycode.h: K_TAB = VK_TAB
autopy-key-module.c: PyModule_AddIntMacro(mod, K_TAB) < 0 ||
Issue by hwong
Monday Sep 23, 2013 at 14:26 GMT
Originally opened as autopilot-rs#44
Fix for Windows mouse movement coordinate rounding described in autopilot-rs#28
hwong included the following code: https://github.com/msanders/autopy/pull/44/commits
Issue by Kian-Huang
Tuesday Jun 02, 2015 at 08:44 GMT
Originally opened as autopilot-rs#73
at autopy/src/mouse.c, line 34 and 35.
this method
#elif defined(IS_WINDOWS)
point.x = point.x * 0xFFFF / GetSystemMetrics(SM_CXSCREEN);
point.y = point.y * 0xFFFF / GetSystemMetrics(SM_CYSCREEN);
would be more precise then
#elif defined(IS_WINDOWS)
point.x *= 0xFFFF / GetSystemMetrics(SM_CXSCREEN);
point.y *= 0xFFFF / GetSystemMetrics(SM_CYSCREEN);
Issue by gitfoxi
Sunday Mar 22, 2015 at 17:59 GMT
Originally opened as autopilot-rs#69
Probably not tricky to implement except for Linux which does it several different ways depending on desktop and whether you're in a terminal.
Issue by daluu
Wednesday Dec 31, 2014 at 00:24 GMT
Originally opened as autopilot-rs#62
bmp.to_string() and bitmap.Bitmap.from_string(string)
http://www.autopy.org/documentation/api-reference/bitmap.html
https://github.com/msanders/autopy/#readme
The current documentation/tutorial doesn't make it clear to me. I had assumed the string is base 64. But trying out this tool/library and comparing to other base 64 encoding/decoding utilities output, the string produced by to_string() is not standard base 64 encoding.
I did come across one issue related to base 64 searching this Github project:
Did I find some bug or is the string encoding not base 64 but some related variant? If a variant, why not use standard base 64? It would be nice to interoperate actions performed with AutoPy with other tools/utilties (e.g. decode output from AutoPy bitmap.to_string() elsewhere, encoded string elsewhere to load into AutoPy as bitmap). And if variant, is there a way to convert the to_string() value to standard base 64 and vice versa? So as not to need to do it separately/externally with some Python base 64 module.
FYI, I tested this with a PNG I saved externally with image editing tool that I loaded into AutoPy as well as a saved screenshot captured by AutoPy (saved with PNG extension), both on Windows 7 64-bit.
Issue by Hoangjimmy
Monday Jun 16, 2014 at 00:29 GMT
Originally opened as autopilot-rs#51
Hello,
I'm student in engeneering school and I Have to implement some new function in your module. I add three new function to use bitmap buffer in numpy for example.
These three functions are
Bitmap.get_bpp (To get the number of bits per pixel of screen)
Bitmap.get_buffer_length ( To get the length of the buffer)
Bitmap.get_buffer(To get the...buffer)
So I hope you'll accept my pull request
Thank you and have nice day
Hoangjimmy included the following code: https://github.com/msanders/autopy/pull/51/commits
Issue by lecheel
Monday Feb 13, 2012 at 11:57 GMT
Originally opened as autopilot-rs#32
bitmap.capture_screen capture on OSX 10.7 cause black screen
Issue by daluu
Friday Nov 18, 2011 at 23:31 GMT
Originally opened as autopilot-rs#25
I dont' think tolerance is really defined in the tutorial or the API doc. What are the valid ranges for tolerance values? 0.0 to 1.0? Or greater than 1 as well?
Based on testing, I'm assuming 0.0, the default, is must be exact match? And towards 1.0 means higher tolerance for partial or even no matches. At 1.0, for a test needle, testing with find bitmap against screen capture, it returns coordinates of (1,1) when the needle is not even present.
So would be helpful to clarify for users who are not well skilled in image recognition tools.
Issue by TheWizzz
Wednesday Oct 29, 2014 at 23:36 GMT
Originally opened as autopilot-rs#56
Under Win 7 x64, using Cygwin x64 v 1.7.32, gcc 4.8.3 and python 2.7.8
One gets, while doing "pip -v install autopy"
**** error dump start ****
gcc -fno-strict-aliasing -ggdb -O2 -pipe -Wimplicit-function-declaration -fdebug-prefix-map=/usr/src/ports/python/python-2.7.8-1.x86_64/build=/usr/src/debug/python-2.7.8-1 -fdebug-prefix-map=/usr/src/ports/python/python-2.7.8-1.x86_64/src/Python-2.7.8=/usr/src/debug/python-2.7.8-1 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -DNDEBUG=1 -DMM_LITTLE_ENDIAN -DUSE_X11 -I/usr/include/python2.7 -c src/alert.c -o build/temp.cygwin-1.7.32-x86_64-2.7/src/alert.o -Wall -Wparentheses -Winline -Wbad-function-cast -Wdisabled-optimization -Wshadow
In file included from src/alert.c:13:0:
src/snprintf.h:34:12: error: conflicting types for ‘asnprintf’
extern int asnprintf (char ptr, size_t str_m, const char _fmt, /args/ ...);
^
In file included from /usr/include/assert.h:9:0,
from src/alert.c:3:
/usr/include/stdio.h:247:8: note: previous declaration of ‘asnprintf’ was here
char * _EXFUN(asnprintf, (char *__restrict, size_t *__restrict, const char *__restrict, ...)
^
In file included from src/alert.c:13:0:
src/snprintf.h:35:12: error: conflicting types for ‘vasnprintf’
extern int vasnprintf(char *_ptr, size_t str_m, const char _fmt, va_list ap);
^
In file included from /usr/include/assert.h:9:0,
from src/alert.c:3:
/usr/include/stdio.h:275:8: note: previous declaration of ‘vasnprintf’ was here
char * EXFUN(vasnprintf, (char *, size_t *, const char *, __VALIST)
^
error: command 'gcc' failed with exit status 1
** error dump ends ****
Commenting-out lines 34 and 35 of src/snprintf.h seems to do the trick:
//extern int asnprintf (char *_ptr, size_t str_m, const char *fmt, /args/ ...);
//extern int vasnprintf(char *_ptr, size_t str_m, const char *fmt, va_list ap);
Compiling is successful afterwards.
Perhaps there's a deeper issue that someone here might get a grasp of.
Issue by Wilfred
Sunday Apr 15, 2012 at 18:10 GMT
Originally opened as autopilot-rs#33
They're very handy. Sure, most folks will guess that the attributes are there, but it's good to be explicit :).
Issue by eadmaster
Friday Apr 20, 2012 at 05:16 GMT
Originally opened as autopilot-rs#34
I'd like to request a function to control the media player, since python is missing this.
It could be implemented sending keystrokes to the player process.
Issue by bolus
Sunday Jan 17, 2010 at 00:21 GMT
Originally opened as autopilot-rs#8
(Sorry for the bad English)
Hello msanders,
first of all thanks for this library. I think it has the best API I've ever seen!
Unfortunately some essential thinks in the module "key" doesn't seem to work on my system (Ubuntu).
I've written an test script with comments in it to show you what I mean (appended after the PS).
I'm using a german keyboard layout / os, could this be a problem?
Do you see the same behavior as described in my script?
If yes: Do you think the problem is easy to fix?
I would love to use your library, sadly I don't know C, so I can't debug this myself.
Best regard,
Daniel
PS: here is the test script:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from autopy import key as k
import subprocess
import time
TAB = 65289
def main( ):
test_typing( )
alt_tab_test( )
def test_typing( ):
"""
typing a string doesn't works. Some chars are ignored (key.type_string) or
the false character is written (line 24, 25)
"""
string = "123456789!§$%&/()=?¹²³¼½¬{[]}\ "
p = subprocess.Popen( "gedit", shell=True )
time.sleep( 2 )
# bad => "123456789134567()0ß1234567890ß ":
for char in string:
k.tap( ord( char ) )
# worse => "123456789":
#k.type_string( string )
def alt_tab_test( ):
"""
modifiers don't seem to work. But it is easy to work around.
"""
# works:
k.toggle( k.K_ALT, True )
k.tap( TAB )
k.toggle( k.K_ALT, False )
# failed with: Segmentation fault
k.tap( TAB, k.MOD_ALT )
if __name__ == "__main__":
main( )
Issue by fHachenberg
Sunday May 04, 2014 at 21:00 GMT
Originally opened as autopilot-rs#48
There seems to be no activity in the original github project for the last 3 years. Looking into the fork overview I see about a dozen of unmerged forks. There are 5 open pull request which look like serious fixes.
Does anyone here have an overview over the project status? I would like to see a version of autopy including all those fixes as well as a Python 3 port. Is anyone here working on that target yet?
Issue by trafficone
Tuesday May 20, 2014 at 06:34 GMT
Originally opened as autopilot-rs#49
Fixed getMainDisplaySize to look at SM_CXVIRTUALSCREEN and SM_CYVIRTUALSCREEN instead of SM_CXSCREEN and SM_CYSCREEN if Windows says more than one monitor is attached.
trafficone included the following code: https://github.com/msanders/autopy/pull/49/commits
Issue by usracct84420
Monday Nov 10, 2014 at 10:11 GMT
Originally opened as autopilot-rs#59
key within autopy does not provide access to the standard numpad keys, the caps or scroll lock keys, or the pause/break key.
Retrieving the state of caps lock, num lock or scroll lock seems to be missing too.
Issue by joeltio
Saturday Oct 31, 2015 at 04:03 GMT
Originally opened as autopilot-rs#78
I have a problem where the functions:
mouse.toggle
type_string
when I input keyword arguments,
autopy.mouse.toggle(True, button=autopy.mouse.LEFT_BUTTON)
autopy.key.type_string("Hello, world!", wpm=60)
the python interpreter throws an error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: toggle() takes no keyword arguments
or
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: type_string() takes no keyword arguments
However this works when I do not include the button=
and wpm=
, so it works when I type this:
autopy.mouse.toggle(True, autopy.mouse.LEFT_BUTTON)
autopy.key.type_string("Hello, world!", 60)
Issue by behrisch
Wednesday Dec 21, 2011 at 09:26 GMT
Originally opened as autopilot-rs#28
autopy.mouse.move does not move to the correct position on the windows platform due to rounding errors. The problem are the following lines in src/mouse.c:
point.x *= 0xFFFF / GetSystemMetrics(SM_CXSCREEN);
point.y *= 0xFFFF / GetSystemMetrics(SM_CYSCREEN);
because if I want to move to (2000, 10) (I have two joined screens which gives a total res of 2560x1024),
it calculates for the x-coordinate 0xFFFF/2560 = 25 and then 2000 * 25 = 50000 while the correct result is
2000 * 0xFFFF / 2560 = 51199. This gives as a result a x-position of 50000 * 2560 / 0xFFF = 1953 (47 pixels off).
A workaround is to use ctypes.windll.user32.SetCursorPos(2000,10) which is not equivalent (http://stackoverflow.com/questions/3720938/win32-moving-mouse-with-setcursorpos-vs-mouse-event) but may help in some cases.
Issue by AdUki
Thursday Oct 15, 2015 at 19:25 GMT
Originally opened as autopilot-rs#77
Fixed compilation errors and warnings for python3.
Fixed screengrab function for OS X.
AdUki included the following code: https://github.com/msanders/autopy/pull/77/commits
Issue by fishstamp82
Sunday Jan 03, 2016 at 16:01 GMT
Originally opened as autopilot-rs#81
Documentation on the form of the rect as a tuple ((pos1, pos2), (width, height)) wasnt obvious so i added it to the readme.
fishstamp82 included the following code: https://github.com/msanders/autopy/pull/81/commits
Issue by tshirtman
Sunday Mar 03, 2013 at 22:59 GMT
Originally opened as autopilot-rs#40
if i pass a string containing non-ascii chars (like "éèçà" and their friends) only the ascii characters are typed, seems toggleUniKey() in keypress.c converst to unsigned char, so there is no unicode support whatsoever, is it possible to find a fix for that?
Issue by TaylorSMarks
Thursday Jul 30, 2015 at 00:51 GMT
Originally opened as autopilot-rs#75
When I do
sudo pip install autopy
I fail with 10 warnings and 9 errors. The warnings are all about stuff that was deprecated in 10.6. The errors are as follows:
src/screengrab.c:194:15: error: use of undeclared identifier 'GL_FRONT'
glReadBuffer(GL_FRONT);
^
src/screengrab.c:199:22: error: use of undeclared identifier 'GL_NO_ERROR'
if (glGetError() != GL_NO_ERROR) return NULL;
^
src/screengrab.c:223:21: error: use of undeclared identifier 'GL_CLIENT_PIXEL_STORE_BIT'
glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);
^
src/screengrab.c:225:16: error: use of undeclared identifier 'GL_PACK_ALIGNMENT'
glPixelStorei(GL_PACK_ALIGNMENT, BYTE_ALIGN); /* Force alignment. */
^
src/screengrab.c:226:16: error: use of undeclared identifier 'GL_PACK_ROW_LENGTH'
glPixelStorei(GL_PACK_ROW_LENGTH, 0);
^
src/screengrab.c:227:16: error: use of undeclared identifier 'GL_PACK_SKIP_ROWS'
glPixelStorei(GL_PACK_SKIP_ROWS, 0);
^
src/screengrab.c:228:16: error: use of undeclared identifier 'GL_PACK_SKIP_PIXELS'
glPixelStorei(GL_PACK_SKIP_PIXELS, 0);
^
src/screengrab.c:236:30: error: use of undeclared identifier 'GL_BGRA'
MMRGB_IS_BGR ? GL_BGRA : GL_RGBA,
^
src/screengrab.c:240:15: error: use of undeclared identifier 'GL_UNSIGNED_INT_8_8_8_8_REV'
GL_UNSIGNED_INT_8_8_8_8_REV, /* Native format */
^
Issue by donjan
Friday Jun 19, 2015 at 09:25 GMT
Originally opened as autopilot-rs#74
First issue.
Searching with haystack.find_bitmap(needle, tolerance)
and 0<tolerance<<1 doesn't work.
The problem is in MMRGBHexSimilarToColor()
at src/rgb.h:98 where the differences are stored as uint8_t
, but we need to handle a range of (-255, -255).
uint wrapping doesn't work because a very similar h1 - h2, e.g. 21 - 23, gets stored as d1=254, which fails the search for small tolerance.
The fix is to use a signed integer that supports the range (i.e. int
), and due to simplicity I won't bother putting a fork online and sending a pulling request. Here's the diff:
@@ -117,18 +95,30 @@
if (tolerance <= 0.0f) {
return h1 == h2;
} else {
- uint8_t d1 = RED_FROM_HEX(h1) - RED_FROM_HEX(h2);
- uint8_t d2 = GREEN_FROM_HEX(h1) - GREEN_FROM_HEX(h2);
- uint8_t d3 = BLUE_FROM_HEX(h1) - BLUE_FROM_HEX(h2);
+ int d1 = RED_FROM_HEX(h1) - RED_FROM_HEX(h2);
+ int d2 = GREEN_FROM_HEX(h1) - GREEN_FROM_HEX(h2);
+ int d3 = BLUE_FROM_HEX(h1) - BLUE_FROM_HEX(h2);
return sqrt((d1 * d1) +
(d2 * d2) +
(d3 * d3)) <= (tolerance * 442.0f);
}
}
Also the same should be done for the MMRGBColorEqualToColor()
higher up.
Second issue.
The find_bitmap
function is internally 0-start-index based, but returns (1,1) if the match occurs at the very beginning, which implies autopy.bitmap to be 1-start-index based. Yet Bitmap.get_portion()
appears to work with 0-start-index (side note: the documentation in this regard is lacking).
Easiest way to check is by searching for itself:
img = autopy.bitmap.Bitmap.open("test.png")
pos = img.find_bitmap(img, 0.01)
img.get_portion(pos, (img.width, img.height)).save('match.png')
pos
is (1,1) and the last line throws a ValueError: Portion out of bounds
If we get_portion(pos, (img.width-1, img.height-1))
the resulting match.png is wrong (1 pixel too small in each direction).
The simple fix is in findBitmapInRectAt
at src/bitmap_find.c:89 to increment (EDIT) not increment pointOffset
after assigning, not beforepointOffset
before returning. Again due to simplicity here's just the diff:
@@ -86,9 +86,9 @@
while (pointOffset.x <= scanWidth) {
/* Check offset in |haystack| for |needle|. */
if (needleAtOffset(needle, haystack, pointOffset, tolerance)) {
- ++pointOffset.x;
- ++pointOffset.y;
*point = pointOffset;
return 0;
}
This gives the correct result. It changes postconditions though, so the proper thing to do would be to define the coordinate start somewhere (documentation?) and be consistent about it.
Conclusion.
I hope these two "patches" get accepted quickly, as I have a slightly improved fuzzy matching (which requires some more changes) that depends on them.
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.