![]() ![]() maximize () Screen from ahk import AHK ahk = AHK () ahk. active : # Check if window active window. rect ) # (x, y, width, height) print ( window. title ) # Some more attributes print ( window. always_on_top = True # Make the window always on top for window in ahk. to_bottom () # Move the window to the bottom of the other windows win. to_top () # Move the window on top of other windows win. disable () # Make the window non-interactable win. activate_bottom () # Give the window focus win. send ( 'hello' ) # Send keys directly to the window (does not need focus!) win. find_window ( title = b 'Untitled - Notepad' ) # Find the opened window win. run_script ( 'Run Notepad' ) # Open notepad win = ahk. win_wait ( title = 'Untitled - Notepad', timeout = 5 ) except TimeoutError : print ( 'Notepad was not found!' ) Working with windows from ahk import AHK ahk = AHK () ahk. from_pid ( ahk, pid = '20366' ) # by process ID # Wait for a window try : # wait up to 5 seconds for notepad win = ahk. from_mouse_position ( ahk ) # the window under the mouse cursor win = Window. windows ()) # list of all windows win = Window ( ahk, ahk_id = '0xabc123' ) # by ahk_id win = Window. win_get ( title = 'Untitled - Notepad' ) # by title win = list ( ahk. active_window # Get the active window win = ahk. Getting windows from ahk import AHK from ahk.window import Window ahk = AHK () win = ahk. set_capslock_state ( "on" ) # Turn CapsLock on Windows NOTE: This throws # a TimeoutError if the key isn't pressed within the timeout window ahk. key_wait ( 'a', timeout = 3 ) # Wait up to 3 seconds for the "a" key to be pressed. key_up ( 'Control' ) # Release the key ahk. key_down ( 'Control' ) # Press down (but do not release) Control key ahk. key_press ( 'a' ) # Press and release a key ahk. key_state ( 'CapsLock', mode = 'T' ) # Check toggle state of a key (like for NumLock, CapsLock, etc) ahk. key_state ( 'Control' ) # Return True or False based on whether Control key is pressed down ahk. send_input ( 'Hello`, World' ) # Like AHK SendInput, must escape strings yourself! ahk. type ( 'hello, world!' ) # Send keys, as if typed (performs ahk string escapes) ahk. mouse_drag ( 100, 100, relative = True ) # Holds down primary button and moves the mouse Keyboard from ahk import AHK ahk = AHK () ahk. right_click () # Clicks the secondary mouse button ahk. click ( 200, 200 ) # Moves the mouse to a particular position and clicks ahk. double_click () # Clicks the primary mouse button twice ahk. click () # Click the primary mouse button ahk. mouse_position = ( 100, 100 ) # Moves the mouse instantly to absolute screen position ahk. mouse_move ( 100, 100, speed = 10, relative = True ) # Moves the mouse reletave to the current position ahk. mouse_position # Returns a tuple of mouse coordinates (x, y) ahk. Full documentation coming soon! Mouse from ahk import AHK ahk = AHK () ahk. ![]() Non-exhaustive examples of some of the functions available with this package. ![]() mouse_move ( x = 150, y = 150, speed = 10, blocking = True ) # Moves the mouse to x, y taking 'speed' seconds to move print ( ahk. mouse_move ( x = 100, y = 100, blocking = True ) # Blocks until mouse finishes moving (the default) ahk. ![]() See also Non-Python dependencies Usage from ahk import AHK ahk = AHK () ahk. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |