autokey keypress script

4,938 views
Skip to first unread message

John

unread,
Apr 23, 2011, 9:12:28 PM4/23/11
to autokey-users
I am trying to create a script for use with minecraft but I have no
knowledge of programming. what I am trying to get the script to do is
press the "," key down but not release it. I found
keyboard.send_key(key, repeat=1) but I do not want it to repeat and I
am not sure how to modify it. I use a devorak keyboard so the forward
key in the game is set to "," instead of "w" , since the game has no
autorun feature I was hoping to accomplish this with autokey. Can
anyone help? (I have begun trying to learn python but I just started
so hopefully soon I will be able to do this sort of thing on my own
soon)

Chris D

unread,
Apr 25, 2011, 8:05:15 PM4/25/11
to autokey-users
If you look at the API documentation here:

http://autokey.googlecode.com/svn/trunk/doc/scripting/index.html

you will see that there is a keyboard.press_key() and
keyboard.release_key() which does what you want.

John

unread,
Apr 26, 2011, 2:39:58 AM4/26/11
to autokey-users
wierd the page I was looking at that I had followed links to (http://
autokey.sourceforge.net/apidoc/frames.html) only showed send_keys,
send_key, and fake_keypress . thank you for the link that helped a lot

Chris D

unread,
Apr 26, 2011, 7:04:25 PM4/26/11
to autokey-users
Can you tell me where you followed this link from? Unless it was from
a search engine or another forum, I'll need to update the link.

uni...@gmail.com

unread,
Mar 2, 2014, 5:43:31 AM3/2/14
to autoke...@googlegroups.com
Hello Chris D,

I am also trying to get a script to work with these commands but I have been unable to. What I want is something very simple: switch from one workspace to another (I am using linux mint), so it would be a pressing of ctrl+alt and then send arrow right and next release ctrl+alt. At least manually that's what I do.

The script I used is

keyboard.press_key("<ctrl>")
keyboard.press_key("<alt>")
keyboard.send_key("<right>")

keyboard.release_key("<ctrl>")
keyboard.release_key("<alt>")

However it doesn't works and I have no idea why :-(. I must be missing something very simple. Thank you for any help.

Regards

Joe

unread,
Mar 2, 2014, 6:14:10 PM3/2/14
to autoke...@googlegroups.com
Try

keyboard.send_keys("<ctrl>+<alt>+<right>")

Using "+" makes them all one multi-key press.

Without the "+", it will send them sequentially.

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.

uni...@gmail.com

unread,
Mar 3, 2014, 6:55:38 AM3/3/14
to autoke...@googlegroups.com
Thank you,

