loop my script and key to pause

260 views
Skip to first unread message

Tibia REC

unread,
Jun 3, 2020, 6:25:34 AM6/3/20
to autokey-users
hello i wanted to loop my macro key and i wanted to have a key to pause it this is possible?

#i want to keep using f8 and f3 util it got paused
import time
keyboard.send_keys('<f8>')
time.sleep(2.07)
keyboard.send_keys('<f3>')
time.sleep(2.07)



jack

unread,
Jun 3, 2020, 6:29:42 AM6/3/20
to autoke...@googlegroups.com, Tibia REC

hi

something like this:

https://stackoverflow.com/questions/21101084/autokey-repeating-loop

import time
import sys
try:
    while True:
        time.sleep(5)
        keyboard.send_key("4")
except KeyboardInterrupt:
    exit(0)
    sys.exit(0)


you need to use ctrl+C to interrupt.


jack
Biodegrading: Now it's getting personal.
--
You received this message because you are subscribed to the Google Groups "autokey-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to autokey-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/autokey-users/3b300f17-e239-4f83-b67c-960cf21ecda1%40googlegroups.com.

Tibia REC

unread,
Jun 3, 2020, 6:34:05 AM6/3/20
to autokey-users
got error can you check it?
import time
import sys
try:
    while True:
        keyboard.send_keys('<f8>')
         time.sleep(2.07)
except KeyboardInterrupt:
    exit(0)
    sys.exit(0)

To unsubscribe from this group and stop receiving emails from it, send an email to autoke...@googlegroups.com.

jack

unread,
Jun 3, 2020, 6:36:29 AM6/3/20
to autoke...@googlegroups.com, Tibia REC
spacing is important. you have to be consistent

    keyboard and time have different indentation.


fwiw, when you want help with an error, please send the error that you get. it can be awkward to fix without knowing that.


cheers

jack
been there, done that, got the screen-saver
To unsubscribe from this group and stop receiving emails from it, send an email to autokey-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/autokey-users/d356a7ac-841e-4b28-a9a6-b811d47b9587%40googlegroups.com.

Tibia REC

unread,
Jun 3, 2020, 6:48:19 AM6/3/20
to autokey-users
my bad it works good now but when use ctrl+ c it didnt stop and no errors given i've tried on my window filter app also in autokey gui

jack horsfield

unread,
Jun 4, 2020, 4:34:16 AM6/4/20
to autoke...@googlegroups.com
The ctrl+c must be in the same window as the script is running. Dunno if that helps.

I suppose you could try putting a very long sleep in there...a second or two, just to see if that lets the ctrl+c get in there. If yes, trim the king sleep as much as possible

Jack

Joe

unread,
Jun 5, 2020, 5:58:31 AM6/5/20
to autoke...@googlegroups.com
If the Ctrl+C doesn't work, then you have two options:

1) Repost on Gitter and let the developers enlighten us as to why it
doesn't work and how to fix it.

While you're waiting for an answer, you can try running a trace to see
how AutoKey is processing your script. It might give you some insight
into why it doesn't work or how to fix it. See
https://github.com/autokey/autokey-python2/wiki/Problem-Reporting-Guide
for how to do that.

2) Write a second script that toggles an AutoKey global variable between
on/off, 1/0, etc. and assign it to a hotkey.

Modify the original script to set the global variable to "on" before
entering its loop. While in the loop, read that AutoKey global variable
and break out of the loop when it sees it is set to "off".

This way you have your own hotkey that functions roughly the same as
using Ctrl+C would, but just for your script.

BTW, when talking to the developers, we call these "scripts", not
"macros". The term "macro" is reserved for several features like adding
"<cursor>" within a phrase text to reposition the text cursor after the
phrase has been expanded.

Joe

On 6/4/20 4:34 AM, jack horsfield wrote:
> The ctrl+c must be in the same window as the script is running. Dunno
> if that helps.
>
> I suppose you could try putting a very long sleep in there...a second
> or two, just to see if that lets the ctrl+c get in there. If yes, trim
> the king sleep as much as possible
>
> Jack
> On 3 Jun 2020, at 11:48, Tibia REC <migue...@gmail.com
>>> <https://groups.google.com/d/msgid/autokey-users/3b300f17-e239-4f83-b67c-960cf21ecda1%40googlegroups.com?utm_medium=email&utm_source=footer>.
>>
>> --
>> You received this message because you are subscribed to the
>> Google Groups "autokey-users" group.
>> To unsubscribe from this group and stop receiving emails from
>> it, send an email to autoke...@googlegroups.com <javascript:>.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/autokey-users/d356a7ac-841e-4b28-a9a6-b811d47b9587%40googlegroups.com
>> <https://groups.google.com/d/msgid/autokey-users/d356a7ac-841e-4b28-a9a6-b811d47b9587%40googlegroups.com?utm_medium=email&utm_source=footer>.
>
> --
> You received this message because you are subscribed to the Google
> Groups "autokey-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to autokey-user...@googlegroups.com
> <mailto:autokey-user...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/autokey-users/146cc172-8a89-4a7f-8ffc-b845857e6a75%40gmail.com
> <https://groups.google.com/d/msgid/autokey-users/146cc172-8a89-4a7f-8ffc-b845857e6a75%40gmail.com?utm_medium=email&utm_source=footer>.
Reply all
Reply to author
Forward
0 new messages