Post your favourite scripts/tips

3,846 views
Skip to first unread message

Chris Dekter

unread,
Jan 3, 2010, 7:40:32 PM1/3/10
to autokey-users
I am planning to expand the Sample Scripts wiki page with some more
ideas on clever uses of AutoKey. I would be very interested to receive
suggestions for additions to this page - post them here on the group
for all to see.

Derek

unread,
Jan 3, 2010, 10:15:20 PM1/3/10
to autokey-users
I use this to automate a search on something Python-related that I
have selected:

text = clipboard.get_selection()
window.activate("Firefox")
if window.wait_for_focus(".*Firefox.*"):
keyboard.send_keys("<ctrl>+t")
keyboard.send_keys("<tab>python "+text+"<enter>")

This assumes Firefox is already open somewhere. The <tab> gets the
cursor into the search box for my browser configuration. It might
have to be adjusted if your search box is somewhere else. Otherwise,
you could just put the google url with search terms into the url box.

Derek

Message has been deleted

Neo Futur

unread,
Aug 17, 2013, 10:06:23 AM8/17/13
to autoke...@googlegroups.com
imho a good example on driving the mouse and click is most needed ( many gamers need that and its a main reason why people use autohk afaik )
also providing some macros to help scripting like
MOUSETO(163,248)
CLICKHERE
WAIT(20)

would really help people

Joe

unread,
Aug 17, 2013, 11:52:33 PM8/17/13
to autoke...@googlegroups.com, Neo Futur
AFAIK, AutoKey does not support mouse events. (It would be very good if
it was extended to do so.)

There are a few examples of AutoKey macros on this list, but a more
formal collection has not been organized. If someone wants to set it up,
I believe we could gather the ones already on the list or in the wiki
and put them there. Once that is done, it's likely that there will be
more contributions. From what I've seen on this list, some people have
done really interesting things with AutoKey.

Chris, the developer, retired from the project over a year ago. There
are a few developers who have expressed interest in working on the
project, but no one has taken the lead to make further development and
maintenance happen yet. If you or anyone you know is interested, send
them our way!

Joe
> --
> 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.
> For more options, visit https://groups.google.com/groups/opt_out.

Neo Futur

unread,
Aug 18, 2013, 11:43:56 AM8/18/13
to autoke...@googlegroups.com, Neo Futur
yes autokey seems to support mouse :

http://autokey.sourceforge.net/apidoc/lib.scripting.Mouse-class.html

but without any working examples , not so easy to make it work

Martin Jurčo

unread,
Feb 21, 2015, 11:54:54 AM2/21/15
to autoke...@googlegroups.com
This is few my favourite scripts:

Translate selected text from English to Slovak with Google translator with hotkey:
import time
text
= clipboard.get_selection()
output
= system.exec_command("chromium-browser https://translate.google.com/#en/sk/")
keyboard
.send_keys(output)
time
.sleep(1.25)
keyboard
.send_keys(text)

Create new diretory in Thunar file manager like in Total Commander with hotkey F7:
keyboard.send_keys("<shift>+<ctrl>+n")

Delete directory or file in Thunar file manager like in Total Commander with hotkey F8: 
import time
keyboard
.send_keys("<alt>+e")
time
.sleep(0.05)
keyboard
.send_key("d")

I was also remap <shift>+<backspace> hotkey to <delete> key with autokey phrase because <delete> key missing on my Chromebook.

Here is sample to use easygui dialog in autokey but it is just sample without exact meaning.
import easygui
myname
= easygui.enterbox("Enter your name")
#first syntax version for msgbox
easygui
.msgbox("Your name is :\n" + myname)
#second syntax version for msgbox
#easygui.msgbox("Your name is :\n '%s'" % myname)




Dňa pondelok, 4. januára 2010 1:40:32 UTC+1 Chris D napísal(-a):

Joe

unread,
Feb 21, 2015, 4:09:09 PM2/21/15
to autoke...@googlegroups.com
Thanks for your contributions.

It's amazing how much you can improve your end-user experience with just
a few lines of code.

Joe

