Send "F5" every 30 seconds

974 views
Skip to first unread message

Jon Munford

unread,
Mar 26, 2014, 2:36:29 PM3/26/14
to autoke...@googlegroups.com
Hey All, 

I need to loop the pressing of f5 every 30 seconds or so.  My understanding is that an AutoKey script is a one time run.  Is there a way to make it loop?

Thanks!


Confidentiality Statement: This message is intended only for the use of the Addressee and may contain information that is PRIVILEGED and CONFIDENTIAL. If you are not the intended recipient, dissemination of this communication is prohibited. If you have received this communication in error, please erase all copies of the message and its attachments and notify the sender immediately. Thank you.

Steve Fisher

unread,
Mar 26, 2014, 5:54:19 PM3/26/14
to autoke...@googlegroups.com
Something like:

# Enter script code
a = 1
while a = 1
    keyboard.send_key("<f5>")
    time.sleep(30.0)

But..........  I have never got my machine to recognise the sending of a function key, e.g. f12 should call up guake but it doesn't

This script has no exit point, so you have to kill autokey to terminate.

Steve

Joe

unread,
Mar 27, 2014, 5:19:33 AM3/27/14
to autoke...@googlegroups.com
What are you really trying to do? I ask because maybe you don't need AutoKey for it.

This is something I've read about, but not done.

(In what follows, substitute the name of your favorite scripting (or even compiled) language for "bash".)

I found:
http://www.techrepublic.com/article/find-and-bind-key-sequences-in-bash/

which (among other things) tells you how to get the character sequence for a function key.

Maybe you could write a simple bash script that emits this character sequence at timed intervals. If you just want to affect what's running in a terminal, maybe this would take care of it.

If the F5 needs to go into a gui app, then that's a bit trickier. The tool for that is xdotool. You can tell xdotool to send most anything a keyboard (or mouse) can send and you can tell it what window to send it to.

http://linux-commands-examples.com/xdotool

This even has an example that finds the window and sends F5 to it. A pretty good start for you!

This can still all be done in bash. If it needs to be launched from a hotkey, then an AutoKey macro can use Python to launch your script in the background (so you can stop or kill it without killing AutoKey).

If you save the script's process ID to a file, you can use another script to kill it or kill it by name using pkill. Or you can just have the script look at a (semaphore) file (created when the script first gets invoked - either by the script or by the macro). If the file is there, keep running. If it's not, then exit. Then, you just need another script and/or macro to delete the file when you want the first script to quit.

Joe
Reply all
Reply to author
Forward
0 new messages