-
Notifications
You must be signed in to change notification settings - Fork 0
AutoPy Python API specifics for debugging
daluu edited this page Jan 3, 2015
·
1 revision
From Python script or shell
import autopy
# find by image within another image
canvas = autopy.bitmap.Bitmap.open(image_path)
pos = canvas.find_bitmap(elem[,tolerance]) #tolerance is optional parameter, default is 0.0
# find image from desktop screen
pos = autopy.bitmap.capture_screen().find_bitmap(elem[,tolerance]) #tolerance is optional parameter, default is 0.0
if pos is None:
print 'image not found'
else:
print 'image located at (%d,%d)' % (pos[0],pos[1])
# if image not found, can try varying tolerance value from 0.0 to 1.0 to see if it helps or not
# more details at https://github.com/msanders/autopy/issues/25
# finding images/elements
result = autopy.bitmap.capture_screen().find_every_bitmap(elem[,tolerance])
result = canvas.find_every_bitmap(elem[,tolerance]) #canvas from previous line of code above
# if result is empty list, not found, else get list of x,y coordinates, one for each element/image found
# can also use .count_of_bitmap(elem[,tolerance]) to check as well. 0 = not found
elem = autopy.bitmap.Bitmap.open(image_path)
print 'image dimensions: %d x %d' % elem.width, elem.height
autopy.bitmap.capture_screen().save(path_to_save_screenshot_file)
autopy.key.type_string(keys_to_send) # can also send modifiers, etc. See full API docs.
autopy.mouse.click() # default of left mouse button
autopy.mouse.click(autopy.mouse.RIGHT_BUTTON)
autopy.mouse.toggle(False) # mouse up on left button
autopy.mouse.toggle(True,autopy.mouse.RIGHT_BUTTON) # mouse down right button
autopy.mouse.smooth_move(x,y)
coordinates = autopy.mouse.get_pos() # returns (x,y)
https://github.com/msanders/autopy
http://www.autopy.org/documentation/api-reference/index.html