On 02/21/2015 11:54 AM, Martin Jurčo wrote:
> This is few my favourite scripts:
>
> Translate selected text from English to Slovak with Google translator
> with hotkey:
> |
> importtime
> text =clipboard.get_selection()
> output =system.exec_command("chromium-browser
> https://translate.google.com/#en/sk/")
> keyboard.send_keys(output)
> time.sleep(1.25)
> keyboard.send_keys(text)
> |
>
> Create new diretory in Thunar file manager like in Total Commander
> with hotkey F7:
> |
> keyboard.send_keys("<shift>+<ctrl>+n")
> |
>
> Delete directory or file in Thunar file manager like in Total
> Commander with hotkey F8:
> |
> importtime
> keyboard.send_keys("<alt>+e")
> time.sleep(0.05)
> keyboard.send_key("d")
> |
>
> I was also remap <shift>+<backspace> hotkey to <delete> key with
> autokey phrase because <delete> key missing on my Chromebook.
>
> Here is sample to use easygui dialog in autokey but it is just sample
> without exact meaning.
> |
> importeasygui
> myname =easygui.enterbox("Enter your name")
> #first syntax version for msgbox
> easygui.msgbox("Your name is :\n"+myname)
> #second syntax version for msgbox
> #easygui.msgbox("Your name is :\n '%s'" % myname)
>
> |
>
>
>
> Dňa pondelok, 4. januára 2010 1:40:32 UTC+1 Chris D napísal(-a):
>
> I am planning to expand the Sample Scripts wiki page with some more
> ideas on clever uses of AutoKey. I would be very interested to receive
> suggestions for additions to this page - post them here on the group
> for all to see.
>
> --
> 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>.
> For more options, visit https://groups.google.com/d/optout.

Steve Fisher

unread,
Feb 21, 2015, 4:57:16 PM2/21/15
to autoke...@googlegroups.com

This is brilliant,  we need more posts like this.   I am not a python guy,  I use mainly text expansion,  but will post some of my "best" uses for autokey.   We need to get a bigger audience!

Steve

Sent from Blue Mail

Joe

unread,
Feb 21, 2015, 7:08:25 PM2/21/15
to autoke...@googlegroups.com
To really promote AutoKey, the main thing we need is volunteers to make
this into a fully functioning project.

This list may seem a bit long, but it would only take 5 or 6 people to
do most of it.

TL;DR: We need to take a great, active community and turn it back into a
project again.

1) One or two more people with the skills to maintain and develop the
project.

We have two contributing developers now, but both of them have a lot
of other things on their plates.
(This is a huge improvement! For around a year after Chris resigned,
we had no one.)

It would be good if someone was willing to become the official
maintainer/coordinator of the project
like Chris was.

2) People to update the current documentation. I've done a bit of this
in the past, but the existing docs are
getting dated. Now that the project has moved off of code.google,
more changes will be needed.

3) People to write new, more thorough documentation and a few
howtos/tutorials.

4) Someone to manage the project website - or maybe make a new one.
We have some example macros on the web, but we need to put more like
the ones
just contributed onto the web - maybe in a wiki, so everybody can
see them.

If someone is looking at AutoKey to decide if they want to use it,
and they find a few macros there that already do something they need,
then that would have a major impact on their decision to try it.

Examples give people ideas about what is possible and about how
hard/easy it is to implement things.

Examples on a list like this are great, but only the true believers
get to see them.

Python is a great language, but I'd bet most of our current, and
certainly most of our
potential user base don't know how to program in it.

This is Linux, so many of them would probably be able to take
something that is almost what they want
and modify it a bit. They just wouldn't attempt to build something
from scratch.

5) A few people with different setups to act as beta testers.

6) Once 1) - 5) are addressed and making progress, we need someone to
evangelize AutoKey to the various
distribution packagers and coordinate with them so they include it
(in an up to date version) in their
repositories. That's where people look first for a new
application. If it's not in there, then they start to worry about
installing it, getting updates, and compatibility
issues ...

Joe

