Simple Autokey script to start a program with hotkey

1,037 views
Skip to first unread message

James Davis

unread,
May 17, 2019, 3:52:26 PM5/17/19
to autokey-users
As my first Autokey task I am trying to assign a hotkey to start the program Anydesk.

A lot of Googling did not show me how.

Example please?

Thanks.

Imre Neuwirth

unread,
May 17, 2019, 10:17:56 PM5/17/19
to autokey-users
It would have helped to know which Linux you are using,

In my case, I am using Linux Mint 19.1 and tested this as follows. In keyboard shortcut definitions, I selected custom definitions and clicked to add a new keyboard key combination.Named it "Autokey" and in the action box I added "autokey-gtk -c" (That's the version I am using,) and assigned a key combination (Alt-u)  because it's the second letter in the name and is an unused letter in my autokey macros scheme. Be sure not to assign a keyboard macro to the combination selected.
Message has been deleted

James Davis

unread,
May 18, 2019, 3:10:56 PM5/18/19
to autokey-users
Thanks, I'm using Zorin which is  Debian-based Linux kernel and GNOME interface 

Joe

unread,
May 18, 2019, 7:07:10 PM5/18/19
to autoke...@googlegroups.com
Welcome to the list, James.

You will need to write a script for this. You just have to know a little
Python3, which is the language AutoKey scripts are written in.

import subprocess
subprocess.run(["anydesk"])

will run anydesk when it is invoked (assuming it's in your PATH). If you
need to pass it arguments, then you add them to the list
["anydesk","arg1","arg2"]

subprocess has a lot of options. I have only used it in very simple
ways. You can learn more about it in the links below and on many other
webpages.

http://queirozf.com/entries/python-3-subprocess-examples

https://docs.python.org/3/library/subprocess.html

Start with this and come back if you have more questions.

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
> <mailto:autokey-user...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/autokey-users/f1ab80af-f6ff-44dd-b830-43a68414f513%40googlegroups.com
> <https://groups.google.com/d/msgid/autokey-users/f1ab80af-f6ff-44dd-b830-43a68414f513%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

James Davis

unread,
May 18, 2019, 10:14:03 PM5/18/19
to autokey-users
Thanks Joe,

I put:

import subprocess 
subprocess.run(["anydesk"]) 

In the Autokey and tried to run and got:

AttributeError: “module” object has no atttribute “run” 

jack

unread,
May 19, 2019, 2:32:28 AM5/19/19
to autoke...@googlegroups.com, James Davis
strange.

try:

import subprocess
subprocess.Popen(["anydesk"])



jack
the defaults won't help you
--
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/621472a5-5380-44ac-98ce-ca2d6eef64bf%40googlegroups.com.

Johnny Rosenberg

unread,
May 19, 2019, 3:38:55 AM5/19/19
to autoke...@googlegroups.com
Den lör 18 maj 2019 kl 21:10 skrev James Davis <mysti...@gmail.com>:
Thanks, I'm using Zorin which is  Debian-based Linux kernel and GNOME interface

Just for curiosity, is there a special reason why you want to use AutoKey for this? Most desktop environments, Gnome included, let you create keyboard shortcuts for starting specific apps, even with specific parameters.Something like this:
Or this:
I don't use Gnome myself, so I don't know how relevant those pages are.

Doing this with AutoKey reminded me a little bit of an expression that's common in my language: ”Gå inte över ån efter vatten”, meaning something like ”don't cross the river for water”, meaning ”don't over-complicate things”, sort of.


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.

James Davis

unread,
May 19, 2019, 9:20:18 AM5/19/19
to autoke...@googlegroups.com
Thanks, the second one worked!  The reason I'm using autokey is that I want to use autokey for some mouse clicks after Anydesk launches so that it automatically logs on to where I wan to go.

Johnny Rosenberg

unread,
May 19, 2019, 9:35:43 AM5/19/19
to autoke...@googlegroups.com
Den sön 19 maj 2019 kl 15:20 skrev James Davis <mysti...@gmail.com>:
Thanks, the second one worked!  The reason I'm using autokey is that I want to use autokey for some mouse clicks after Anydesk launches so that it automatically logs on to where I wan to go.

Ok, I guess that makes sense (even though I don't even know what Anydesk is).


Kind regards

Johnny Rosenberg
Reply all
Reply to author
Forward
0 new messages