//
// AppleScriptMaker.swift
// ffow2
//
// Created by user on 2016/09/27.
// Copyright © 2016年 user. All rights reserved.
//
import Foundation
func makeCompiledAppleScript(appName: String, key: String, modifierKeys: String) -> NSAppleScript? {
let source = "tell application \"System Events\"\n"
+ "tell process \"\(appName)\"\n"
+ "keystroke \"\(key)\" using \(modifierKeys)\n"
+ "end tell\n"
+ "end tell\n"
let appleScript = NSAppleScript(source: source)
var error: NSDictionary?
appleScript?.compileAndReturnError(&error)
return appleScript
}
func makeCompiledAppleScript(appName: String, keyCode: String, modifierKeys: String) -> NSAppleScript? {
let source = "tell application \"System Events\"\n"
+ "tell process \"\(appName)\"\n"
+ "key code \(keyCode) using \(modifierKeys)\n"
+ "end tell\n"
+ "end tell\n"
let appleScript = NSAppleScript(source: source)
var error: NSDictionary?
appleScript?.compileAndReturnError(&error)
return appleScript
}