On 02/21/2015 04:57 PM, Steve Fisher wrote:
>
> This is brilliant, we need more posts like this. I am not a python
> guy, I use mainly text expansion, but will +post some of my "best"
> uses for autokey. We need to get a bigger audience!
>
> Steve
>
> Sent from Blue Mail <http://r.bluemailapp.com>
>
> On 21 Feb 2015, at 16:54, "Martin Jurčo" <uxman...@gmail.com
> <mailto:uxman...@gmail.com>> wrote:
>
> This is few my favourite scripts:
>
> Translate selected text from English to Slovak with Google
> translator with hotkey:
> ||
> importtime
> text =clipboard.get_selection()
> output =system.exec_command("chromium-browser
> https://translate.google.com/#en/sk/")
> keyboard.send_keys(output)
> time.sleep(1.25)
> keyboard.send_keys(text)
>
> Create new diretory in Thunar file manager like in Total Commander
> with hotkey F7:
> ||
> keyboard.send_keys("<shift>+<ctrl>+n")
>
> Delete directory or file in Thunar file manager like in Total
> Commander with hotkey F8:
> ||
> importtime
> keyboard.send_keys("<alt>+e")
> time.sleep(0.05)
> keyboard.send_key("d")
>
> I was also remap <shift>+<backspace> hotkey to <delete> key with
> autokey phrase because <delete> key missing on my Chromebook.
>
> Here is sample to use easygui dialog in autokey but it is just
> sample without exact meaning.
> ||
> importeasygui
> myname =easygui.enterbox("Enter your name")
> #first syntax version for msgbox
> easygui.msgbox("Your name is :\n"+myname)
> #second syntax version for msgbox
> #easygui.msgbox("Your name is :\n '%s'" % myname)
>
>
>
>
> Dňa pondelok, 4. januára 2010 1:40:32 UTC+1 Chris D napísal(-a):
>
> I am planning to expand the Sample Scripts wiki page with some
> more
> ideas on clever uses of AutoKey. I would be very interested to
> receive
> suggestions for additions to this page - post them here on the
> group
> for all to see.
>

Johnny Rosenberg

unread,
Feb 21, 2015, 7:08:35 PM2/21/15
to autoke...@googlegroups.com
2015-02-21 22:57 GMT+01:00 Steve Fisher <xirc...@gmail.com>:

This is brilliant,  we need more posts like this.   I am not a python guy,  I use mainly text expansion,  but will post some of my "best" uses for autokey.   We need to get a bigger audience!

Steve


I also use AutoKey mainly for text expansion, especially for song titles with ”foreign” characters in them, such as ”Manchurian Beat (На Сопках Манчжурии)” and ”Yozora No Hoshi (夜空の星)”. Saves me some time now and then.

Among my many phrases (I don't even remember many of them…) I type things like ”ccc” for ”Ctrl+”, ”ggg” for ”AltGr+” and so on. I write a lot on forums… And of course I let AutoKey type things like ”as far as I know”, ”on the other hand”, ”or something like that” and other common phrases for me. Most of them in Swedish, but some in English too, obviously.

Some of my phrases corrects common misspelling errors. Very often it happens that I type the Swedish word ”ytterligare” as ”yttelrigare”. Somehow the left hand's ”r” gets delayed long enough for the right hand to hit the ”l”…

And I have my phrase (okay, it's actually a script, but still very simple…) for typing date and time and then save (Ctrl+s). In some types of text files it's nice to know when it was last edited without having to open a terminal or file manager, so I let the phrase type the date and time and then save, making reasonable sure that the time is the same as the file's time stamp…
It looks like this, very simple indeed, you have probably already figured it out:
keyboard.send_keys(time.strftime("%F %T")+"<ctrl>+s")

I can't see what I would use the mouse features for, though; I don't use the mouse that much.

So nothing complicated here, but still saving me some time now and then. Sorry for not being very exciting…
And here is another phrase (the following multi-line one):


Kind regards

Johnny Rosenberg
ジョニー・ローゼンバーグ

 

--
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.

Sven Mason

unread,
Feb 21, 2015, 7:18:08 PM2/21/15
to autoke...@googlegroups.com
I have a lot of scripts for Navigating windows, all my apps and instances of common apps are switched to using keys, also within some apps, for example in Thunderbird I have scripts to go up or down one message, or up and down within the current message (more difficult than it sounds and requires Thunderbird addons because under normal circumstances the results of up and down keys are location dependant within Thunderbird and there is no in built hotkey to differentiate these simple actions - crazy), also switching to specific Mozilla instances and tabs is a big one for me.
 
I have RSI setting in so many of my scripts are designed to reduce strain. I use the left Super key as my hotkey modifier, and normally numpad keys as the triggers. Many of these hotkeys perform different actions depending on what application I am in.
 
I have a script that copies sender email addresses from Thunderbird, this will act differently if in the main Thunderbird window or in a Compose window, there are some checks after sleeps to make sure correct window is active, then the cleanup section tries to extract only the simple email address from the data in the clipboard:

if 'Mail.Thunderbird' in winClass:
   
#copy emails reply-to address (try to get email address for message)
    keyboard
.send_keys('<ctrl>+r')
    time
.sleep(0.6)
   
#if expected reply window open then continue
    subwinClass
= window.get_active_class()
   
if 'Msgcompose.Thunderbird' in subwinClass:
        keyboard
.send_keys('<alt>+r<tab><tab>')
        time
.sleep(0.1)
        keyboard
.send_keys('<ctrl>+c<ctrl>+<f4>')
elif 'Msgcompose.Thunderbird' in winClass:
    keyboard
.send_keys('<alt>+r<tab><tab>')
    time
.sleep(0.1)
    keyboard
.send_keys('<ctrl>+c')
 
#cleanup email
if 'Msgcompose.Thunderbird' in winClass or 'Mail.Thunderbird' in winClass:
    time
.sleep(0.1)
    strEmail
= clipboard.get_clipboard()
   
if strEmail:
       
if "<" in strEmail:
            strPos
= strEmail.find("<")
            strPos
=strPos+1
            strEmail
= strEmail[strPos:]
       
if ">" in strEmail:
            strPos
= strEmail.find(">")
            strEmail
= strEmail[:strPos]
       
if "(" in strEmail:
            strPos
= strEmail.find("(")
            strPos
=strPos+1
            strEmail
= strEmail[strPos:]
       
if ")" in strEmail:
            strPos
= strEmail.find(")")
            strEmail
= strEmail[:strPos]  
        time
.sleep(0.2)  
        clipboard
.fill_clipboard(strEmail)

I will extend this to switching to a specific Firefox instance and tab and filling in then submitting a search box, all in one keystroke.

Another in Thunderbird are hotkeys to move messages to specific folders - again needing addons and a lot more difficult than it should be.


For RSI I have moved my copy/paste/cut keys to places like Super+tilde, Super+Tab, Super+Esc (for one hand, less strain than ctrl+x/c/v), and also Super+Numpad keys for two hand.





Sven Mason

unread,
Feb 21, 2015, 7:54:10 PM2/21/15
to autoke...@googlegroups.com
Hi Joe
Wish I could do more but so many projects as it is and I am no Linux programmer, nor even a Python one. I could look at managing a website. What is the current status? What would be the new form that the current contributors/community would want?

Maybe a Wordpress or Drupal based site?

A couple of years ago I basically took over the admin of http://e2d-international.org/, it is an international collective of direct democracy political parties (was trying to be like the Pirate collective), I agree the site is messy but I was trying to get it organized. The political parties that were/are part of the collective pretty much dropped off from being active in the international group so the content and drive to clean it up fizzed. The structure I was trying to build there was:

- A forum for open discussion about political DD and discussion of changes to the collective and site itself, I put a lot of work into trying to give the forum an intuitive structure, did not really get to the rest of the site:
http://www.e2d-international.org/forum/

- An internal voting system so any changes could be passed or rejected by voting members (I programmed that as a WordPress plugin, it is a very simple/ugly example of electronic DD, there would be better out there but it served its basic job), previous to that it seemed any admin member would go and add or remove anything they wanted which is OK for a sandbox but (as a direct democracy proponent) I think not the correct way for decisions to be made.

- Then the Wordpress site itself, I envisioned this would be more designed for casual visitors, to explain the movement and get them involved, that never happened. In fact I think Wordpress was probably not the correct base (that was setup before I came on) as I don't think that area should have been blog entry focused, I think it should have been more of a menu/static content structure, as easy as possible for casual browsers to find what they need.

- There was also a Wiki, that was leftover from previous admin and some members liked the environment. I was not so keen on it, I guess it created a common interface for working on things like statutes - but even those types of tasks I think would be better served using a focused tool and collaborative proceedure, something like PiratePad sessions. Also in the E2D situation I felt it did not work because a wiki needs activity to keep it accurate and full of up to date information, E2D did not have that involvement. I would see Autokey is probably in a similar situation, there will be 1 or 2 people administering and updating this information (like the program itself), and they will come and go, I know there will be months at a time where I would only have time to perform basic admin. There is nothing wrong with this as like E2D everything is volunteer, but if our goal is to encourage new users it can leave the project looking confusing, unfinished and unprofessional - unless we plan for this in the way we present the site. In my mind a more solid and static design would require less hands on admin to achieve a professional presentation than something like a wiki.


That is just some quick thoughts, I also maintain a few shared servers for my projects, like the E2D site I could tag an Autokey site onto one of those, the downside is I would be the only point of access (as I would have other things running on the server).

Sheshera Mysore

unread,
Jun 25, 2015, 7:07:20 AM6/25/15
to autoke...@googlegroups.com
I just started using AutoKey and Python. Here's one my favourite things to do with it:
I use this to search (Google) any piece of text that I highlight.
Do tell me if this can be made better too :)

import webbrowser
base="http://www.google.com/search?q="
phrase=clipboard.get_selection()

#Remove trailing or leading white space and find if there are multiple
#words.
phrase=phrase.strip()
singleWord=False
if phrase.find(' ')<0:
    singleWord=True
   
#Determine if phrase is a noun (or an actual title).
#Solely syntactically for now.
name=False
if phrase.istitle():
    name=True

#Generate search URL.
if singleWord:
    search_url=base+phrase

if (not singleWord) and (not name):
    phrase='+'.join(phrase.split())
    search_url=base+phrase
   
if (not singleWord) and (name):
    phrase='"'+phrase+'"'
    search_url=base+phrase
   
webbrowser.open_new_tab(search_url)
Reply all
Reply to author
Forward
0 new messages