From 81394c8c596200d6f05c4d02e11fba4a9218d168 Mon Sep 17 00:00:00 2001 From: antelle Date: Sat, 23 Jul 2016 10:48:56 +0300 Subject: [PATCH] darwin keewebhelper draft --- .gitignore | 2 + .../KeeWebHelper.xcodeproj/project.pbxproj | 248 ++++++++++++++++++ .../KeeWebHelper/KeeWebHelper/main.swift | 19 ++ 3 files changed, 269 insertions(+) create mode 100644 helper/darwin/KeeWebHelper/KeeWebHelper.xcodeproj/project.pbxproj create mode 100644 helper/darwin/KeeWebHelper/KeeWebHelper/main.swift diff --git a/.gitignore b/.gitignore index 5ea0dff4..ec48ff36 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,5 @@ keys/ *.user bin/ obj/ +*.xcworkspace/ +xcuserdata/ diff --git a/helper/darwin/KeeWebHelper/KeeWebHelper.xcodeproj/project.pbxproj b/helper/darwin/KeeWebHelper/KeeWebHelper.xcodeproj/project.pbxproj new file mode 100644 index 00000000..406939cf --- /dev/null +++ b/helper/darwin/KeeWebHelper/KeeWebHelper.xcodeproj/project.pbxproj @@ -0,0 +1,248 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 48395FC01D434F0000BF9A6E /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 48395FBF1D434F0000BF9A6E /* main.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 48395FBA1D434F0000BF9A6E /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 48395FBC1D434F0000BF9A6E /* KeeWebHelper */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = KeeWebHelper; sourceTree = BUILT_PRODUCTS_DIR; }; + 48395FBF1D434F0000BF9A6E /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 48395FB91D434F0000BF9A6E /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 48395FB31D434F0000BF9A6E = { + isa = PBXGroup; + children = ( + 48395FBE1D434F0000BF9A6E /* KeeWebHelper */, + 48395FBD1D434F0000BF9A6E /* Products */, + ); + sourceTree = ""; + }; + 48395FBD1D434F0000BF9A6E /* Products */ = { + isa = PBXGroup; + children = ( + 48395FBC1D434F0000BF9A6E /* KeeWebHelper */, + ); + name = Products; + sourceTree = ""; + }; + 48395FBE1D434F0000BF9A6E /* KeeWebHelper */ = { + isa = PBXGroup; + children = ( + 48395FBF1D434F0000BF9A6E /* main.swift */, + ); + path = KeeWebHelper; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 48395FBB1D434F0000BF9A6E /* KeeWebHelper */ = { + isa = PBXNativeTarget; + buildConfigurationList = 48395FC31D434F0000BF9A6E /* Build configuration list for PBXNativeTarget "KeeWebHelper" */; + buildPhases = ( + 48395FB81D434F0000BF9A6E /* Sources */, + 48395FB91D434F0000BF9A6E /* Frameworks */, + 48395FBA1D434F0000BF9A6E /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = KeeWebHelper; + productName = KeeWebHelper; + productReference = 48395FBC1D434F0000BF9A6E /* KeeWebHelper */; + productType = "com.apple.product-type.tool"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 48395FB41D434F0000BF9A6E /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0730; + LastUpgradeCheck = 0730; + ORGANIZATIONNAME = KeeWeb; + TargetAttributes = { + 48395FBB1D434F0000BF9A6E = { + CreatedOnToolsVersion = 7.3.1; + }; + }; + }; + buildConfigurationList = 48395FB71D434F0000BF9A6E /* Build configuration list for PBXProject "KeeWebHelper" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 48395FB31D434F0000BF9A6E; + productRefGroup = 48395FBD1D434F0000BF9A6E /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 48395FBB1D434F0000BF9A6E /* KeeWebHelper */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 48395FB81D434F0000BF9A6E /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 48395FC01D434F0000BF9A6E /* main.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 48395FC11D434F0000BF9A6E /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.11; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 48395FC21D434F0000BF9A6E /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.11; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + }; + name = Release; + }; + 48395FC41D434F0000BF9A6E /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 48395FC51D434F0000BF9A6E /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 48395FB71D434F0000BF9A6E /* Build configuration list for PBXProject "KeeWebHelper" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 48395FC11D434F0000BF9A6E /* Debug */, + 48395FC21D434F0000BF9A6E /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 48395FC31D434F0000BF9A6E /* Build configuration list for PBXNativeTarget "KeeWebHelper" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 48395FC41D434F0000BF9A6E /* Debug */, + 48395FC51D434F0000BF9A6E /* Release */, + ); + defaultConfigurationIsVisible = 0; + }; +/* End XCConfigurationList section */ + }; + rootObject = 48395FB41D434F0000BF9A6E /* Project object */; +} diff --git a/helper/darwin/KeeWebHelper/KeeWebHelper/main.swift b/helper/darwin/KeeWebHelper/KeeWebHelper/main.swift new file mode 100644 index 00000000..2d6d03be --- /dev/null +++ b/helper/darwin/KeeWebHelper/KeeWebHelper/main.swift @@ -0,0 +1,19 @@ +import Foundation + +let src = CGEventSourceCreate(CGEventSourceStateID.HIDSystemState) + +func pressChar(char: UniChar) { + pressCharUpDown(char, down: true) + pressCharUpDown(char, down: false) +} + +func pressCharUpDown(char: UniChar, down: Bool) { + var ch = char; + let keyEvent = CGEventCreateKeyboardEvent(src, 0, down) + CGEventKeyboardSetUnicodeString(keyEvent, 1, &ch) + CGEventPost(CGEventTapLocation.CGHIDEventTap, keyEvent) +} + +for char in "\n^A~A´A¼Î©~{*!+¢f4ыâ\n".utf16 { + pressChar(char) +}