How to use the ahk.AHK function in ahk

To help you get started, we’ve selected a few ahk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github spyoungtech / ahk / tests / unittests / test_keyboard.py View on Github external
def a_down():
    time.sleep(0.5)
    ahk = AHK()
    ahk.key_down('a')
github spyoungtech / ahk / tests / unittests / test_win_get.py View on Github external
import sys
import os
import time
project_root = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '../..'))
sys.path.insert(0, project_root)
from ahk import AHK
from ahk.window import WindowNotFoundError
import pytest
import subprocess
ahk = AHK()

def test_get_calculator():
    p = None
    try:
        p = subprocess.Popen('notepad')
        time.sleep(1)  # give notepad time to start up
        win = ahk.win_get(title='Untitled - Notepad')
        assert win
        assert win.position
    finally:
        if p is not None:
            p.terminate()

def test_win_close():
    p = None
    try:
github spyoungtech / ahk / tests / features / steps / ahk_steps.py View on Github external
from behave.matchers import RegexMatcher
from ahk import AHK
from behave_classy import step_impl_base

Base = step_impl_base()


class AHKSteps(AHK, Base):
    @Base.given(u'the mouse position is ({xpos:d}, {ypos:d})')
    def given_mouse_move(self, xpos, ypos):
        self.mouse_move(x=xpos, y=ypos)

    @Base.when(u'I move the mouse (UP|DOWN|LEFT|RIGHT) (\d+)px', matcher=RegexMatcher)
    def move_direction(self, direction, px):
        px = int(px)
        if direction in ('UP', 'DOWN'):
            axis = 'y'
        else:
            axis = 'x'
        if direction in ('LEFT', 'UP'):
            px = px * -1
        kwargs = {axis: px, 'relative': True}
        self.mouse_move(**kwargs)
github spyoungtech / ahk / tests / unittests / test_executable_location.py View on Github external
def test_no_executable_raises_error():
    check_pwd()
    with mock.patch.dict(os.environ, {'PATH': ''}, clear=True):
        with pytest.raises(ExecutableNotFoundError):
            AHK()
github spyoungtech / ahk / tests / unittests / test_executable_location.py View on Github external
def test_env_var_takes_precedence_over_path():
    check_pwd()
    actual_path = AHK().executable_path
    ahk_location = os.path.abspath(os.path.dirname(actual_path))
    with mock.patch.dict(os.environ, {'PATH': ahk_location, 'AHK_PATH':'C:\\expected\\path\\to\\ahk.exe'}):
        ahk = AHK()
        assert ahk.executable_path == 'C:\\expected\\path\\to\\ahk.exe'
github spyoungtech / ahk / tests / unittests / test_screen.py View on Github external
def setUp(self):
        """
        Record all open windows
        :return:
        """
        self.ahk = AHK()
        self.before_windows = self.ahk.windows()
        im = Image.new('RGB', (20, 20))
        for coord in product(range(20), range(20)):
            im.putpixel(coord, (255, 0, 0))
        self.im = im
        im.show()
        time.sleep(2)
github spyoungtech / ahk / tests / unittests / test_keyboard.py View on Github external
def setUp(self):
        """
        Record all open windows
        :return:
        """
        self.ahk = AHK()
        self.before_windows = self.ahk.windows()
        self.p = subprocess.Popen('notepad')
        time.sleep(1)
        self.notepad = self.ahk.find_window(title=b'Untitled - Notepad')
github spyoungtech / ahk / tests / unittests / test_executable_location.py View on Github external
def test_executable_from_path():
    check_pwd()
    actual_path = AHK().executable_path
    ahk_location = os.path.abspath(os.path.dirname(actual_path))
    with mock.patch.dict(os.environ, {'PATH': ahk_location}, clear=True):
        ahk = AHK()
        assert ahk.executable_path == actual_path
github spyoungtech / ahk / tests / unittests / test_keyboard.py View on Github external
def release_a():
    time.sleep(0.5)
    ahk = AHK()
    ahk.key_up('a')