Unfortunately it didn't worked. I had already tried this sort of combination. I also checked to see if there is any script error in the view script error button  of autokey but nothing. Seems the script is running fine but doesn't do what it is supposed to do. :-(

Joe

unread,
Mar 3, 2014, 1:32:00 PM3/3/14
to autoke...@googlegroups.com
Barring further insight, the only other thing to try is to start autokey from a terminal window.
Then, do the minimum required to recreate your issue and then stop autokey.

autokey-gtk -l
or
autokey-qt -l

depending on which version of autokey you have installed. That's a lower case "ell".

This will produce a log of what autokey is doing.

It will probably show you what is wrong.

If it doesn't make sense, etc. copy and paste the log output into a post to this list and we'll take a look at it.

Joe

uni...@gmail.com

unread,
Mar 3, 2014, 3:38:08 PM3/3/14
to autoke...@googlegroups.com
Since the log registers every keystroke it is a bit confusing. Everything seems normal.
The file is caled music_D_and_d.py and just sends the command keyboard.send_keys("<ctrl>+<
alt>+<right>") when pressing the Shift+F combination.

2014-03-03 20:25:35,889 DEBUG - service - Raw key: u'f', modifiers: ['<shift>'], Key: F
2014-03-03 20:25:35,889 DEBUG - service - Window visible title: u'Terminal', Window class: u'gnome-terminal.Gnome-terminal'
2014-03-03 20:25:35,889 INFO - service - Matched hotkey phrase/script with prompt=False
2014-03-03 20:25:35,890 DEBUG - service - Script runner executing: Script('music_D_and_d')
2014-03-03 20:25:35,891 DEBUG - iomediator - Send via event interface
2014-03-03 20:25:35,892 DEBUG - service - Input stack at end of handle_keypress: [u'F']
2014-03-03 20:25:35,892 DEBUG - service - Ignored locking error in handle_keypress
2014-03-03 20:25:35,897 DEBUG - interface - Send modified key: modifiers: [u'<ctrl>', u'<alt>'] key: <right>
^[[1;7C2014-03-03 20:25:36,063 DEBUG - iomediator - <shift> released
2014-03-03 20:26:06,238 DEBUG - phrase-menu - Sorting phrase menu by usage count
2014-03-03 20:26:06,243 DEBUG - service - Received mouse click - resetting buffer
2014-03-03 20:26:07,157 DEBUG - service - Received mouse click - resetting buffer
2014-03-03 20:26:07,312 INFO - root - Shutting down
2014-03-03 20:26:07,312 INFO - service - Service shutting down

Thank you
Anders

Joe

unread,
Mar 3, 2014, 4:44:49 PM3/3/14
to autoke...@googlegroups.com
Looks good. The only thing I can think of is that your terminal might be capturing/filtering that keyboard shortcut, but if it works when you manually type it in the terminal, then that's probably not the case.

From just glancing at the code, the tryReleaseLock thing doesn't look like a problem.

Joe

uni...@gmail.com

unread,
Mar 4, 2014, 3:15:27 AM3/4/14
to autoke...@googlegroups.com
:-S

I have tried a different shortcut, F9, but the result was the same. How do I manually type this in the terminal? I have no experience on batch mode for autokey :-S.
 Does anyone had a similar issue? Maybe trying to reproduce it?

Anders

Joe

unread,
Mar 4, 2014, 3:46:55 AM3/4/14
to autoke...@googlegroups.com
I meant typing ctrl-alt-right on your keyboard into a terminal window. If that performs the desired action, then AutoKey appears to be doing something wrong, but I don't see what.

Joe

uni...@gmail.com

unread,
Mar 4, 2014, 4:16:37 AM3/4/14
to autoke...@googlegroups.com
I hope this is what you asked (Sorry if I am not understanding something, English is not my native language)
I opened autokey just has before and typed ctrl+alt+right. The workspace was switched as expected and this is what became written in the terminal.

2014-03-04 09:11:21,309 DEBUG - iomediator - <ctrl> pressed
2014-03-04 09:11:21,635 DEBUG - iomediator - <alt> pressed
2014-03-04 09:11:22,030 DEBUG - service - Raw key: '<right>', modifiers: ['<alt>', '<ctrl>'], Key: <right>
2014-03-04 09:11:22,030 DEBUG - service - Window visible title: u'Terminal', Window class: u'gnome-terminal.Gnome-terminal'
2014-03-04 09:11:22,031 DEBUG - service - No phrase/script matched hotkey
2014-03-04 09:11:22,400 DEBUG - iomediator - <alt> released
2014-03-04 09:11:22,411 DEBUG - iomediator - <ctrl> released
2014-03-04 09:11:29,803 DEBUG - phrase-menu - Sorting phrase menu by usage count
2014-03-04 09:11:29,808 DEBUG - service - Received mouse click - resetting buffer
2014-03-04 09:11:30,540 DEBUG - service - Received mouse click - resetting buffer
2014-03-04 09:11:30,678 INFO - root - Shutting down

Anders

Joe

unread,
Mar 4, 2014, 4:25:51 AM3/4/14
to autoke...@googlegroups.com
I just wanted to make sure it worked without AutoKey (AutoKey didn't need to be running for that test.) Since it does work, there appears to be a problem with AutoKey, but I have no idea what it might be. The original log you provided looks like it worked perfectly (other than the small detail that it didn't do what we expected  it to do.)

Maybe someone else who knows a bit more about AutoKey internals and Python will have some better ideas.

Joe

uni...@gmail.com

unread,
Mar 11, 2014, 3:50:16 PM3/11/14
to autoke...@googlegroups.com
Hello Joe,

I tried to ask for help on this issue but apparently there are no clues (almost nobody answered). Steve Fisher asked what desktop I was using and if I was using compiz. Does that means something to you? I am using xfce 4.10 and I might have activated Compiz since I used Blender once, but I am unsure.
I would really need to put this script working until 15 March and the only missing piece is this workspace switch :-(. Please help.

Regards
Anders
Reply all
Reply to author
Forward
0 new messages