Great that it works for you!
Since these scripts are Python, there are probably many ways to do what
you want.
One simple "AutoKey" way to do it would be as follows.
Before the loop, set a global AutoKey variable to false or 0.
Use while true (infinite loop)
Inside the loop retrieve the AutoKey global variable. If it is set to
true or 1, break out of the loop.
Write another script bound to another hotkey which sets the AutoKey
global variable to true or 1.
When your first script is running, press the hotkey for the second
script when you want it to stop.
You will probably have to experiment with delays/timing to get the
responsiveness you need to stop at the right time. Start with long
delays and shorten them until it stops working as desired.
Joe
> *time.sleep(1)*
> *for main in range (20):*
> * keyboard.send_keys("<up>")*
> * keyboard.send_keys("<ctrl>+a")*
> * keyboard.send_keys("<backspace>") # Or <delete>,
> if that's what you want.*
> * keyboard.send_keys("<enter>"*2)
> *
> * keyboard.send_keys("<tab>")*
>
> Or, if you really need those delays between
> everything, I would make a function for it:
>
> *def SendKeys(TextToSend, Delay):*
> * keyboard.send_keys(TextToSend)*
> * time.sleep(Delay)*
> *
> *
> *time.sleep(1)*
> *for main in range (20):*
> * SendKeys("<up>", 0.1)*
> * SendKeys("<ctrl>+a", 0.1)*
> * SendKeys("<backspace>", 0.15) # Or <delete>, if
> that's what you want.
> *
> * SendKeys("<enter>"*2, 0.15) # Maybe separate this
> into two lines, if it doesn't work properly otherwise.
> *
> * SendKeys("<tab>", 0.15)*
>
> Those delays are usually not needed. The only time I
> needed delays so far, was when using the clipboard.
> Here's an example for that:
> *def SendStringViaClipboard(Text):
> # Remember the original clipboard content.
> OriginalClipboard=clipboard.get_clipboard()
>
> clipboard.fill_clipboard(Text)
> keyboard.send_keys("<ctrl>+v")
> time.sleep(0.5)
>
> # Restore the clipboard to its original value.
> clipboard.fill_clipboard(OriginalClipboard)
>
> SendStringViaClipboard("This is a test string.")
> keyboard.send_keys("<enter>"*2)*
>
> In this case I think the Ctrl+v thing takes some time,
> so a delay is needed before putting back the old
> contents to the clipboard. Otherwise the old contents
> will be in the clipboard before the paste is
> completed, so the old content will be pasted instead…
>
> Another good thing to know is that if you try to send
> Unicode characters (I know this isn't the problem in
> this particular case), except the most common ones,
> send_keys will probably fail. That's when sending text
> via the clipboard comes in handy as a workaround.In
> the above example, this will work:*
> *
> *SendStringViaClipboard("На Сопках Манчжурии")*
>
> And this will fail:
> *keyboard.send_keys("На Сопках Манчжурии")*
> <
https://groups.google.com/d/msgid/autokey-users/349a5990-581a-4219-be8f-6cae343bf42an%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/eaf880a1-58fa-492f-9892-74c07a0858dan%40googlegroups.com
> <
https://groups.google.com/d/msgid/autokey-users/eaf880a1-58fa-492f-9892-74c07a0858dan%40googlegroups.com?utm_medium=email&utm_source=footer>.