Esempio n. 1
0
"""
Sends series of characters to UI. Mac version. Based on applescript.

Author Andrew Terekhine
Since 2014-11-23
"""
import os
import string
import time

import MacClipboardUtil
import MacCommon
import MacUtil
import SystemUtil

if SystemUtil.isMac():
    import applescript

if __name__ == "__main__":
    import sys, PythonCall
    PythonCall.PythonCall(sys.argv).execute()


def sendUnicodeTextAsKeyCodes(text):
    if len(text) == 0:
        return
    text = text.strip()
    command = "\nkeystroke \""
    for c in text:
        command += ("0x" + hex(ord(c))[2:].zfill(4))
    content = "tell application \"System Events\"" + command + "\" using option down\n end tell"
Esempio n. 2
0
"""
Sends series of characters to UI. Mac version. Based on applescript.

Author Andrew Terekhine
Since 2014-11-23
"""
import os
import string
import time

import MacClipboardUtil
import MacCommon
import MacUtil
import SystemUtil

if SystemUtil.isMac():
    import applescript

if __name__ == "__main__":
        import sys, PythonCall
        PythonCall.PythonCall(sys.argv).execute()

def sendUnicodeTextAsKeyCodes(text):
    if len(text) == 0:
        return
    text = text.strip()
    command = "\nkeystroke \""
    for c in text:
        command += ("0x" + hex(ord(c))[2:].zfill(4))
    content = "tell application \"System Events\"" + command + "\" using option down\n end tell"
    script = applescript.AppleScript(content)