Exemple #1
0
 def code():
     import ahkpy as ahk
     import threading
     ahk.set_countdown(0.1, print, 1)
     threading.Timer(0.2, lambda: print(2)).start()
     ahk.sleep(0.3)
     print(3)
        def windows():
            import ahkpy as ahk
            import sys

            ahk.hotkey("F24", sys.exit)

            ahk.set_countdown(0.1, ahk.message_box, "win1", "ahkpy win1")
            ahk.set_countdown(0.3, ahk.message_box, "win2", "ahkpy win2")
            ahk.sleep(1)
            sys.exit()
def test_status_bar(notepad):
    ahk.sleep(0.2)
    assert "Ln 1, Col 1" in notepad.get_status_bar_text(1)

    notepad.send("q")
    ahk.sleep(0)
    assert "Ln 1, Col 2" in notepad.get_status_bar_text(1)

    ahk.set_countdown(0.5, notepad.send, "q")
    assert notepad.wait_status_bar("  Ln 1, Col x", part=1, timeout=0.1) is False
    assert notepad.wait_status_bar("  Ln 1, Col 3", part=1, timeout=1) is True
    assert notepad.get_status_bar_text(1) == "  Ln 1, Col 3"
def test_refcounts(request):
    func = lambda: None  # noqa: E731
    timer = ahk.set_countdown(1, func)
    request.addfinalizer(timer.stop)
    func_refcount = sys.getrefcount(func)
    timer.stop()
    assert sys.getrefcount(func) == func_refcount - 1

    timer = ahk.set_countdown(0.01, func)
    func_refcount = sys.getrefcount(func)
    ahk.sleep(0.01)
    assert sys.getrefcount(func) == func_refcount - 1
Exemple #5
0
    def code():
        import ahkpy as ahk
        import sys

        ahk.hotkey("F13", print, "ok01")

        @ahk.hotkey("F14")
        def sus():
            ahk.suspend()
            print("ok02")

        ahk.set_countdown(0.5, sys.exit)
        print("ok00")
Exemple #6
0
def test_settings_bleed(settings):
    settings.win_delay = 0.1

    win_delays = []

    def f():
        local = ahk.local_settings().activate()
        win_delays.append(ahk.get_settings().win_delay)
        local.win_delay = 0  # This must not affect other callbacks
        ahk.sleep(0.02)

    ahk.set_countdown(0.01, f)
    ahk.set_countdown(0.02, f)
    ahk.sleep(0.03)

    assert win_delays == [0.1, 0.1]
def test_countdown_start(request):
    times = []

    timer = ahk.set_countdown(1, times.append, 1)
    request.addfinalizer(timer.stop)

    timer.start(interval=0.1)  # Restart a non-finished countdown
    ahk.sleep(0.11)
    assert len(times) == 1

    timer.start()  # Start a finished countdown with its previous interval
    ahk.sleep(0.11)
    assert len(times) == 2
 def timers():
     import ahkpy as ahk
     import sys
     ahk.hotkey("F24", sys.exit)
     ahk.set_countdown(0.01, object)
     print("ok00")
Exemple #9
0
 def code():
     import ahkpy as ahk
     ahk.set_countdown(0.1, print, 1)
     ahk.sleep(0.2)  # sleep longer than the countdown
     print(2)