Created
June 25, 2011 05:13
controlling keyboard with Jython
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/jython | |
# -*- coding: utf-8 -*- | |
# Copyright : (c) SAEKI Yoshiyasu | |
# License : MIT-style license | |
# <http://www.opensource.org/licenses/mit-license.php> | |
# last updated: 2011/06/25 | |
from java.awt import Robot | |
from java.awt.event import KeyEvent | |
import os | |
os.system(""" | |
osascript << EOF | |
tell application "TextEdit" | |
activate | |
end tell | |
EOF | |
""") | |
# == os.system("open /Applications/TextEdit.app") | |
rbt = Robot() | |
rbt.keyPress(KeyEvent.VK_SHIFT) | |
rbt.keyPress(KeyEvent.VK_H) | |
rbt.keyRelease(KeyEvent.VK_H) | |
rbt.keyRelease(KeyEvent.VK_SHIFT) | |
rbt.keyPress(KeyEvent.VK_E) | |
rbt.keyRelease(KeyEvent.VK_E) | |
rbt.keyPress(KeyEvent.VK_L) | |
rbt.keyRelease(KeyEvent.VK_L) | |
rbt.keyPress(KeyEvent.VK_L) | |
rbt.keyRelease(KeyEvent.VK_L) | |
rbt.keyPress(KeyEvent.VK_O) | |
rbt.keyRelease(KeyEvent.VK_O) | |
rbt.keyPress(KeyEvent.VK_PERIOD) | |
rbt.keyRelease(KeyEvent.VK_PERIOD) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment