├── .clang-format ├── .github ├── FUNDING.yml └── workflows │ ├── build.yml │ ├── lint.yml │ └── test.yml ├── .gitignore ├── LICENSE ├── README-ZH.md ├── README.md ├── melos.yaml ├── packages ├── keypress_simulator │ ├── .gitignore │ ├── .metadata │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README-ZH.md │ ├── README.md │ ├── analysis_options.yaml │ ├── example │ │ ├── .gitignore │ │ ├── .metadata │ │ ├── README.md │ │ ├── analysis_options.yaml │ │ ├── lib │ │ │ ├── main.dart │ │ │ └── pages │ │ │ │ └── home.dart │ │ ├── macos │ │ │ ├── .gitignore │ │ │ ├── Flutter │ │ │ │ ├── Flutter-Debug.xcconfig │ │ │ │ ├── Flutter-Release.xcconfig │ │ │ │ └── GeneratedPluginRegistrant.swift │ │ │ ├── Podfile │ │ │ ├── Podfile.lock │ │ │ ├── Runner.xcodeproj │ │ │ │ ├── project.pbxproj │ │ │ │ ├── project.xcworkspace │ │ │ │ │ └── xcshareddata │ │ │ │ │ │ └── IDEWorkspaceChecks.plist │ │ │ │ └── xcshareddata │ │ │ │ │ └── xcschemes │ │ │ │ │ └── Runner.xcscheme │ │ │ ├── Runner.xcworkspace │ │ │ │ ├── contents.xcworkspacedata │ │ │ │ └── xcshareddata │ │ │ │ │ └── IDEWorkspaceChecks.plist │ │ │ └── Runner │ │ │ │ ├── AppDelegate.swift │ │ │ │ ├── Assets.xcassets │ │ │ │ └── AppIcon.appiconset │ │ │ │ │ ├── Contents.json │ │ │ │ │ ├── app_icon_1024.png │ │ │ │ │ ├── app_icon_128.png │ │ │ │ │ ├── app_icon_16.png │ │ │ │ │ ├── app_icon_256.png │ │ │ │ │ ├── app_icon_32.png │ │ │ │ │ ├── app_icon_512.png │ │ │ │ │ └── app_icon_64.png │ │ │ │ ├── Base.lproj │ │ │ │ └── MainMenu.xib │ │ │ │ ├── Configs │ │ │ │ ├── AppInfo.xcconfig │ │ │ │ ├── Debug.xcconfig │ │ │ │ ├── Release.xcconfig │ │ │ │ └── Warnings.xcconfig │ │ │ │ ├── DebugProfile.entitlements │ │ │ │ ├── Info.plist │ │ │ │ ├── MainFlutterWindow.swift │ │ │ │ └── Release.entitlements │ │ ├── pubspec.yaml │ │ ├── web │ │ │ ├── favicon.png │ │ │ ├── icons │ │ │ │ ├── Icon-192.png │ │ │ │ ├── Icon-512.png │ │ │ │ ├── Icon-maskable-192.png │ │ │ │ └── Icon-maskable-512.png │ │ │ ├── index.html │ │ │ └── manifest.json │ │ └── windows │ │ │ ├── .gitignore │ │ │ ├── CMakeLists.txt │ │ │ ├── flutter │ │ │ ├── CMakeLists.txt │ │ │ ├── generated_plugin_registrant.cc │ │ │ ├── generated_plugin_registrant.h │ │ │ └── generated_plugins.cmake │ │ │ └── runner │ │ │ ├── CMakeLists.txt │ │ │ ├── Runner.rc │ │ │ ├── flutter_window.cpp │ │ │ ├── flutter_window.h │ │ │ ├── main.cpp │ │ │ ├── resource.h │ │ │ ├── resources │ │ │ └── app_icon.ico │ │ │ ├── runner.exe.manifest │ │ │ ├── utils.cpp │ │ │ ├── utils.h │ │ │ ├── win32_window.cpp │ │ │ └── win32_window.h │ ├── lib │ │ ├── keypress_simulator.dart │ │ └── src │ │ │ └── keypress_simulator.dart │ └── pubspec.yaml ├── keypress_simulator_macos │ ├── .gitignore │ ├── .metadata │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── analysis_options.yaml │ ├── macos │ │ ├── Classes │ │ │ └── KeypressSimulatorMacosPlugin.swift │ │ └── keypress_simulator_macos.podspec │ └── pubspec.yaml ├── keypress_simulator_platform_interface │ ├── .gitignore │ ├── .metadata │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── analysis_options.yaml │ ├── lib │ │ ├── keypress_simulator_platform_interface.dart │ │ └── src │ │ │ ├── keypress_simulator_method_channel.dart │ │ │ └── keypress_simulator_platform_interface.dart │ ├── pubspec.yaml │ └── test │ │ └── src │ │ └── keypress_simulator_method_channel_test.dart └── keypress_simulator_windows │ ├── .gitignore │ ├── .metadata │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── analysis_options.yaml │ ├── pubspec.yaml │ └── windows │ ├── .gitignore │ ├── CMakeLists.txt │ ├── include │ └── keypress_simulator_windows │ │ └── keypress_simulator_windows_plugin_c_api.h │ ├── keypress_simulator_windows_plugin.cpp │ ├── keypress_simulator_windows_plugin.h │ ├── keypress_simulator_windows_plugin_c_api.cpp │ └── test │ └── keypress_simulator_windows_plugin_test.cpp └── pubspec.yaml /.clang-format: -------------------------------------------------------------------------------- 1 | # Defines the Chromium style for automatic reformatting. 2 | # http://clang.llvm.org/docs/ClangFormatStyleOptions.html 3 | BasedOnStyle: Chromium 4 | # This defaults to 'Auto'. Explicitly set it for a while, so that 5 | # 'vector >' in existing files gets formatted to 6 | # 'vector>'. ('Auto' means that clang-format will only use 7 | # 'int>>' if the file already contains at least one such instance.) 8 | Standard: Cpp11 9 | SortIncludes: true 10 | --- 11 | Language: ObjC 12 | ColumnLimit: 100 13 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | liberapay: lijy91 2 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: build 2 | 3 | on: 4 | push: 5 | branches: [main, dev] 6 | pull_request: 7 | branches: [main] 8 | 9 | jobs: 10 | build-macos: 11 | runs-on: macos-latest 12 | steps: 13 | - uses: actions/checkout@v3 14 | - uses: subosito/flutter-action@v2 15 | with: 16 | flutter-version: "3.16.8" 17 | channel: "stable" 18 | - uses: bluefireteam/melos-action@v2 19 | - working-directory: ./packages/keypress_simulator/example 20 | run: | 21 | melos bs 22 | flutter build macos --release 23 | 24 | build-web: 25 | runs-on: macos-latest 26 | steps: 27 | - uses: actions/checkout@v3 28 | - uses: subosito/flutter-action@v2 29 | with: 30 | flutter-version: "3.16.8" 31 | channel: "stable" 32 | - uses: bluefireteam/melos-action@v2 33 | - working-directory: ./packages/keypress_simulator/example 34 | run: | 35 | melos bs 36 | flutter build web --release 37 | 38 | build-windows: 39 | runs-on: windows-latest 40 | steps: 41 | - uses: actions/checkout@v3 42 | - uses: subosito/flutter-action@v2 43 | with: 44 | flutter-version: "3.16.8" 45 | channel: "stable" 46 | - uses: bluefireteam/melos-action@v2 47 | - working-directory: ./packages/keypress_simulator/example 48 | run: | 49 | melos bs 50 | flutter build windows --release 51 | -------------------------------------------------------------------------------- /.github/workflows/lint.yml: -------------------------------------------------------------------------------- 1 | name: lint 2 | 3 | on: 4 | push: 5 | branches: [main, dev] 6 | pull_request: 7 | branches: [main] 8 | 9 | jobs: 10 | analyze: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v3 14 | - uses: subosito/flutter-action@v2 15 | with: 16 | flutter-version: "3.16.8" 17 | channel: "stable" 18 | - uses: bluefireteam/melos-action@v2 19 | - run: melos run analyze 20 | 21 | format: 22 | runs-on: ubuntu-latest 23 | steps: 24 | - uses: actions/checkout@v3 25 | - uses: subosito/flutter-action@v2 26 | with: 27 | flutter-version: "3.16.8" 28 | channel: "stable" 29 | cache: true 30 | - uses: bluefireteam/melos-action@v2 31 | - run: melos run format-check 32 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: test 2 | 3 | on: 4 | push: 5 | branches: [main, dev] 6 | pull_request: 7 | branches: [main] 8 | 9 | jobs: 10 | test: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v3 14 | - uses: subosito/flutter-action@v2 15 | with: 16 | flutter-version: "3.16.8" 17 | channel: "stable" 18 | cache: true 19 | - uses: bluefireteam/melos-action@v2 20 | - run: melos run test --no-select 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .dart_tool/ 2 | .idea/ 3 | 4 | *.iml 5 | pubspec_overrides.yaml 6 | pubspec.lock 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022-2024 LiJianying 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README-ZH.md: -------------------------------------------------------------------------------- 1 | > **🚀 快速发布您的应用**: 试试 [Fastforge](https://fastforge.dev) - 构建、打包和分发您的 Flutter 应用最简单的方式。 2 | 3 | # keypress_simulator 4 | 5 | [![pub version][pub-image]][pub-url] [![][discord-image]][discord-url] 6 | 7 | [pub-image]: https://img.shields.io/pub/v/keypress_simulator.svg 8 | [pub-url]: https://pub.dev/packages/keypress_simulator 9 | [discord-image]: https://img.shields.io/discord/884679008049037342.svg 10 | [discord-url]: https://discord.gg/zPa6EZ2jqb 11 | 12 | 这个插件允许 Flutter 桌面应用模拟按键操作。 13 | 14 | --- 15 | 16 | [English](./README.md) | 简体中文 17 | 18 | --- 19 | 20 | 21 | 22 | 23 | - [平台支持](#%E5%B9%B3%E5%8F%B0%E6%94%AF%E6%8C%81) 24 | - [快速开始](#%E5%BF%AB%E9%80%9F%E5%BC%80%E5%A7%8B) 25 | - [安装](#%E5%AE%89%E8%A3%85) 26 | - [用法](#%E7%94%A8%E6%B3%95) 27 | - [谁在用使用它?](#%E8%B0%81%E5%9C%A8%E7%94%A8%E4%BD%BF%E7%94%A8%E5%AE%83) 28 | - [许可证](#%E8%AE%B8%E5%8F%AF%E8%AF%81) 29 | 30 | 31 | 32 | ## 平台支持 33 | 34 | | Linux | macOS | Windows | 35 | | :---: | :---: | :-----: | 36 | | ➖ | ✔️ | ✔️ | 37 | 38 | ## 快速开始 39 | 40 | ### 安装 41 | 42 | 将此添加到你的软件包的 pubspec.yaml 文件: 43 | 44 | ```yaml 45 | dependencies: 46 | keypress_simulator: ^0.2.0 47 | ``` 48 | 49 | ### 用法 50 | 51 | ```dart 52 | import 'package:keypress_simulator/keypress_simulator.dart'; 53 | 54 | // 1. Simulate pressing ⌘ + C 55 | 56 | // 1.1 Simulate key down 57 | await keyPressSimulator.simulateKeyDown( 58 | PhysicalKeyboardKey.keyC, 59 | [ModifierKey.metaModifier], 60 | ); 61 | 62 | // 1.2 Simulate key up 63 | await keyPressSimulator.simulateKeyUp( 64 | PhysicalKeyboardKey.keyC, 65 | [ModifierKey.metaModifier], 66 | ); 67 | 68 | // 2. Simulate long pressing ⌘ + space 69 | 70 | // 2.1. Simulate key down 71 | await keyPressSimulator.simulateKeyDown( 72 | PhysicalKeyboardKey.space, 73 | [ModifierKey.metaModifier], 74 | ); 75 | 76 | await Future.delayed(const Duration(seconds: 5)); 77 | 78 | // 2.2. Simulate key up 79 | await keyPressSimulator.simulateKeyUp( 80 | PhysicalKeyboardKey.space, 81 | [ModifierKey.metaModifier], 82 | ); 83 | ``` 84 | 85 | > 请看这个插件的示例应用,以了解完整的例子。 86 | 87 | ## 谁在用使用它? 88 | 89 | - [Biyi (比译)](https://biyidev.com/) - 一个便捷的翻译和词典应用程序。 90 | 91 | ## 许可证 92 | 93 | [MIT](./LICENSE) 94 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | > **🚀 Ship Your App Faster**: Try [Fastforge](https://fastforge.dev) - The simplest way to build, package and distribute your Flutter apps. 2 | 3 | # keypress_simulator 4 | 5 | [![pub version][pub-image]][pub-url] [![][discord-image]][discord-url] 6 | 7 | [pub-image]: https://img.shields.io/pub/v/keypress_simulator.svg 8 | [pub-url]: https://pub.dev/packages/keypress_simulator 9 | [discord-image]: https://img.shields.io/discord/884679008049037342.svg 10 | [discord-url]: https://discord.gg/zPa6EZ2jqb 11 | 12 | This plugin allows Flutter desktop apps to simulate key presses. 13 | 14 | --- 15 | 16 | English | [简体中文](./README-ZH.md) 17 | 18 | --- 19 | 20 | 21 | 22 | 23 | - [Platform Support](#platform-support) 24 | - [Quick Start](#quick-start) 25 | - [Installation](#installation) 26 | - [Usage](#usage) 27 | - [Who's using it?](#whos-using-it) 28 | - [License](#license) 29 | 30 | 31 | 32 | ## Platform Support 33 | 34 | | Linux | macOS | Windows | 35 | | :---: | :---: | :-----: | 36 | | ➖ | ✔️ | ✔️ | 37 | 38 | ## Quick Start 39 | 40 | ### Installation 41 | 42 | Add this to your package's pubspec.yaml file: 43 | 44 | ```yaml 45 | dependencies: 46 | keypress_simulator: ^0.2.0 47 | ``` 48 | 49 | ### Usage 50 | 51 | ```dart 52 | import 'package:keypress_simulator/keypress_simulator.dart'; 53 | 54 | // 1. Simulate pressing ⌘ + C 55 | 56 | // 1.1 Simulate key down 57 | await keyPressSimulator.simulateKeyDown( 58 | PhysicalKeyboardKey.keyC, 59 | [ModifierKey.metaModifier], 60 | ); 61 | 62 | // 1.2 Simulate key up 63 | await keyPressSimulator.simulateKeyUp( 64 | PhysicalKeyboardKey.keyC, 65 | [ModifierKey.metaModifier], 66 | ); 67 | 68 | // 2. Simulate long pressing ⌘ + space 69 | 70 | // 2.1. Simulate key down 71 | await keyPressSimulator.simulateKeyDown( 72 | PhysicalKeyboardKey.space, 73 | [ModifierKey.metaModifier], 74 | ); 75 | 76 | await Future.delayed(const Duration(seconds: 5)); 77 | 78 | // 2.2. Simulate key up 79 | await keyPressSimulator.simulateKeyUp( 80 | PhysicalKeyboardKey.space, 81 | [ModifierKey.metaModifier], 82 | ); 83 | ``` 84 | 85 | > Please see the example app of this plugin for a full example. 86 | 87 | ## Who's using it? 88 | 89 | - [Biyi (比译)](https://biyidev.com/) - A convenient translation and dictionary app. 90 | 91 | ## License 92 | 93 | [MIT](./LICENSE) 94 | -------------------------------------------------------------------------------- /melos.yaml: -------------------------------------------------------------------------------- 1 | name: keypress_simulator_workspace 2 | repository: https://github.com/leanflutter/keypress_simulator 3 | 4 | packages: 5 | - examples/** 6 | - packages/** 7 | 8 | command: 9 | bootstrap: 10 | # Uses the pubspec_overrides.yaml instead of having Melos modifying the lock file. 11 | usePubspecOverrides: true 12 | 13 | scripts: 14 | analyze: 15 | exec: flutter analyze --fatal-infos 16 | description: Run `flutter analyze` for all packages. 17 | 18 | test: 19 | exec: flutter test 20 | description: Run `flutter test` for a specific package. 21 | packageFilters: 22 | dirExists: 23 | - test 24 | 25 | format: 26 | exec: dart format . --fix 27 | description: Run `dart format` for all packages. 28 | 29 | format-check: 30 | exec: dart format . --fix --set-exit-if-changed 31 | description: Run `dart format` checks for all packages. 32 | 33 | fix: 34 | exec: dart fix . --apply 35 | description: Run `dart fix` for all packages. 36 | -------------------------------------------------------------------------------- /packages/keypress_simulator/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | .vscode/ 22 | 23 | # Flutter/Dart/Pub related 24 | # Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. 25 | /pubspec.lock 26 | **/doc/api/ 27 | .dart_tool/ 28 | .packages 29 | build/ 30 | -------------------------------------------------------------------------------- /packages/keypress_simulator/.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: db747aa1331bd95bc9b3874c842261ca2d302cd5 8 | channel: stable 9 | 10 | project_type: plugin 11 | -------------------------------------------------------------------------------- /packages/keypress_simulator/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.2.0 2 | 3 | * feat: Convert to federated plugin 4 | 5 | ## 0.1.0 6 | 7 | * First release. 8 | -------------------------------------------------------------------------------- /packages/keypress_simulator/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022-2024 LiJianying 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /packages/keypress_simulator/README-ZH.md: -------------------------------------------------------------------------------- 1 | ../../README-ZH.md -------------------------------------------------------------------------------- /packages/keypress_simulator/README.md: -------------------------------------------------------------------------------- 1 | ../../README.md -------------------------------------------------------------------------------- /packages/keypress_simulator/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:mostly_reasonable_lints/flutter.yaml 2 | -------------------------------------------------------------------------------- /packages/keypress_simulator/example/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | #.vscode/ 22 | 23 | # Flutter/Dart/Pub related 24 | **/doc/api/ 25 | **/ios/Flutter/.last_build_id 26 | .dart_tool/ 27 | .flutter-plugins 28 | .flutter-plugins-dependencies 29 | .packages 30 | .pub-cache/ 31 | .pub/ 32 | /build/ 33 | 34 | # Web related 35 | 36 | # Symbolication related 37 | app.*.symbols 38 | 39 | # Obfuscation related 40 | app.*.map.json 41 | 42 | # Android Studio will place build artifacts here 43 | /android/app/debug 44 | /android/app/profile 45 | /android/app/release 46 | -------------------------------------------------------------------------------- /packages/keypress_simulator/example/.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: db747aa1331bd95bc9b3874c842261ca2d302cd5 8 | channel: stable 9 | 10 | project_type: app 11 | -------------------------------------------------------------------------------- /packages/keypress_simulator/example/README.md: -------------------------------------------------------------------------------- 1 | # keypress_simulator_example 2 | 3 | Demonstrates how to use the keypress_simulator plugin. 4 | 5 | ## Getting Started 6 | 7 | This project is a starting point for a Flutter application. 8 | 9 | A few resources to get you started if this is your first Flutter project: 10 | 11 | - [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) 12 | - [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) 13 | 14 | For help getting started with Flutter, view our 15 | [online documentation](https://flutter.dev/docs), which offers tutorials, 16 | samples, guidance on mobile development, and a full API reference. 17 | -------------------------------------------------------------------------------- /packages/keypress_simulator/example/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:mostly_reasonable_lints/flutter.yaml 2 | -------------------------------------------------------------------------------- /packages/keypress_simulator/example/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:bot_toast/bot_toast.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:keypress_simulator_example/pages/home.dart'; 4 | 5 | void main() { 6 | WidgetsFlutterBinding.ensureInitialized(); 7 | hotKeyManager.unregisterAll(); 8 | 9 | runApp(const MyApp()); 10 | } 11 | 12 | class MyApp extends StatefulWidget { 13 | const MyApp({super.key}); 14 | 15 | @override 16 | State createState() => _MyAppState(); 17 | } 18 | 19 | class _MyAppState extends State { 20 | @override 21 | Widget build(BuildContext context) { 22 | return MaterialApp( 23 | theme: ThemeData( 24 | primaryColor: const Color(0xff416ff4), 25 | canvasColor: Colors.white, 26 | scaffoldBackgroundColor: const Color(0xffF7F9FB), 27 | dividerColor: Colors.grey.withOpacity(0.3), 28 | ), 29 | builder: BotToastInit(), 30 | navigatorObservers: [BotToastNavigatorObserver()], 31 | home: const HomePage(), 32 | ); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /packages/keypress_simulator/example/lib/pages/home.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: deprecated_member_use 2 | 3 | import 'dart:io'; 4 | 5 | import 'package:bot_toast/bot_toast.dart'; 6 | import 'package:flutter/foundation.dart'; 7 | import 'package:flutter/material.dart'; 8 | import 'package:flutter/services.dart'; 9 | import 'package:hotkey_manager/hotkey_manager.dart'; 10 | import 'package:keypress_simulator/keypress_simulator.dart'; 11 | import 'package:preference_list/preference_list.dart'; 12 | 13 | final hotKeyManager = HotKeyManager.instance; 14 | 15 | final kShortcutSimulateCtrlT = HotKey( 16 | KeyCode.keyT, 17 | modifiers: [ 18 | Platform.isMacOS ? KeyModifier.meta : KeyModifier.control, 19 | ], 20 | ); 21 | 22 | final kShortcutSimulateCtrlC = HotKey( 23 | KeyCode.keyC, 24 | modifiers: [ 25 | KeyModifier.shift, 26 | Platform.isMacOS ? KeyModifier.meta : KeyModifier.control, 27 | ], 28 | ); 29 | 30 | final kShortcutSimulateCtrlV = HotKey( 31 | KeyCode.keyV, 32 | modifiers: [ 33 | KeyModifier.shift, 34 | Platform.isMacOS ? KeyModifier.meta : KeyModifier.control, 35 | ], 36 | ); 37 | 38 | class HomePage extends StatefulWidget { 39 | const HomePage({super.key}); 40 | 41 | @override 42 | State createState() => _HomePageState(); 43 | } 44 | 45 | class _HomePageState extends State { 46 | bool _isRegisteredHotKeys = false; 47 | bool _isAccessAllowed = false; 48 | 49 | @override 50 | void initState() { 51 | super.initState(); 52 | _init(); 53 | } 54 | 55 | Future _init() async { 56 | _isAccessAllowed = await keyPressSimulator.isAccessAllowed(); 57 | setState(() {}); 58 | } 59 | 60 | void _registerHotKeys() { 61 | // 初始化快捷键 62 | hotKeyManager.unregisterAll(); 63 | hotKeyManager.register( 64 | kShortcutSimulateCtrlT, 65 | keyDownHandler: (_) async { 66 | if (kDebugMode) { 67 | print('simulateCtrlAKeyPress'); 68 | } 69 | await keyPressSimulator.simulateKeyDown( 70 | PhysicalKeyboardKey.keyA, 71 | [ 72 | Platform.isMacOS 73 | ? ModifierKey.metaModifier 74 | : ModifierKey.controlModifier, 75 | ], 76 | ); 77 | await keyPressSimulator.simulateKeyUp( 78 | PhysicalKeyboardKey.keyA, 79 | [ 80 | Platform.isMacOS 81 | ? ModifierKey.metaModifier 82 | : ModifierKey.controlModifier, 83 | ], 84 | ); 85 | if (kDebugMode) { 86 | print('simulateCtrlCKeyPress'); 87 | } 88 | await keyPressSimulator.simulateCtrlCKeyPress(); 89 | await Future.delayed(const Duration(milliseconds: 200)); 90 | if (kDebugMode) { 91 | print('simulateCtrlVKeyPress'); 92 | } 93 | ClipboardData? data = await Clipboard.getData(Clipboard.kTextPlain); 94 | await Clipboard.setData( 95 | ClipboardData( 96 | text: 'KPS: ${data?.text}', 97 | ), 98 | ); 99 | await keyPressSimulator.simulateCtrlVKeyPress(); 100 | }, 101 | ); 102 | hotKeyManager.register( 103 | kShortcutSimulateCtrlC, 104 | keyDownHandler: (_) async { 105 | if (kDebugMode) { 106 | print('simulateCtrlCKeyPress'); 107 | } 108 | keyPressSimulator.simulateCtrlCKeyPress(); 109 | }, 110 | ); 111 | hotKeyManager.register( 112 | kShortcutSimulateCtrlV, 113 | keyDownHandler: (_) async { 114 | if (kDebugMode) { 115 | print('simulateCtrlVKeyPress'); 116 | } 117 | ClipboardData? data = await Clipboard.getData(Clipboard.kTextPlain); 118 | await Clipboard.setData( 119 | ClipboardData( 120 | text: 'KPS: ${data?.text}', 121 | ), 122 | ); 123 | keyPressSimulator.simulateCtrlVKeyPress(); 124 | }, 125 | ); 126 | } 127 | 128 | Widget _buildBody(BuildContext context) { 129 | return PreferenceList( 130 | children: [ 131 | PreferenceListSwitchItem( 132 | title: const Text('Register hotkeys'), 133 | value: _isRegisteredHotKeys, 134 | onChanged: ((value) { 135 | if (value) { 136 | _registerHotKeys(); 137 | } else { 138 | hotKeyManager.unregisterAll(); 139 | } 140 | setState(() { 141 | _isRegisteredHotKeys = value; 142 | }); 143 | }), 144 | ), 145 | if (Platform.isMacOS) 146 | PreferenceListSection( 147 | children: [ 148 | PreferenceListItem( 149 | title: const Text('isAccessAllowed'), 150 | accessoryView: Text('$_isAccessAllowed'), 151 | onTap: () async { 152 | bool allowed = await keyPressSimulator.isAccessAllowed(); 153 | BotToast.showText(text: 'allowed: $allowed'); 154 | setState(() { 155 | _isAccessAllowed = allowed; 156 | }); 157 | }, 158 | ), 159 | PreferenceListItem( 160 | title: const Text('requestAccess'), 161 | onTap: () async { 162 | await keyPressSimulator.requestAccess(); 163 | }, 164 | ), 165 | ], 166 | ), 167 | PreferenceListSection( 168 | title: const Text('Examples'), 169 | children: [ 170 | PreferenceListItem( 171 | title: const Text('Active Spotlight'), 172 | onTap: () async { 173 | await keyPressSimulator.simulateKeyDown( 174 | PhysicalKeyboardKey.space, 175 | [ModifierKey.metaModifier], 176 | ); 177 | await keyPressSimulator.simulateKeyUp( 178 | PhysicalKeyboardKey.space, 179 | [ModifierKey.metaModifier], 180 | ); 181 | }, 182 | ), 183 | PreferenceListItem( 184 | title: const Text('Active Siri'), 185 | onTap: () async { 186 | await keyPressSimulator.simulateKeyDown( 187 | PhysicalKeyboardKey.space, 188 | [ModifierKey.metaModifier], 189 | ); 190 | await Future.delayed(const Duration(seconds: 6)); 191 | await keyPressSimulator.simulateKeyUp( 192 | PhysicalKeyboardKey.space, 193 | [ModifierKey.metaModifier], 194 | ); 195 | }, 196 | ), 197 | PreferenceListItem( 198 | title: const Text('Screenshot'), 199 | onTap: () async { 200 | await Future.delayed(const Duration(seconds: 3)); 201 | if (Platform.isMacOS) { 202 | await keyPressSimulator.simulateKeyDown( 203 | PhysicalKeyboardKey.digit4, 204 | [ 205 | ModifierKey.shiftModifier, 206 | ModifierKey.metaModifier, 207 | ], 208 | ); 209 | await keyPressSimulator.simulateKeyUp( 210 | PhysicalKeyboardKey.digit4, 211 | [ 212 | ModifierKey.shiftModifier, 213 | ModifierKey.metaModifier, 214 | ], 215 | ); 216 | } else if (Platform.isWindows) { 217 | await keyPressSimulator.simulateKeyDown( 218 | PhysicalKeyboardKey.f1, 219 | [ModifierKey.controlModifier], 220 | ); 221 | await keyPressSimulator.simulateKeyUp( 222 | PhysicalKeyboardKey.f1, 223 | [ModifierKey.controlModifier], 224 | ); 225 | } 226 | }, 227 | ), 228 | ], 229 | ), 230 | ], 231 | ); 232 | } 233 | 234 | @override 235 | Widget build(BuildContext context) { 236 | return Scaffold( 237 | appBar: AppBar( 238 | title: const Text('Plugin example app'), 239 | ), 240 | body: _buildBody(context), 241 | ); 242 | } 243 | } 244 | -------------------------------------------------------------------------------- /packages/keypress_simulator/example/macos/.gitignore: -------------------------------------------------------------------------------- 1 | # Flutter-related 2 | **/Flutter/ephemeral/ 3 | **/Pods/ 4 | 5 | # Xcode-related 6 | **/dgph 7 | **/xcuserdata/ 8 | -------------------------------------------------------------------------------- /packages/keypress_simulator/example/macos/Flutter/Flutter-Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /packages/keypress_simulator/example/macos/Flutter/Flutter-Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /packages/keypress_simulator/example/macos/Flutter/GeneratedPluginRegistrant.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | import FlutterMacOS 6 | import Foundation 7 | 8 | import hotkey_manager 9 | import keypress_simulator_macos 10 | 11 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { 12 | HotkeyManagerPlugin.register(with: registry.registrar(forPlugin: "HotkeyManagerPlugin")) 13 | KeypressSimulatorMacosPlugin.register(with: registry.registrar(forPlugin: "KeypressSimulatorMacosPlugin")) 14 | } 15 | -------------------------------------------------------------------------------- /packages/keypress_simulator/example/macos/Podfile: -------------------------------------------------------------------------------- 1 | platform :osx, '10.14' 2 | 3 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 4 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 5 | 6 | project 'Runner', { 7 | 'Debug' => :debug, 8 | 'Profile' => :release, 9 | 'Release' => :release, 10 | } 11 | 12 | def flutter_root 13 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) 14 | unless File.exist?(generated_xcode_build_settings_path) 15 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" 16 | end 17 | 18 | File.foreach(generated_xcode_build_settings_path) do |line| 19 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 20 | return matches[1].strip if matches 21 | end 22 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" 23 | end 24 | 25 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 26 | 27 | flutter_macos_podfile_setup 28 | 29 | target 'Runner' do 30 | use_frameworks! 31 | use_modular_headers! 32 | 33 | flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) 34 | end 35 | 36 | post_install do |installer| 37 | installer.pods_project.targets.each do |target| 38 | flutter_additional_macos_build_settings(target) 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /packages/keypress_simulator/example/macos/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - FlutterMacOS (1.0.0) 3 | - HotKey (0.2.0) 4 | - hotkey_manager (0.0.1): 5 | - FlutterMacOS 6 | - HotKey 7 | - keypress_simulator_macos (0.0.1): 8 | - FlutterMacOS 9 | 10 | DEPENDENCIES: 11 | - FlutterMacOS (from `Flutter/ephemeral`) 12 | - hotkey_manager (from `Flutter/ephemeral/.symlinks/plugins/hotkey_manager/macos`) 13 | - keypress_simulator_macos (from `Flutter/ephemeral/.symlinks/plugins/keypress_simulator_macos/macos`) 14 | 15 | SPEC REPOS: 16 | trunk: 17 | - HotKey 18 | 19 | EXTERNAL SOURCES: 20 | FlutterMacOS: 21 | :path: Flutter/ephemeral 22 | hotkey_manager: 23 | :path: Flutter/ephemeral/.symlinks/plugins/hotkey_manager/macos 24 | keypress_simulator_macos: 25 | :path: Flutter/ephemeral/.symlinks/plugins/keypress_simulator_macos/macos 26 | 27 | SPEC CHECKSUMS: 28 | FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24 29 | HotKey: e96d8a2ddbf4591131e2bb3f54e69554d90cdca6 30 | hotkey_manager: c32bf0bfe8f934b7bc17ab4ad5c4c142960b023c 31 | keypress_simulator_macos: f8556f9101f9f2f175652e0bceddf0fe82a4c6b2 32 | 33 | PODFILE CHECKSUM: 353c8bcc5d5b0994e508d035b5431cfe18c1dea7 34 | 35 | COCOAPODS: 1.14.3 36 | -------------------------------------------------------------------------------- /packages/keypress_simulator/example/macos/Runner.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 54; 7 | objects = { 8 | 9 | /* Begin PBXAggregateTarget section */ 10 | 33CC111A2044C6BA0003C045 /* Flutter Assemble */ = { 11 | isa = PBXAggregateTarget; 12 | buildConfigurationList = 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */; 13 | buildPhases = ( 14 | 33CC111E2044C6BF0003C045 /* ShellScript */, 15 | ); 16 | dependencies = ( 17 | ); 18 | name = "Flutter Assemble"; 19 | productName = FLX; 20 | }; 21 | /* End PBXAggregateTarget section */ 22 | 23 | /* Begin PBXBuildFile section */ 24 | 28F80CB5B7CFDE3486C758D6 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 76939868F7A196829F74C69E /* Pods_Runner.framework */; }; 25 | 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */; }; 26 | 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC10F02044A3C60003C045 /* AppDelegate.swift */; }; 27 | 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; 28 | 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; 29 | 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; 30 | /* End PBXBuildFile section */ 31 | 32 | /* Begin PBXContainerItemProxy section */ 33 | 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */ = { 34 | isa = PBXContainerItemProxy; 35 | containerPortal = 33CC10E52044A3C60003C045 /* Project object */; 36 | proxyType = 1; 37 | remoteGlobalIDString = 33CC111A2044C6BA0003C045; 38 | remoteInfo = FLX; 39 | }; 40 | /* End PBXContainerItemProxy section */ 41 | 42 | /* Begin PBXCopyFilesBuildPhase section */ 43 | 33CC110E2044A8840003C045 /* Bundle Framework */ = { 44 | isa = PBXCopyFilesBuildPhase; 45 | buildActionMask = 2147483647; 46 | dstPath = ""; 47 | dstSubfolderSpec = 10; 48 | files = ( 49 | ); 50 | name = "Bundle Framework"; 51 | runOnlyForDeploymentPostprocessing = 0; 52 | }; 53 | /* End PBXCopyFilesBuildPhase section */ 54 | 55 | /* Begin PBXFileReference section */ 56 | 0C242688C3B2D08C134EB8DB /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; 57 | 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; }; 58 | 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = ""; }; 59 | 33CC10ED2044A3C60003C045 /* keypress_simulator_example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = keypress_simulator_example.app; sourceTree = BUILT_PRODUCTS_DIR; }; 60 | 33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 61 | 33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = ""; }; 62 | 33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; 63 | 33CC10F72044A3C60003C045 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = Runner/Info.plist; sourceTree = ""; }; 64 | 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainFlutterWindow.swift; sourceTree = ""; }; 65 | 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = ""; }; 66 | 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = ""; }; 67 | 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = ""; }; 68 | 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; }; 69 | 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; }; 70 | 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; 71 | 668CC059647136DFBEF2BCFC /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; 72 | 76939868F7A196829F74C69E /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 73 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; 74 | 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; 75 | F6F89ECA31294B2873C9D00B /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; 76 | /* End PBXFileReference section */ 77 | 78 | /* Begin PBXFrameworksBuildPhase section */ 79 | 33CC10EA2044A3C60003C045 /* Frameworks */ = { 80 | isa = PBXFrameworksBuildPhase; 81 | buildActionMask = 2147483647; 82 | files = ( 83 | 28F80CB5B7CFDE3486C758D6 /* Pods_Runner.framework in Frameworks */, 84 | ); 85 | runOnlyForDeploymentPostprocessing = 0; 86 | }; 87 | /* End PBXFrameworksBuildPhase section */ 88 | 89 | /* Begin PBXGroup section */ 90 | 33BA886A226E78AF003329D5 /* Configs */ = { 91 | isa = PBXGroup; 92 | children = ( 93 | 33E5194F232828860026EE4D /* AppInfo.xcconfig */, 94 | 9740EEB21CF90195004384FC /* Debug.xcconfig */, 95 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, 96 | 333000ED22D3DE5D00554162 /* Warnings.xcconfig */, 97 | ); 98 | path = Configs; 99 | sourceTree = ""; 100 | }; 101 | 33CC10E42044A3C60003C045 = { 102 | isa = PBXGroup; 103 | children = ( 104 | 33FAB671232836740065AC1E /* Runner */, 105 | 33CEB47122A05771004F2AC0 /* Flutter */, 106 | 33CC10EE2044A3C60003C045 /* Products */, 107 | D73912EC22F37F3D000D13A0 /* Frameworks */, 108 | E32CAE734E5DA22433063D71 /* Pods */, 109 | ); 110 | sourceTree = ""; 111 | }; 112 | 33CC10EE2044A3C60003C045 /* Products */ = { 113 | isa = PBXGroup; 114 | children = ( 115 | 33CC10ED2044A3C60003C045 /* keypress_simulator_example.app */, 116 | ); 117 | name = Products; 118 | sourceTree = ""; 119 | }; 120 | 33CC11242044D66E0003C045 /* Resources */ = { 121 | isa = PBXGroup; 122 | children = ( 123 | 33CC10F22044A3C60003C045 /* Assets.xcassets */, 124 | 33CC10F42044A3C60003C045 /* MainMenu.xib */, 125 | 33CC10F72044A3C60003C045 /* Info.plist */, 126 | ); 127 | name = Resources; 128 | path = ..; 129 | sourceTree = ""; 130 | }; 131 | 33CEB47122A05771004F2AC0 /* Flutter */ = { 132 | isa = PBXGroup; 133 | children = ( 134 | 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */, 135 | 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */, 136 | 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */, 137 | 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */, 138 | ); 139 | path = Flutter; 140 | sourceTree = ""; 141 | }; 142 | 33FAB671232836740065AC1E /* Runner */ = { 143 | isa = PBXGroup; 144 | children = ( 145 | 33CC10F02044A3C60003C045 /* AppDelegate.swift */, 146 | 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */, 147 | 33E51913231747F40026EE4D /* DebugProfile.entitlements */, 148 | 33E51914231749380026EE4D /* Release.entitlements */, 149 | 33CC11242044D66E0003C045 /* Resources */, 150 | 33BA886A226E78AF003329D5 /* Configs */, 151 | ); 152 | path = Runner; 153 | sourceTree = ""; 154 | }; 155 | D73912EC22F37F3D000D13A0 /* Frameworks */ = { 156 | isa = PBXGroup; 157 | children = ( 158 | 76939868F7A196829F74C69E /* Pods_Runner.framework */, 159 | ); 160 | name = Frameworks; 161 | sourceTree = ""; 162 | }; 163 | E32CAE734E5DA22433063D71 /* Pods */ = { 164 | isa = PBXGroup; 165 | children = ( 166 | 668CC059647136DFBEF2BCFC /* Pods-Runner.debug.xcconfig */, 167 | F6F89ECA31294B2873C9D00B /* Pods-Runner.release.xcconfig */, 168 | 0C242688C3B2D08C134EB8DB /* Pods-Runner.profile.xcconfig */, 169 | ); 170 | name = Pods; 171 | path = Pods; 172 | sourceTree = ""; 173 | }; 174 | /* End PBXGroup section */ 175 | 176 | /* Begin PBXNativeTarget section */ 177 | 33CC10EC2044A3C60003C045 /* Runner */ = { 178 | isa = PBXNativeTarget; 179 | buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */; 180 | buildPhases = ( 181 | F7B7789D64169D75F0CC1121 /* [CP] Check Pods Manifest.lock */, 182 | 33CC10E92044A3C60003C045 /* Sources */, 183 | 33CC10EA2044A3C60003C045 /* Frameworks */, 184 | 33CC10EB2044A3C60003C045 /* Resources */, 185 | 33CC110E2044A8840003C045 /* Bundle Framework */, 186 | 3399D490228B24CF009A79C7 /* ShellScript */, 187 | 75493ACDA5B36920A4C4229C /* [CP] Embed Pods Frameworks */, 188 | ); 189 | buildRules = ( 190 | ); 191 | dependencies = ( 192 | 33CC11202044C79F0003C045 /* PBXTargetDependency */, 193 | ); 194 | name = Runner; 195 | productName = Runner; 196 | productReference = 33CC10ED2044A3C60003C045 /* keypress_simulator_example.app */; 197 | productType = "com.apple.product-type.application"; 198 | }; 199 | /* End PBXNativeTarget section */ 200 | 201 | /* Begin PBXProject section */ 202 | 33CC10E52044A3C60003C045 /* Project object */ = { 203 | isa = PBXProject; 204 | attributes = { 205 | LastSwiftUpdateCheck = 0920; 206 | LastUpgradeCheck = 1430; 207 | ORGANIZATIONNAME = ""; 208 | TargetAttributes = { 209 | 33CC10EC2044A3C60003C045 = { 210 | CreatedOnToolsVersion = 9.2; 211 | LastSwiftMigration = 1100; 212 | ProvisioningStyle = Automatic; 213 | SystemCapabilities = { 214 | com.apple.Sandbox = { 215 | enabled = 1; 216 | }; 217 | }; 218 | }; 219 | 33CC111A2044C6BA0003C045 = { 220 | CreatedOnToolsVersion = 9.2; 221 | ProvisioningStyle = Manual; 222 | }; 223 | }; 224 | }; 225 | buildConfigurationList = 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */; 226 | compatibilityVersion = "Xcode 9.3"; 227 | developmentRegion = en; 228 | hasScannedForEncodings = 0; 229 | knownRegions = ( 230 | en, 231 | Base, 232 | ); 233 | mainGroup = 33CC10E42044A3C60003C045; 234 | productRefGroup = 33CC10EE2044A3C60003C045 /* Products */; 235 | projectDirPath = ""; 236 | projectRoot = ""; 237 | targets = ( 238 | 33CC10EC2044A3C60003C045 /* Runner */, 239 | 33CC111A2044C6BA0003C045 /* Flutter Assemble */, 240 | ); 241 | }; 242 | /* End PBXProject section */ 243 | 244 | /* Begin PBXResourcesBuildPhase section */ 245 | 33CC10EB2044A3C60003C045 /* Resources */ = { 246 | isa = PBXResourcesBuildPhase; 247 | buildActionMask = 2147483647; 248 | files = ( 249 | 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */, 250 | 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */, 251 | ); 252 | runOnlyForDeploymentPostprocessing = 0; 253 | }; 254 | /* End PBXResourcesBuildPhase section */ 255 | 256 | /* Begin PBXShellScriptBuildPhase section */ 257 | 3399D490228B24CF009A79C7 /* ShellScript */ = { 258 | isa = PBXShellScriptBuildPhase; 259 | alwaysOutOfDate = 1; 260 | buildActionMask = 2147483647; 261 | files = ( 262 | ); 263 | inputFileListPaths = ( 264 | ); 265 | inputPaths = ( 266 | ); 267 | outputFileListPaths = ( 268 | ); 269 | outputPaths = ( 270 | ); 271 | runOnlyForDeploymentPostprocessing = 0; 272 | shellPath = /bin/sh; 273 | shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n"; 274 | }; 275 | 33CC111E2044C6BF0003C045 /* ShellScript */ = { 276 | isa = PBXShellScriptBuildPhase; 277 | buildActionMask = 2147483647; 278 | files = ( 279 | ); 280 | inputFileListPaths = ( 281 | Flutter/ephemeral/FlutterInputs.xcfilelist, 282 | ); 283 | inputPaths = ( 284 | Flutter/ephemeral/tripwire, 285 | ); 286 | outputFileListPaths = ( 287 | Flutter/ephemeral/FlutterOutputs.xcfilelist, 288 | ); 289 | outputPaths = ( 290 | ); 291 | runOnlyForDeploymentPostprocessing = 0; 292 | shellPath = /bin/sh; 293 | shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire"; 294 | }; 295 | 75493ACDA5B36920A4C4229C /* [CP] Embed Pods Frameworks */ = { 296 | isa = PBXShellScriptBuildPhase; 297 | buildActionMask = 2147483647; 298 | files = ( 299 | ); 300 | inputFileListPaths = ( 301 | "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", 302 | ); 303 | name = "[CP] Embed Pods Frameworks"; 304 | outputFileListPaths = ( 305 | "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", 306 | ); 307 | runOnlyForDeploymentPostprocessing = 0; 308 | shellPath = /bin/sh; 309 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; 310 | showEnvVarsInLog = 0; 311 | }; 312 | F7B7789D64169D75F0CC1121 /* [CP] Check Pods Manifest.lock */ = { 313 | isa = PBXShellScriptBuildPhase; 314 | buildActionMask = 2147483647; 315 | files = ( 316 | ); 317 | inputFileListPaths = ( 318 | ); 319 | inputPaths = ( 320 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 321 | "${PODS_ROOT}/Manifest.lock", 322 | ); 323 | name = "[CP] Check Pods Manifest.lock"; 324 | outputFileListPaths = ( 325 | ); 326 | outputPaths = ( 327 | "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", 328 | ); 329 | runOnlyForDeploymentPostprocessing = 0; 330 | shellPath = /bin/sh; 331 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 332 | showEnvVarsInLog = 0; 333 | }; 334 | /* End PBXShellScriptBuildPhase section */ 335 | 336 | /* Begin PBXSourcesBuildPhase section */ 337 | 33CC10E92044A3C60003C045 /* Sources */ = { 338 | isa = PBXSourcesBuildPhase; 339 | buildActionMask = 2147483647; 340 | files = ( 341 | 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */, 342 | 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */, 343 | 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */, 344 | ); 345 | runOnlyForDeploymentPostprocessing = 0; 346 | }; 347 | /* End PBXSourcesBuildPhase section */ 348 | 349 | /* Begin PBXTargetDependency section */ 350 | 33CC11202044C79F0003C045 /* PBXTargetDependency */ = { 351 | isa = PBXTargetDependency; 352 | target = 33CC111A2044C6BA0003C045 /* Flutter Assemble */; 353 | targetProxy = 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */; 354 | }; 355 | /* End PBXTargetDependency section */ 356 | 357 | /* Begin PBXVariantGroup section */ 358 | 33CC10F42044A3C60003C045 /* MainMenu.xib */ = { 359 | isa = PBXVariantGroup; 360 | children = ( 361 | 33CC10F52044A3C60003C045 /* Base */, 362 | ); 363 | name = MainMenu.xib; 364 | path = Runner; 365 | sourceTree = ""; 366 | }; 367 | /* End PBXVariantGroup section */ 368 | 369 | /* Begin XCBuildConfiguration section */ 370 | 338D0CE9231458BD00FA5F75 /* Profile */ = { 371 | isa = XCBuildConfiguration; 372 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 373 | buildSettings = { 374 | ALWAYS_SEARCH_USER_PATHS = NO; 375 | CLANG_ANALYZER_NONNULL = YES; 376 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 377 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 378 | CLANG_CXX_LIBRARY = "libc++"; 379 | CLANG_ENABLE_MODULES = YES; 380 | CLANG_ENABLE_OBJC_ARC = YES; 381 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 382 | CLANG_WARN_BOOL_CONVERSION = YES; 383 | CLANG_WARN_CONSTANT_CONVERSION = YES; 384 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 385 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 386 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 387 | CLANG_WARN_EMPTY_BODY = YES; 388 | CLANG_WARN_ENUM_CONVERSION = YES; 389 | CLANG_WARN_INFINITE_RECURSION = YES; 390 | CLANG_WARN_INT_CONVERSION = YES; 391 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 392 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 393 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 394 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 395 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 396 | CODE_SIGN_IDENTITY = "-"; 397 | COPY_PHASE_STRIP = NO; 398 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 399 | ENABLE_NS_ASSERTIONS = NO; 400 | ENABLE_STRICT_OBJC_MSGSEND = YES; 401 | GCC_C_LANGUAGE_STANDARD = gnu11; 402 | GCC_NO_COMMON_BLOCKS = YES; 403 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 404 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 405 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 406 | GCC_WARN_UNUSED_FUNCTION = YES; 407 | GCC_WARN_UNUSED_VARIABLE = YES; 408 | MACOSX_DEPLOYMENT_TARGET = 10.14; 409 | MTL_ENABLE_DEBUG_INFO = NO; 410 | SDKROOT = macosx; 411 | SWIFT_COMPILATION_MODE = wholemodule; 412 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 413 | }; 414 | name = Profile; 415 | }; 416 | 338D0CEA231458BD00FA5F75 /* Profile */ = { 417 | isa = XCBuildConfiguration; 418 | baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; 419 | buildSettings = { 420 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 421 | CLANG_ENABLE_MODULES = YES; 422 | CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; 423 | CODE_SIGN_STYLE = Automatic; 424 | COMBINE_HIDPI_IMAGES = YES; 425 | INFOPLIST_FILE = Runner/Info.plist; 426 | LD_RUNPATH_SEARCH_PATHS = ( 427 | "$(inherited)", 428 | "@executable_path/../Frameworks", 429 | ); 430 | PROVISIONING_PROFILE_SPECIFIER = ""; 431 | SWIFT_VERSION = 5.0; 432 | }; 433 | name = Profile; 434 | }; 435 | 338D0CEB231458BD00FA5F75 /* Profile */ = { 436 | isa = XCBuildConfiguration; 437 | buildSettings = { 438 | CODE_SIGN_STYLE = Manual; 439 | PRODUCT_NAME = "$(TARGET_NAME)"; 440 | }; 441 | name = Profile; 442 | }; 443 | 33CC10F92044A3C60003C045 /* Debug */ = { 444 | isa = XCBuildConfiguration; 445 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; 446 | buildSettings = { 447 | ALWAYS_SEARCH_USER_PATHS = NO; 448 | CLANG_ANALYZER_NONNULL = YES; 449 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 450 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 451 | CLANG_CXX_LIBRARY = "libc++"; 452 | CLANG_ENABLE_MODULES = YES; 453 | CLANG_ENABLE_OBJC_ARC = YES; 454 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 455 | CLANG_WARN_BOOL_CONVERSION = YES; 456 | CLANG_WARN_CONSTANT_CONVERSION = YES; 457 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 458 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 459 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 460 | CLANG_WARN_EMPTY_BODY = YES; 461 | CLANG_WARN_ENUM_CONVERSION = YES; 462 | CLANG_WARN_INFINITE_RECURSION = YES; 463 | CLANG_WARN_INT_CONVERSION = YES; 464 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 465 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 466 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 467 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 468 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 469 | CODE_SIGN_IDENTITY = "-"; 470 | COPY_PHASE_STRIP = NO; 471 | DEBUG_INFORMATION_FORMAT = dwarf; 472 | ENABLE_STRICT_OBJC_MSGSEND = YES; 473 | ENABLE_TESTABILITY = YES; 474 | GCC_C_LANGUAGE_STANDARD = gnu11; 475 | GCC_DYNAMIC_NO_PIC = NO; 476 | GCC_NO_COMMON_BLOCKS = YES; 477 | GCC_OPTIMIZATION_LEVEL = 0; 478 | GCC_PREPROCESSOR_DEFINITIONS = ( 479 | "DEBUG=1", 480 | "$(inherited)", 481 | ); 482 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 483 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 484 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 485 | GCC_WARN_UNUSED_FUNCTION = YES; 486 | GCC_WARN_UNUSED_VARIABLE = YES; 487 | MACOSX_DEPLOYMENT_TARGET = 10.14; 488 | MTL_ENABLE_DEBUG_INFO = YES; 489 | ONLY_ACTIVE_ARCH = YES; 490 | SDKROOT = macosx; 491 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 492 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 493 | }; 494 | name = Debug; 495 | }; 496 | 33CC10FA2044A3C60003C045 /* Release */ = { 497 | isa = XCBuildConfiguration; 498 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 499 | buildSettings = { 500 | ALWAYS_SEARCH_USER_PATHS = NO; 501 | CLANG_ANALYZER_NONNULL = YES; 502 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 503 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 504 | CLANG_CXX_LIBRARY = "libc++"; 505 | CLANG_ENABLE_MODULES = YES; 506 | CLANG_ENABLE_OBJC_ARC = YES; 507 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 508 | CLANG_WARN_BOOL_CONVERSION = YES; 509 | CLANG_WARN_CONSTANT_CONVERSION = YES; 510 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 511 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 512 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 513 | CLANG_WARN_EMPTY_BODY = YES; 514 | CLANG_WARN_ENUM_CONVERSION = YES; 515 | CLANG_WARN_INFINITE_RECURSION = YES; 516 | CLANG_WARN_INT_CONVERSION = YES; 517 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 518 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 519 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 520 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 521 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 522 | CODE_SIGN_IDENTITY = "-"; 523 | COPY_PHASE_STRIP = NO; 524 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 525 | ENABLE_NS_ASSERTIONS = NO; 526 | ENABLE_STRICT_OBJC_MSGSEND = YES; 527 | GCC_C_LANGUAGE_STANDARD = gnu11; 528 | GCC_NO_COMMON_BLOCKS = YES; 529 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 530 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 531 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 532 | GCC_WARN_UNUSED_FUNCTION = YES; 533 | GCC_WARN_UNUSED_VARIABLE = YES; 534 | MACOSX_DEPLOYMENT_TARGET = 10.14; 535 | MTL_ENABLE_DEBUG_INFO = NO; 536 | SDKROOT = macosx; 537 | SWIFT_COMPILATION_MODE = wholemodule; 538 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 539 | }; 540 | name = Release; 541 | }; 542 | 33CC10FC2044A3C60003C045 /* Debug */ = { 543 | isa = XCBuildConfiguration; 544 | baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; 545 | buildSettings = { 546 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 547 | CLANG_ENABLE_MODULES = YES; 548 | CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; 549 | CODE_SIGN_STYLE = Automatic; 550 | COMBINE_HIDPI_IMAGES = YES; 551 | INFOPLIST_FILE = Runner/Info.plist; 552 | LD_RUNPATH_SEARCH_PATHS = ( 553 | "$(inherited)", 554 | "@executable_path/../Frameworks", 555 | ); 556 | PROVISIONING_PROFILE_SPECIFIER = ""; 557 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 558 | SWIFT_VERSION = 5.0; 559 | }; 560 | name = Debug; 561 | }; 562 | 33CC10FD2044A3C60003C045 /* Release */ = { 563 | isa = XCBuildConfiguration; 564 | baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; 565 | buildSettings = { 566 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 567 | CLANG_ENABLE_MODULES = YES; 568 | CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements; 569 | CODE_SIGN_STYLE = Automatic; 570 | COMBINE_HIDPI_IMAGES = YES; 571 | INFOPLIST_FILE = Runner/Info.plist; 572 | LD_RUNPATH_SEARCH_PATHS = ( 573 | "$(inherited)", 574 | "@executable_path/../Frameworks", 575 | ); 576 | PROVISIONING_PROFILE_SPECIFIER = ""; 577 | SWIFT_VERSION = 5.0; 578 | }; 579 | name = Release; 580 | }; 581 | 33CC111C2044C6BA0003C045 /* Debug */ = { 582 | isa = XCBuildConfiguration; 583 | buildSettings = { 584 | CODE_SIGN_STYLE = Manual; 585 | PRODUCT_NAME = "$(TARGET_NAME)"; 586 | }; 587 | name = Debug; 588 | }; 589 | 33CC111D2044C6BA0003C045 /* Release */ = { 590 | isa = XCBuildConfiguration; 591 | buildSettings = { 592 | CODE_SIGN_STYLE = Automatic; 593 | PRODUCT_NAME = "$(TARGET_NAME)"; 594 | }; 595 | name = Release; 596 | }; 597 | /* End XCBuildConfiguration section */ 598 | 599 | /* Begin XCConfigurationList section */ 600 | 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */ = { 601 | isa = XCConfigurationList; 602 | buildConfigurations = ( 603 | 33CC10F92044A3C60003C045 /* Debug */, 604 | 33CC10FA2044A3C60003C045 /* Release */, 605 | 338D0CE9231458BD00FA5F75 /* Profile */, 606 | ); 607 | defaultConfigurationIsVisible = 0; 608 | defaultConfigurationName = Release; 609 | }; 610 | 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */ = { 611 | isa = XCConfigurationList; 612 | buildConfigurations = ( 613 | 33CC10FC2044A3C60003C045 /* Debug */, 614 | 33CC10FD2044A3C60003C045 /* Release */, 615 | 338D0CEA231458BD00FA5F75 /* Profile */, 616 | ); 617 | defaultConfigurationIsVisible = 0; 618 | defaultConfigurationName = Release; 619 | }; 620 | 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */ = { 621 | isa = XCConfigurationList; 622 | buildConfigurations = ( 623 | 33CC111C2044C6BA0003C045 /* Debug */, 624 | 33CC111D2044C6BA0003C045 /* Release */, 625 | 338D0CEB231458BD00FA5F75 /* Profile */, 626 | ); 627 | defaultConfigurationIsVisible = 0; 628 | defaultConfigurationName = Release; 629 | }; 630 | /* End XCConfigurationList section */ 631 | }; 632 | rootObject = 33CC10E52044A3C60003C045 /* Project object */; 633 | } 634 | -------------------------------------------------------------------------------- /packages/keypress_simulator/example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /packages/keypress_simulator/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 69 | 71 | 77 | 78 | 79 | 80 | 82 | 83 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /packages/keypress_simulator/example/macos/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /packages/keypress_simulator/example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /packages/keypress_simulator/example/macos/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | @NSApplicationMain 5 | class AppDelegate: FlutterAppDelegate { 6 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { 7 | return true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/keypress_simulator/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "16x16", 5 | "idiom" : "mac", 6 | "filename" : "app_icon_16.png", 7 | "scale" : "1x" 8 | }, 9 | { 10 | "size" : "16x16", 11 | "idiom" : "mac", 12 | "filename" : "app_icon_32.png", 13 | "scale" : "2x" 14 | }, 15 | { 16 | "size" : "32x32", 17 | "idiom" : "mac", 18 | "filename" : "app_icon_32.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "32x32", 23 | "idiom" : "mac", 24 | "filename" : "app_icon_64.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "128x128", 29 | "idiom" : "mac", 30 | "filename" : "app_icon_128.png", 31 | "scale" : "1x" 32 | }, 33 | { 34 | "size" : "128x128", 35 | "idiom" : "mac", 36 | "filename" : "app_icon_256.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "256x256", 41 | "idiom" : "mac", 42 | "filename" : "app_icon_256.png", 43 | "scale" : "1x" 44 | }, 45 | { 46 | "size" : "256x256", 47 | "idiom" : "mac", 48 | "filename" : "app_icon_512.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "512x512", 53 | "idiom" : "mac", 54 | "filename" : "app_icon_512.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "512x512", 59 | "idiom" : "mac", 60 | "filename" : "app_icon_1024.png", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /packages/keypress_simulator/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leanflutter/keypress_simulator/86ba751d53cc620863cdb048bed0ecacb7e6c1a1/packages/keypress_simulator/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png -------------------------------------------------------------------------------- /packages/keypress_simulator/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leanflutter/keypress_simulator/86ba751d53cc620863cdb048bed0ecacb7e6c1a1/packages/keypress_simulator/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png -------------------------------------------------------------------------------- /packages/keypress_simulator/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leanflutter/keypress_simulator/86ba751d53cc620863cdb048bed0ecacb7e6c1a1/packages/keypress_simulator/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png -------------------------------------------------------------------------------- /packages/keypress_simulator/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leanflutter/keypress_simulator/86ba751d53cc620863cdb048bed0ecacb7e6c1a1/packages/keypress_simulator/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png -------------------------------------------------------------------------------- /packages/keypress_simulator/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leanflutter/keypress_simulator/86ba751d53cc620863cdb048bed0ecacb7e6c1a1/packages/keypress_simulator/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png -------------------------------------------------------------------------------- /packages/keypress_simulator/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leanflutter/keypress_simulator/86ba751d53cc620863cdb048bed0ecacb7e6c1a1/packages/keypress_simulator/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png -------------------------------------------------------------------------------- /packages/keypress_simulator/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leanflutter/keypress_simulator/86ba751d53cc620863cdb048bed0ecacb7e6c1a1/packages/keypress_simulator/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png -------------------------------------------------------------------------------- /packages/keypress_simulator/example/macos/Runner/Base.lproj/MainMenu.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | -------------------------------------------------------------------------------- /packages/keypress_simulator/example/macos/Runner/Configs/AppInfo.xcconfig: -------------------------------------------------------------------------------- 1 | // Application-level settings for the Runner target. 2 | // 3 | // This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the 4 | // future. If not, the values below would default to using the project name when this becomes a 5 | // 'flutter create' template. 6 | 7 | // The application's name. By default this is also the title of the Flutter window. 8 | PRODUCT_NAME = keypress_simulator_example 9 | 10 | // The application's bundle identifier 11 | PRODUCT_BUNDLE_IDENTIFIER = org.leanflutter.plugins.keypressSimulatorExample 12 | 13 | // The copyright displayed in application information 14 | PRODUCT_COPYRIGHT = Copyright © 2022 org.leanflutter.plugins. All rights reserved. 15 | -------------------------------------------------------------------------------- /packages/keypress_simulator/example/macos/Runner/Configs/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Debug.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /packages/keypress_simulator/example/macos/Runner/Configs/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Release.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /packages/keypress_simulator/example/macos/Runner/Configs/Warnings.xcconfig: -------------------------------------------------------------------------------- 1 | WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings 2 | GCC_WARN_UNDECLARED_SELECTOR = YES 3 | CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES 4 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE 5 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES 6 | CLANG_WARN_PRAGMA_PACK = YES 7 | CLANG_WARN_STRICT_PROTOTYPES = YES 8 | CLANG_WARN_COMMA = YES 9 | GCC_WARN_STRICT_SELECTOR_MATCH = YES 10 | CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES 11 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES 12 | GCC_WARN_SHADOW = YES 13 | CLANG_WARN_UNREACHABLE_CODE = YES 14 | -------------------------------------------------------------------------------- /packages/keypress_simulator/example/macos/Runner/DebugProfile.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.cs.allow-jit 8 | 9 | com.apple.security.network.server 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /packages/keypress_simulator/example/macos/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSMinimumSystemVersion 24 | $(MACOSX_DEPLOYMENT_TARGET) 25 | NSHumanReadableCopyright 26 | $(PRODUCT_COPYRIGHT) 27 | NSMainNibFile 28 | MainMenu 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /packages/keypress_simulator/example/macos/Runner/MainFlutterWindow.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | class MainFlutterWindow: NSWindow { 5 | override func awakeFromNib() { 6 | let flutterViewController = FlutterViewController.init() 7 | let windowFrame = self.frame 8 | self.contentViewController = flutterViewController 9 | self.setFrame(windowFrame, display: true) 10 | 11 | RegisterGeneratedPlugins(registry: flutterViewController) 12 | 13 | super.awakeFromNib() 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /packages/keypress_simulator/example/macos/Runner/Release.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /packages/keypress_simulator/example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: keypress_simulator_example 2 | description: Demonstrates how to use the keypress_simulator plugin. 3 | publish_to: 'none' 4 | 5 | environment: 6 | sdk: ">=3.0.0 <4.0.0" 7 | 8 | dependencies: 9 | bot_toast: ^4.0.1 10 | cupertino_icons: ^1.0.2 11 | flutter: 12 | sdk: flutter 13 | hotkey_manager: ^0.1.0 14 | keypress_simulator: 15 | path: ../ 16 | preference_list: ^0.0.1 17 | 18 | dev_dependencies: 19 | flutter_test: 20 | sdk: flutter 21 | mostly_reasonable_lints: ^0.1.1 22 | 23 | flutter: 24 | uses-material-design: true 25 | -------------------------------------------------------------------------------- /packages/keypress_simulator/example/web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leanflutter/keypress_simulator/86ba751d53cc620863cdb048bed0ecacb7e6c1a1/packages/keypress_simulator/example/web/favicon.png -------------------------------------------------------------------------------- /packages/keypress_simulator/example/web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leanflutter/keypress_simulator/86ba751d53cc620863cdb048bed0ecacb7e6c1a1/packages/keypress_simulator/example/web/icons/Icon-192.png -------------------------------------------------------------------------------- /packages/keypress_simulator/example/web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leanflutter/keypress_simulator/86ba751d53cc620863cdb048bed0ecacb7e6c1a1/packages/keypress_simulator/example/web/icons/Icon-512.png -------------------------------------------------------------------------------- /packages/keypress_simulator/example/web/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leanflutter/keypress_simulator/86ba751d53cc620863cdb048bed0ecacb7e6c1a1/packages/keypress_simulator/example/web/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /packages/keypress_simulator/example/web/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leanflutter/keypress_simulator/86ba751d53cc620863cdb048bed0ecacb7e6c1a1/packages/keypress_simulator/example/web/icons/Icon-maskable-512.png -------------------------------------------------------------------------------- /packages/keypress_simulator/example/web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | keypress_simulator_example 33 | 34 | 35 | 39 | 40 | 41 | 42 | 43 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /packages/keypress_simulator/example/web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "keypress_simulator_example", 3 | "short_name": "keypress_simulator_example", 4 | "start_url": ".", 5 | "display": "standalone", 6 | "background_color": "#0175C2", 7 | "theme_color": "#0175C2", 8 | "description": "A new Flutter project.", 9 | "orientation": "portrait-primary", 10 | "prefer_related_applications": false, 11 | "icons": [ 12 | { 13 | "src": "icons/Icon-192.png", 14 | "sizes": "192x192", 15 | "type": "image/png" 16 | }, 17 | { 18 | "src": "icons/Icon-512.png", 19 | "sizes": "512x512", 20 | "type": "image/png" 21 | }, 22 | { 23 | "src": "icons/Icon-maskable-192.png", 24 | "sizes": "192x192", 25 | "type": "image/png", 26 | "purpose": "maskable" 27 | }, 28 | { 29 | "src": "icons/Icon-maskable-512.png", 30 | "sizes": "512x512", 31 | "type": "image/png", 32 | "purpose": "maskable" 33 | } 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /packages/keypress_simulator/example/windows/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral/ 2 | 3 | # Visual Studio user-specific files. 4 | *.suo 5 | *.user 6 | *.userosscache 7 | *.sln.docstates 8 | 9 | # Visual Studio build-related files. 10 | x64/ 11 | x86/ 12 | 13 | # Visual Studio cache files 14 | # files ending in .cache can be ignored 15 | *.[Cc]ache 16 | # but keep track of directories ending in .cache 17 | !*.[Cc]ache/ 18 | -------------------------------------------------------------------------------- /packages/keypress_simulator/example/windows/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | project(keypress_simulator_example LANGUAGES CXX) 3 | 4 | set(BINARY_NAME "keypress_simulator_example") 5 | 6 | cmake_policy(SET CMP0063 NEW) 7 | 8 | set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") 9 | 10 | # Configure build options. 11 | get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) 12 | if(IS_MULTICONFIG) 13 | set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" 14 | CACHE STRING "" FORCE) 15 | else() 16 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 17 | set(CMAKE_BUILD_TYPE "Debug" CACHE 18 | STRING "Flutter build mode" FORCE) 19 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 20 | "Debug" "Profile" "Release") 21 | endif() 22 | endif() 23 | 24 | set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") 25 | set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") 26 | set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") 27 | set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") 28 | 29 | # Use Unicode for all projects. 30 | add_definitions(-DUNICODE -D_UNICODE) 31 | 32 | # Compilation settings that should be applied to most targets. 33 | function(APPLY_STANDARD_SETTINGS TARGET) 34 | target_compile_features(${TARGET} PUBLIC cxx_std_17) 35 | target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") 36 | target_compile_options(${TARGET} PRIVATE /EHsc) 37 | target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") 38 | target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") 39 | endfunction() 40 | 41 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 42 | 43 | # Flutter library and tool build rules. 44 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 45 | 46 | # Application build 47 | add_subdirectory("runner") 48 | 49 | # Generated plugin build rules, which manage building the plugins and adding 50 | # them to the application. 51 | include(flutter/generated_plugins.cmake) 52 | 53 | 54 | # === Installation === 55 | # Support files are copied into place next to the executable, so that it can 56 | # run in place. This is done instead of making a separate bundle (as on Linux) 57 | # so that building and running from within Visual Studio will work. 58 | set(BUILD_BUNDLE_DIR "$") 59 | # Make the "install" step default, as it's required to run. 60 | set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) 61 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 62 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 63 | endif() 64 | 65 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 66 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") 67 | 68 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 69 | COMPONENT Runtime) 70 | 71 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 72 | COMPONENT Runtime) 73 | 74 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 75 | COMPONENT Runtime) 76 | 77 | if(PLUGIN_BUNDLED_LIBRARIES) 78 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" 79 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 80 | COMPONENT Runtime) 81 | endif() 82 | 83 | # Fully re-copy the assets directory on each build to avoid having stale files 84 | # from a previous install. 85 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 86 | install(CODE " 87 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 88 | " COMPONENT Runtime) 89 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 90 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 91 | 92 | # Install the AOT library on non-Debug builds only. 93 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 94 | CONFIGURATIONS Profile;Release 95 | COMPONENT Runtime) 96 | -------------------------------------------------------------------------------- /packages/keypress_simulator/example/windows/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | 3 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 4 | 5 | # Configuration provided via flutter tool. 6 | include(${EPHEMERAL_DIR}/generated_config.cmake) 7 | 8 | # TODO: Move the rest of this into files in ephemeral. See 9 | # https://github.com/flutter/flutter/issues/57146. 10 | set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") 11 | 12 | # Set fallback configurations for older versions of the flutter tool. 13 | if (NOT DEFINED FLUTTER_TARGET_PLATFORM) 14 | set(FLUTTER_TARGET_PLATFORM "windows-x64") 15 | endif() 16 | 17 | # === Flutter Library === 18 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") 19 | 20 | # Published to parent scope for install step. 21 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 22 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 23 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 24 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) 25 | 26 | list(APPEND FLUTTER_LIBRARY_HEADERS 27 | "flutter_export.h" 28 | "flutter_windows.h" 29 | "flutter_messenger.h" 30 | "flutter_plugin_registrar.h" 31 | "flutter_texture_registrar.h" 32 | ) 33 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") 34 | add_library(flutter INTERFACE) 35 | target_include_directories(flutter INTERFACE 36 | "${EPHEMERAL_DIR}" 37 | ) 38 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") 39 | add_dependencies(flutter flutter_assemble) 40 | 41 | # === Wrapper === 42 | list(APPEND CPP_WRAPPER_SOURCES_CORE 43 | "core_implementations.cc" 44 | "standard_codec.cc" 45 | ) 46 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") 47 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN 48 | "plugin_registrar.cc" 49 | ) 50 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") 51 | list(APPEND CPP_WRAPPER_SOURCES_APP 52 | "flutter_engine.cc" 53 | "flutter_view_controller.cc" 54 | ) 55 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") 56 | 57 | # Wrapper sources needed for a plugin. 58 | add_library(flutter_wrapper_plugin STATIC 59 | ${CPP_WRAPPER_SOURCES_CORE} 60 | ${CPP_WRAPPER_SOURCES_PLUGIN} 61 | ) 62 | apply_standard_settings(flutter_wrapper_plugin) 63 | set_target_properties(flutter_wrapper_plugin PROPERTIES 64 | POSITION_INDEPENDENT_CODE ON) 65 | set_target_properties(flutter_wrapper_plugin PROPERTIES 66 | CXX_VISIBILITY_PRESET hidden) 67 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) 68 | target_include_directories(flutter_wrapper_plugin PUBLIC 69 | "${WRAPPER_ROOT}/include" 70 | ) 71 | add_dependencies(flutter_wrapper_plugin flutter_assemble) 72 | 73 | # Wrapper sources needed for the runner. 74 | add_library(flutter_wrapper_app STATIC 75 | ${CPP_WRAPPER_SOURCES_CORE} 76 | ${CPP_WRAPPER_SOURCES_APP} 77 | ) 78 | apply_standard_settings(flutter_wrapper_app) 79 | target_link_libraries(flutter_wrapper_app PUBLIC flutter) 80 | target_include_directories(flutter_wrapper_app PUBLIC 81 | "${WRAPPER_ROOT}/include" 82 | ) 83 | add_dependencies(flutter_wrapper_app flutter_assemble) 84 | 85 | # === Flutter tool backend === 86 | # _phony_ is a non-existent file to force this command to run every time, 87 | # since currently there's no way to get a full input/output list from the 88 | # flutter tool. 89 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") 90 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) 91 | add_custom_command( 92 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 93 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} 94 | ${CPP_WRAPPER_SOURCES_APP} 95 | ${PHONY_OUTPUT} 96 | COMMAND ${CMAKE_COMMAND} -E env 97 | ${FLUTTER_TOOL_ENVIRONMENT} 98 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" 99 | ${FLUTTER_TARGET_PLATFORM} $ 100 | VERBATIM 101 | ) 102 | add_custom_target(flutter_assemble DEPENDS 103 | "${FLUTTER_LIBRARY}" 104 | ${FLUTTER_LIBRARY_HEADERS} 105 | ${CPP_WRAPPER_SOURCES_CORE} 106 | ${CPP_WRAPPER_SOURCES_PLUGIN} 107 | ${CPP_WRAPPER_SOURCES_APP} 108 | ) 109 | -------------------------------------------------------------------------------- /packages/keypress_simulator/example/windows/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | #include 10 | #include 11 | 12 | void RegisterPlugins(flutter::PluginRegistry* registry) { 13 | HotkeyManagerPluginRegisterWithRegistrar( 14 | registry->GetRegistrarForPlugin("HotkeyManagerPlugin")); 15 | KeypressSimulatorWindowsPluginCApiRegisterWithRegistrar( 16 | registry->GetRegistrarForPlugin("KeypressSimulatorWindowsPluginCApi")); 17 | } 18 | -------------------------------------------------------------------------------- /packages/keypress_simulator/example/windows/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void RegisterPlugins(flutter::PluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /packages/keypress_simulator/example/windows/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | hotkey_manager 7 | keypress_simulator_windows 8 | ) 9 | 10 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 11 | ) 12 | 13 | set(PLUGIN_BUNDLED_LIBRARIES) 14 | 15 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 16 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) 17 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 19 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 20 | endforeach(plugin) 21 | 22 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 23 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) 24 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 25 | endforeach(ffi_plugin) 26 | -------------------------------------------------------------------------------- /packages/keypress_simulator/example/windows/runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | project(runner LANGUAGES CXX) 3 | 4 | add_executable(${BINARY_NAME} WIN32 5 | "flutter_window.cpp" 6 | "main.cpp" 7 | "utils.cpp" 8 | "win32_window.cpp" 9 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 10 | "Runner.rc" 11 | "runner.exe.manifest" 12 | ) 13 | apply_standard_settings(${BINARY_NAME}) 14 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") 15 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) 16 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 17 | add_dependencies(${BINARY_NAME} flutter_assemble) 18 | -------------------------------------------------------------------------------- /packages/keypress_simulator/example/windows/runner/Runner.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #pragma code_page(65001) 4 | #include "resource.h" 5 | 6 | #define APSTUDIO_READONLY_SYMBOLS 7 | ///////////////////////////////////////////////////////////////////////////// 8 | // 9 | // Generated from the TEXTINCLUDE 2 resource. 10 | // 11 | #include "winres.h" 12 | 13 | ///////////////////////////////////////////////////////////////////////////// 14 | #undef APSTUDIO_READONLY_SYMBOLS 15 | 16 | ///////////////////////////////////////////////////////////////////////////// 17 | // English (United States) resources 18 | 19 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 21 | 22 | #ifdef APSTUDIO_INVOKED 23 | ///////////////////////////////////////////////////////////////////////////// 24 | // 25 | // TEXTINCLUDE 26 | // 27 | 28 | 1 TEXTINCLUDE 29 | BEGIN 30 | "resource.h\0" 31 | END 32 | 33 | 2 TEXTINCLUDE 34 | BEGIN 35 | "#include ""winres.h""\r\n" 36 | "\0" 37 | END 38 | 39 | 3 TEXTINCLUDE 40 | BEGIN 41 | "\r\n" 42 | "\0" 43 | END 44 | 45 | #endif // APSTUDIO_INVOKED 46 | 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | // 50 | // Icon 51 | // 52 | 53 | // Icon with lowest ID value placed first to ensure application icon 54 | // remains consistent on all systems. 55 | IDI_APP_ICON ICON "resources\\app_icon.ico" 56 | 57 | 58 | ///////////////////////////////////////////////////////////////////////////// 59 | // 60 | // Version 61 | // 62 | 63 | #if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) 64 | #define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD 65 | #else 66 | #define VERSION_AS_NUMBER 1,0,0,0 67 | #endif 68 | 69 | #if defined(FLUTTER_VERSION) 70 | #define VERSION_AS_STRING FLUTTER_VERSION 71 | #else 72 | #define VERSION_AS_STRING "1.0.0" 73 | #endif 74 | 75 | VS_VERSION_INFO VERSIONINFO 76 | FILEVERSION VERSION_AS_NUMBER 77 | PRODUCTVERSION VERSION_AS_NUMBER 78 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 79 | #ifdef _DEBUG 80 | FILEFLAGS VS_FF_DEBUG 81 | #else 82 | FILEFLAGS 0x0L 83 | #endif 84 | FILEOS VOS__WINDOWS32 85 | FILETYPE VFT_APP 86 | FILESUBTYPE 0x0L 87 | BEGIN 88 | BLOCK "StringFileInfo" 89 | BEGIN 90 | BLOCK "040904e4" 91 | BEGIN 92 | VALUE "CompanyName", "org.leanflutter.plugins" "\0" 93 | VALUE "FileDescription", "keypress_simulator_example" "\0" 94 | VALUE "FileVersion", VERSION_AS_STRING "\0" 95 | VALUE "InternalName", "keypress_simulator_example" "\0" 96 | VALUE "LegalCopyright", "Copyright (C) 2022 org.leanflutter.plugins. All rights reserved." "\0" 97 | VALUE "OriginalFilename", "keypress_simulator_example.exe" "\0" 98 | VALUE "ProductName", "keypress_simulator_example" "\0" 99 | VALUE "ProductVersion", VERSION_AS_STRING "\0" 100 | END 101 | END 102 | BLOCK "VarFileInfo" 103 | BEGIN 104 | VALUE "Translation", 0x409, 1252 105 | END 106 | END 107 | 108 | #endif // English (United States) resources 109 | ///////////////////////////////////////////////////////////////////////////// 110 | 111 | 112 | 113 | #ifndef APSTUDIO_INVOKED 114 | ///////////////////////////////////////////////////////////////////////////// 115 | // 116 | // Generated from the TEXTINCLUDE 3 resource. 117 | // 118 | 119 | 120 | ///////////////////////////////////////////////////////////////////////////// 121 | #endif // not APSTUDIO_INVOKED 122 | -------------------------------------------------------------------------------- /packages/keypress_simulator/example/windows/runner/flutter_window.cpp: -------------------------------------------------------------------------------- 1 | #include "flutter_window.h" 2 | 3 | #include 4 | 5 | #include "flutter/generated_plugin_registrant.h" 6 | 7 | FlutterWindow::FlutterWindow(const flutter::DartProject& project) 8 | : project_(project) {} 9 | 10 | FlutterWindow::~FlutterWindow() {} 11 | 12 | bool FlutterWindow::OnCreate() { 13 | if (!Win32Window::OnCreate()) { 14 | return false; 15 | } 16 | 17 | RECT frame = GetClientArea(); 18 | 19 | // The size here must match the window dimensions to avoid unnecessary surface 20 | // creation / destruction in the startup path. 21 | flutter_controller_ = std::make_unique( 22 | frame.right - frame.left, frame.bottom - frame.top, project_); 23 | // Ensure that basic setup of the controller was successful. 24 | if (!flutter_controller_->engine() || !flutter_controller_->view()) { 25 | return false; 26 | } 27 | RegisterPlugins(flutter_controller_->engine()); 28 | SetChildContent(flutter_controller_->view()->GetNativeWindow()); 29 | return true; 30 | } 31 | 32 | void FlutterWindow::OnDestroy() { 33 | if (flutter_controller_) { 34 | flutter_controller_ = nullptr; 35 | } 36 | 37 | Win32Window::OnDestroy(); 38 | } 39 | 40 | LRESULT 41 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message, 42 | WPARAM const wparam, 43 | LPARAM const lparam) noexcept { 44 | // Give Flutter, including plugins, an opportunity to handle window messages. 45 | if (flutter_controller_) { 46 | std::optional result = 47 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, 48 | lparam); 49 | if (result) { 50 | return *result; 51 | } 52 | } 53 | 54 | switch (message) { 55 | case WM_FONTCHANGE: 56 | flutter_controller_->engine()->ReloadSystemFonts(); 57 | break; 58 | } 59 | 60 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam); 61 | } 62 | -------------------------------------------------------------------------------- /packages/keypress_simulator/example/windows/runner/flutter_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_FLUTTER_WINDOW_H_ 2 | #define RUNNER_FLUTTER_WINDOW_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include "win32_window.h" 10 | 11 | // A window that does nothing but host a Flutter view. 12 | class FlutterWindow : public Win32Window { 13 | public: 14 | // Creates a new FlutterWindow hosting a Flutter view running |project|. 15 | explicit FlutterWindow(const flutter::DartProject& project); 16 | virtual ~FlutterWindow(); 17 | 18 | protected: 19 | // Win32Window: 20 | bool OnCreate() override; 21 | void OnDestroy() override; 22 | LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, 23 | LPARAM const lparam) noexcept override; 24 | 25 | private: 26 | // The project to run. 27 | flutter::DartProject project_; 28 | 29 | // The Flutter instance hosted by this window. 30 | std::unique_ptr flutter_controller_; 31 | }; 32 | 33 | #endif // RUNNER_FLUTTER_WINDOW_H_ 34 | -------------------------------------------------------------------------------- /packages/keypress_simulator/example/windows/runner/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "flutter_window.h" 6 | #include "utils.h" 7 | 8 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, 9 | _In_ wchar_t *command_line, _In_ int show_command) { 10 | // Attach to console when present (e.g., 'flutter run') or create a 11 | // new console when running with a debugger. 12 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { 13 | CreateAndAttachConsole(); 14 | } 15 | 16 | // Initialize COM, so that it is available for use in the library and/or 17 | // plugins. 18 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); 19 | 20 | flutter::DartProject project(L"data"); 21 | 22 | std::vector command_line_arguments = 23 | GetCommandLineArguments(); 24 | 25 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); 26 | 27 | FlutterWindow window(project); 28 | Win32Window::Point origin(10, 10); 29 | Win32Window::Size size(1280, 720); 30 | if (!window.CreateAndShow(L"keypress_simulator_example", origin, size)) { 31 | return EXIT_FAILURE; 32 | } 33 | window.SetQuitOnClose(true); 34 | 35 | ::MSG msg; 36 | while (::GetMessage(&msg, nullptr, 0, 0)) { 37 | ::TranslateMessage(&msg); 38 | ::DispatchMessage(&msg); 39 | } 40 | 41 | ::CoUninitialize(); 42 | return EXIT_SUCCESS; 43 | } 44 | -------------------------------------------------------------------------------- /packages/keypress_simulator/example/windows/runner/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by Runner.rc 4 | // 5 | #define IDI_APP_ICON 101 6 | 7 | // Next default values for new objects 8 | // 9 | #ifdef APSTUDIO_INVOKED 10 | #ifndef APSTUDIO_READONLY_SYMBOLS 11 | #define _APS_NEXT_RESOURCE_VALUE 102 12 | #define _APS_NEXT_COMMAND_VALUE 40001 13 | #define _APS_NEXT_CONTROL_VALUE 1001 14 | #define _APS_NEXT_SYMED_VALUE 101 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /packages/keypress_simulator/example/windows/runner/resources/app_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leanflutter/keypress_simulator/86ba751d53cc620863cdb048bed0ecacb7e6c1a1/packages/keypress_simulator/example/windows/runner/resources/app_icon.ico -------------------------------------------------------------------------------- /packages/keypress_simulator/example/windows/runner/runner.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PerMonitorV2 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /packages/keypress_simulator/example/windows/runner/utils.cpp: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | void CreateAndAttachConsole() { 11 | if (::AllocConsole()) { 12 | FILE *unused; 13 | if (freopen_s(&unused, "CONOUT$", "w", stdout)) { 14 | _dup2(_fileno(stdout), 1); 15 | } 16 | if (freopen_s(&unused, "CONOUT$", "w", stderr)) { 17 | _dup2(_fileno(stdout), 2); 18 | } 19 | std::ios::sync_with_stdio(); 20 | FlutterDesktopResyncOutputStreams(); 21 | } 22 | } 23 | 24 | std::vector GetCommandLineArguments() { 25 | // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. 26 | int argc; 27 | wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); 28 | if (argv == nullptr) { 29 | return std::vector(); 30 | } 31 | 32 | std::vector command_line_arguments; 33 | 34 | // Skip the first argument as it's the binary name. 35 | for (int i = 1; i < argc; i++) { 36 | command_line_arguments.push_back(Utf8FromUtf16(argv[i])); 37 | } 38 | 39 | ::LocalFree(argv); 40 | 41 | return command_line_arguments; 42 | } 43 | 44 | std::string Utf8FromUtf16(const wchar_t* utf16_string) { 45 | if (utf16_string == nullptr) { 46 | return std::string(); 47 | } 48 | int target_length = ::WideCharToMultiByte( 49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 50 | -1, nullptr, 0, nullptr, nullptr); 51 | if (target_length == 0) { 52 | return std::string(); 53 | } 54 | std::string utf8_string; 55 | utf8_string.resize(target_length); 56 | int converted_length = ::WideCharToMultiByte( 57 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 58 | -1, utf8_string.data(), 59 | target_length, nullptr, nullptr); 60 | if (converted_length == 0) { 61 | return std::string(); 62 | } 63 | return utf8_string; 64 | } 65 | -------------------------------------------------------------------------------- /packages/keypress_simulator/example/windows/runner/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_UTILS_H_ 2 | #define RUNNER_UTILS_H_ 3 | 4 | #include 5 | #include 6 | 7 | // Creates a console for the process, and redirects stdout and stderr to 8 | // it for both the runner and the Flutter library. 9 | void CreateAndAttachConsole(); 10 | 11 | // Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string 12 | // encoded in UTF-8. Returns an empty std::string on failure. 13 | std::string Utf8FromUtf16(const wchar_t* utf16_string); 14 | 15 | // Gets the command line arguments passed in as a std::vector, 16 | // encoded in UTF-8. Returns an empty std::vector on failure. 17 | std::vector GetCommandLineArguments(); 18 | 19 | #endif // RUNNER_UTILS_H_ 20 | -------------------------------------------------------------------------------- /packages/keypress_simulator/example/windows/runner/win32_window.cpp: -------------------------------------------------------------------------------- 1 | #include "win32_window.h" 2 | 3 | #include 4 | 5 | #include "resource.h" 6 | 7 | namespace { 8 | 9 | constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; 10 | 11 | // The number of Win32Window objects that currently exist. 12 | static int g_active_window_count = 0; 13 | 14 | using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd); 15 | 16 | // Scale helper to convert logical scaler values to physical using passed in 17 | // scale factor 18 | int Scale(int source, double scale_factor) { 19 | return static_cast(source * scale_factor); 20 | } 21 | 22 | // Dynamically loads the |EnableNonClientDpiScaling| from the User32 module. 23 | // This API is only needed for PerMonitor V1 awareness mode. 24 | void EnableFullDpiSupportIfAvailable(HWND hwnd) { 25 | HMODULE user32_module = LoadLibraryA("User32.dll"); 26 | if (!user32_module) { 27 | return; 28 | } 29 | auto enable_non_client_dpi_scaling = 30 | reinterpret_cast( 31 | GetProcAddress(user32_module, "EnableNonClientDpiScaling")); 32 | if (enable_non_client_dpi_scaling != nullptr) { 33 | enable_non_client_dpi_scaling(hwnd); 34 | FreeLibrary(user32_module); 35 | } 36 | } 37 | 38 | } // namespace 39 | 40 | // Manages the Win32Window's window class registration. 41 | class WindowClassRegistrar { 42 | public: 43 | ~WindowClassRegistrar() = default; 44 | 45 | // Returns the singleton registar instance. 46 | static WindowClassRegistrar* GetInstance() { 47 | if (!instance_) { 48 | instance_ = new WindowClassRegistrar(); 49 | } 50 | return instance_; 51 | } 52 | 53 | // Returns the name of the window class, registering the class if it hasn't 54 | // previously been registered. 55 | const wchar_t* GetWindowClass(); 56 | 57 | // Unregisters the window class. Should only be called if there are no 58 | // instances of the window. 59 | void UnregisterWindowClass(); 60 | 61 | private: 62 | WindowClassRegistrar() = default; 63 | 64 | static WindowClassRegistrar* instance_; 65 | 66 | bool class_registered_ = false; 67 | }; 68 | 69 | WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr; 70 | 71 | const wchar_t* WindowClassRegistrar::GetWindowClass() { 72 | if (!class_registered_) { 73 | WNDCLASS window_class{}; 74 | window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); 75 | window_class.lpszClassName = kWindowClassName; 76 | window_class.style = CS_HREDRAW | CS_VREDRAW; 77 | window_class.cbClsExtra = 0; 78 | window_class.cbWndExtra = 0; 79 | window_class.hInstance = GetModuleHandle(nullptr); 80 | window_class.hIcon = 81 | LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); 82 | window_class.hbrBackground = 0; 83 | window_class.lpszMenuName = nullptr; 84 | window_class.lpfnWndProc = Win32Window::WndProc; 85 | RegisterClass(&window_class); 86 | class_registered_ = true; 87 | } 88 | return kWindowClassName; 89 | } 90 | 91 | void WindowClassRegistrar::UnregisterWindowClass() { 92 | UnregisterClass(kWindowClassName, nullptr); 93 | class_registered_ = false; 94 | } 95 | 96 | Win32Window::Win32Window() { 97 | ++g_active_window_count; 98 | } 99 | 100 | Win32Window::~Win32Window() { 101 | --g_active_window_count; 102 | Destroy(); 103 | } 104 | 105 | bool Win32Window::CreateAndShow(const std::wstring& title, 106 | const Point& origin, 107 | const Size& size) { 108 | Destroy(); 109 | 110 | const wchar_t* window_class = 111 | WindowClassRegistrar::GetInstance()->GetWindowClass(); 112 | 113 | const POINT target_point = {static_cast(origin.x), 114 | static_cast(origin.y)}; 115 | HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST); 116 | UINT dpi = FlutterDesktopGetDpiForMonitor(monitor); 117 | double scale_factor = dpi / 96.0; 118 | 119 | HWND window = CreateWindow( 120 | window_class, title.c_str(), WS_OVERLAPPEDWINDOW | WS_VISIBLE, 121 | Scale(origin.x, scale_factor), Scale(origin.y, scale_factor), 122 | Scale(size.width, scale_factor), Scale(size.height, scale_factor), 123 | nullptr, nullptr, GetModuleHandle(nullptr), this); 124 | 125 | if (!window) { 126 | return false; 127 | } 128 | 129 | return OnCreate(); 130 | } 131 | 132 | // static 133 | LRESULT CALLBACK Win32Window::WndProc(HWND const window, 134 | UINT const message, 135 | WPARAM const wparam, 136 | LPARAM const lparam) noexcept { 137 | if (message == WM_NCCREATE) { 138 | auto window_struct = reinterpret_cast(lparam); 139 | SetWindowLongPtr(window, GWLP_USERDATA, 140 | reinterpret_cast(window_struct->lpCreateParams)); 141 | 142 | auto that = static_cast(window_struct->lpCreateParams); 143 | EnableFullDpiSupportIfAvailable(window); 144 | that->window_handle_ = window; 145 | } else if (Win32Window* that = GetThisFromHandle(window)) { 146 | return that->MessageHandler(window, message, wparam, lparam); 147 | } 148 | 149 | return DefWindowProc(window, message, wparam, lparam); 150 | } 151 | 152 | LRESULT 153 | Win32Window::MessageHandler(HWND hwnd, 154 | UINT const message, 155 | WPARAM const wparam, 156 | LPARAM const lparam) noexcept { 157 | switch (message) { 158 | case WM_DESTROY: 159 | window_handle_ = nullptr; 160 | Destroy(); 161 | if (quit_on_close_) { 162 | PostQuitMessage(0); 163 | } 164 | return 0; 165 | 166 | case WM_DPICHANGED: { 167 | auto newRectSize = reinterpret_cast(lparam); 168 | LONG newWidth = newRectSize->right - newRectSize->left; 169 | LONG newHeight = newRectSize->bottom - newRectSize->top; 170 | 171 | SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth, 172 | newHeight, SWP_NOZORDER | SWP_NOACTIVATE); 173 | 174 | return 0; 175 | } 176 | case WM_SIZE: { 177 | RECT rect = GetClientArea(); 178 | if (child_content_ != nullptr) { 179 | // Size and position the child window. 180 | MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left, 181 | rect.bottom - rect.top, TRUE); 182 | } 183 | return 0; 184 | } 185 | 186 | case WM_ACTIVATE: 187 | if (child_content_ != nullptr) { 188 | SetFocus(child_content_); 189 | } 190 | return 0; 191 | } 192 | 193 | return DefWindowProc(window_handle_, message, wparam, lparam); 194 | } 195 | 196 | void Win32Window::Destroy() { 197 | OnDestroy(); 198 | 199 | if (window_handle_) { 200 | DestroyWindow(window_handle_); 201 | window_handle_ = nullptr; 202 | } 203 | if (g_active_window_count == 0) { 204 | WindowClassRegistrar::GetInstance()->UnregisterWindowClass(); 205 | } 206 | } 207 | 208 | Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept { 209 | return reinterpret_cast( 210 | GetWindowLongPtr(window, GWLP_USERDATA)); 211 | } 212 | 213 | void Win32Window::SetChildContent(HWND content) { 214 | child_content_ = content; 215 | SetParent(content, window_handle_); 216 | RECT frame = GetClientArea(); 217 | 218 | MoveWindow(content, frame.left, frame.top, frame.right - frame.left, 219 | frame.bottom - frame.top, true); 220 | 221 | SetFocus(child_content_); 222 | } 223 | 224 | RECT Win32Window::GetClientArea() { 225 | RECT frame; 226 | GetClientRect(window_handle_, &frame); 227 | return frame; 228 | } 229 | 230 | HWND Win32Window::GetHandle() { 231 | return window_handle_; 232 | } 233 | 234 | void Win32Window::SetQuitOnClose(bool quit_on_close) { 235 | quit_on_close_ = quit_on_close; 236 | } 237 | 238 | bool Win32Window::OnCreate() { 239 | // No-op; provided for subclasses. 240 | return true; 241 | } 242 | 243 | void Win32Window::OnDestroy() { 244 | // No-op; provided for subclasses. 245 | } 246 | -------------------------------------------------------------------------------- /packages/keypress_simulator/example/windows/runner/win32_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_WIN32_WINDOW_H_ 2 | #define RUNNER_WIN32_WINDOW_H_ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | // A class abstraction for a high DPI-aware Win32 Window. Intended to be 11 | // inherited from by classes that wish to specialize with custom 12 | // rendering and input handling 13 | class Win32Window { 14 | public: 15 | struct Point { 16 | unsigned int x; 17 | unsigned int y; 18 | Point(unsigned int x, unsigned int y) : x(x), y(y) {} 19 | }; 20 | 21 | struct Size { 22 | unsigned int width; 23 | unsigned int height; 24 | Size(unsigned int width, unsigned int height) 25 | : width(width), height(height) {} 26 | }; 27 | 28 | Win32Window(); 29 | virtual ~Win32Window(); 30 | 31 | // Creates and shows a win32 window with |title| and position and size using 32 | // |origin| and |size|. New windows are created on the default monitor. Window 33 | // sizes are specified to the OS in physical pixels, hence to ensure a 34 | // consistent size to will treat the width height passed in to this function 35 | // as logical pixels and scale to appropriate for the default monitor. Returns 36 | // true if the window was created successfully. 37 | bool CreateAndShow(const std::wstring& title, 38 | const Point& origin, 39 | const Size& size); 40 | 41 | // Release OS resources associated with window. 42 | void Destroy(); 43 | 44 | // Inserts |content| into the window tree. 45 | void SetChildContent(HWND content); 46 | 47 | // Returns the backing Window handle to enable clients to set icon and other 48 | // window properties. Returns nullptr if the window has been destroyed. 49 | HWND GetHandle(); 50 | 51 | // If true, closing this window will quit the application. 52 | void SetQuitOnClose(bool quit_on_close); 53 | 54 | // Return a RECT representing the bounds of the current client area. 55 | RECT GetClientArea(); 56 | 57 | protected: 58 | // Processes and route salient window messages for mouse handling, 59 | // size change and DPI. Delegates handling of these to member overloads that 60 | // inheriting classes can handle. 61 | virtual LRESULT MessageHandler(HWND window, 62 | UINT const message, 63 | WPARAM const wparam, 64 | LPARAM const lparam) noexcept; 65 | 66 | // Called when CreateAndShow is called, allowing subclass window-related 67 | // setup. Subclasses should return false if setup fails. 68 | virtual bool OnCreate(); 69 | 70 | // Called when Destroy is called. 71 | virtual void OnDestroy(); 72 | 73 | private: 74 | friend class WindowClassRegistrar; 75 | 76 | // OS callback called by message pump. Handles the WM_NCCREATE message which 77 | // is passed when the non-client area is being created and enables automatic 78 | // non-client DPI scaling so that the non-client area automatically 79 | // responsponds to changes in DPI. All other messages are handled by 80 | // MessageHandler. 81 | static LRESULT CALLBACK WndProc(HWND const window, 82 | UINT const message, 83 | WPARAM const wparam, 84 | LPARAM const lparam) noexcept; 85 | 86 | // Retrieves a class instance pointer for |window| 87 | static Win32Window* GetThisFromHandle(HWND const window) noexcept; 88 | 89 | bool quit_on_close_ = false; 90 | 91 | // window handle for top level window. 92 | HWND window_handle_ = nullptr; 93 | 94 | // window handle for hosted content. 95 | HWND child_content_ = nullptr; 96 | }; 97 | 98 | #endif // RUNNER_WIN32_WINDOW_H_ 99 | -------------------------------------------------------------------------------- /packages/keypress_simulator/lib/keypress_simulator.dart: -------------------------------------------------------------------------------- 1 | export 'src/keypress_simulator.dart'; 2 | -------------------------------------------------------------------------------- /packages/keypress_simulator/lib/src/keypress_simulator.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | import 'dart:io'; 3 | 4 | import 'package:flutter/services.dart'; 5 | import 'package:keypress_simulator_platform_interface/keypress_simulator_platform_interface.dart'; 6 | 7 | class KeyPressSimulator { 8 | KeyPressSimulator._(); 9 | 10 | /// The shared instance of [KeyPressSimulator]. 11 | static final KeyPressSimulator instance = KeyPressSimulator._(); 12 | 13 | KeyPressSimulatorPlatform get _platform => KeyPressSimulatorPlatform.instance; 14 | 15 | Future isAccessAllowed() { 16 | return _platform.isAccessAllowed(); 17 | } 18 | 19 | Future requestAccess({ 20 | bool onlyOpenPrefPane = false, 21 | }) { 22 | return _platform.requestAccess(onlyOpenPrefPane: onlyOpenPrefPane); 23 | } 24 | 25 | /// Simulate key down. 26 | Future simulateKeyDown( 27 | PhysicalKeyboardKey? key, [ 28 | List modifiers = const [], 29 | ]) { 30 | return _platform.simulateKeyPress( 31 | key: key, 32 | modifiers: modifiers, 33 | keyDown: true, 34 | ); 35 | } 36 | 37 | /// Simulate key up. 38 | Future simulateKeyUp( 39 | PhysicalKeyboardKey? key, [ 40 | List modifiers = const [], 41 | ]) { 42 | return _platform.simulateKeyPress( 43 | key: key, 44 | modifiers: modifiers, 45 | keyDown: false, 46 | ); 47 | } 48 | 49 | @Deprecated('Please use simulateKeyDown & simulateKeyUp methods.') 50 | Future simulateCtrlCKeyPress() async { 51 | const key = PhysicalKeyboardKey.keyC; 52 | final modifiers = Platform.isMacOS 53 | ? [ModifierKey.metaModifier] 54 | : [ModifierKey.controlModifier]; 55 | await simulateKeyDown(key, modifiers); 56 | await simulateKeyUp(key, modifiers); 57 | } 58 | 59 | @Deprecated('Please use simulateKeyDown & simulateKeyUp methods.') 60 | Future simulateCtrlVKeyPress() async { 61 | const key = PhysicalKeyboardKey.keyV; 62 | final modifiers = Platform.isMacOS 63 | ? [ModifierKey.metaModifier] 64 | : [ModifierKey.controlModifier]; 65 | await simulateKeyDown(key, modifiers); 66 | await simulateKeyUp(key, modifiers); 67 | } 68 | } 69 | 70 | final keyPressSimulator = KeyPressSimulator.instance; 71 | -------------------------------------------------------------------------------- /packages/keypress_simulator/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: keypress_simulator 2 | description: This plugin allows Flutter desktop apps to simulate key presses. 3 | version: 0.2.0 4 | homepage: https://github.com/leanflutter/keypress_simulator 5 | 6 | platforms: 7 | macos: 8 | windows: 9 | 10 | environment: 11 | sdk: ">=3.0.0 <4.0.0" 12 | flutter: ">=3.3.0" 13 | 14 | dependencies: 15 | flutter: 16 | sdk: flutter 17 | keypress_simulator_macos: ^0.2.0 18 | keypress_simulator_platform_interface: ^0.2.0 19 | keypress_simulator_windows: ^0.2.0 20 | 21 | dev_dependencies: 22 | flutter_test: 23 | sdk: flutter 24 | mostly_reasonable_lints: ^0.1.1 25 | 26 | flutter: 27 | plugin: 28 | platforms: 29 | macos: 30 | default_package: keypress_simulator_macos 31 | windows: 32 | default_package: keypress_simulator_windows 33 | 34 | -------------------------------------------------------------------------------- /packages/keypress_simulator_macos/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | migrate_working_dir/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # The .vscode folder contains launch configuration and tasks you configure in 20 | # VS Code which you may wish to be included in version control, so this line 21 | # is commented out by default. 22 | #.vscode/ 23 | 24 | # Flutter/Dart/Pub related 25 | # Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. 26 | /pubspec.lock 27 | **/doc/api/ 28 | .dart_tool/ 29 | build/ 30 | -------------------------------------------------------------------------------- /packages/keypress_simulator_macos/.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: "67457e669f79e9f8d13d7a68fe09775fefbb79f4" 8 | channel: "stable" 9 | 10 | project_type: plugin 11 | 12 | # Tracks metadata for the flutter migrate command 13 | migration: 14 | platforms: 15 | - platform: root 16 | create_revision: 67457e669f79e9f8d13d7a68fe09775fefbb79f4 17 | base_revision: 67457e669f79e9f8d13d7a68fe09775fefbb79f4 18 | - platform: macos 19 | create_revision: 67457e669f79e9f8d13d7a68fe09775fefbb79f4 20 | base_revision: 67457e669f79e9f8d13d7a68fe09775fefbb79f4 21 | 22 | # User provided section 23 | 24 | # List of Local paths (relative to this file) that should be 25 | # ignored by the migrate tool. 26 | # 27 | # Files that are not part of the templates will be ignored by default. 28 | unmanaged_files: 29 | - 'lib/main.dart' 30 | - 'ios/Runner.xcodeproj/project.pbxproj' 31 | -------------------------------------------------------------------------------- /packages/keypress_simulator_macos/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.2.0 2 | 3 | * First release. 4 | -------------------------------------------------------------------------------- /packages/keypress_simulator_macos/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022-2024 LiJianying 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /packages/keypress_simulator_macos/README.md: -------------------------------------------------------------------------------- 1 | # keypress_simulator_macos 2 | 3 | [![pub version][pub-image]][pub-url] 4 | 5 | [pub-image]: https://img.shields.io/pub/v/keypress_simulator_macos.svg 6 | [pub-url]: https://pub.dev/packages/keypress_simulator_macos 7 | 8 | The macOS implementation of [keypress_simulator](https://pub.dev/packages/keypress_simulator). 9 | 10 | ## License 11 | 12 | [MIT](./LICENSE) 13 | -------------------------------------------------------------------------------- /packages/keypress_simulator_macos/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:mostly_reasonable_lints/flutter.yaml 2 | -------------------------------------------------------------------------------- /packages/keypress_simulator_macos/macos/Classes/KeypressSimulatorMacosPlugin.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | public class KeypressSimulatorMacosPlugin: NSObject, FlutterPlugin { 5 | public static func register(with registrar: FlutterPluginRegistrar) { 6 | let channel = FlutterMethodChannel(name: "dev.leanflutter.plugins/keypress_simulator", binaryMessenger: registrar.messenger) 7 | let instance = KeypressSimulatorMacosPlugin() 8 | registrar.addMethodCallDelegate(instance, channel: channel) 9 | } 10 | 11 | public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { 12 | switch call.method { 13 | case "isAccessAllowed": 14 | isAccessAllowed(call, result: result) 15 | break 16 | case "requestAccess": 17 | requestAccess(call, result: result) 18 | break 19 | case "simulateKeyPress": 20 | simulateKeyPress(call, result: result) 21 | break 22 | default: 23 | result(FlutterMethodNotImplemented) 24 | } 25 | } 26 | public func isAccessAllowed(_ call: FlutterMethodCall, result: @escaping FlutterResult) { 27 | result(AXIsProcessTrusted()) 28 | } 29 | 30 | public func requestAccess(_ call: FlutterMethodCall, result: @escaping FlutterResult) { 31 | let args:[String: Any] = call.arguments as! [String: Any] 32 | let onlyOpenPrefPane: Bool = args["onlyOpenPrefPane"] as! Bool 33 | 34 | if (!onlyOpenPrefPane) { 35 | let options = [kAXTrustedCheckOptionPrompt.takeRetainedValue(): true] as CFDictionary 36 | AXIsProcessTrustedWithOptions(options) 37 | } else { 38 | let prefpaneUrl = URL(string: "x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility")! 39 | NSWorkspace.shared.open(prefpaneUrl) 40 | } 41 | result(true) 42 | } 43 | 44 | public func simulateKeyPress(_ call: FlutterMethodCall, result: @escaping FlutterResult) { 45 | let args:[String: Any] = call.arguments as! [String: Any] 46 | 47 | let keyCode: Int? = args["keyCode"] as? Int 48 | let modifiers: Array = args["modifiers"] as! Array 49 | let keyDown: Bool = args["keyDown"] as! Bool 50 | 51 | let event = _createKeyPressEvent(keyCode, modifiers, keyDown); 52 | event.post(tap: .cghidEventTap); 53 | result(true) 54 | } 55 | 56 | public func _createKeyPressEvent(_ keyCode: Int?, _ modifiers: Array, _ keyDown: Bool) -> CGEvent { 57 | let virtualKey: CGKeyCode = CGKeyCode(UInt32(keyCode ?? 0)) 58 | var flags: CGEventFlags = CGEventFlags() 59 | 60 | if (modifiers.contains("shiftModifier")) { 61 | flags.insert(CGEventFlags.maskShift) 62 | } 63 | if (modifiers.contains("controlModifier")) { 64 | flags.insert(CGEventFlags.maskControl) 65 | } 66 | if (modifiers.contains("altModifier")) { 67 | flags.insert(CGEventFlags.maskAlternate) 68 | } 69 | if (modifiers.contains("metaModifier")) { 70 | flags.insert(CGEventFlags.maskCommand) 71 | } 72 | if (modifiers.contains("functionModifier")) { 73 | flags.insert(CGEventFlags.maskSecondaryFn) 74 | } 75 | let eventKeyPress = CGEvent(keyboardEventSource: nil, virtualKey: virtualKey, keyDown: keyDown); 76 | eventKeyPress!.flags = flags 77 | return eventKeyPress! 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /packages/keypress_simulator_macos/macos/keypress_simulator_macos.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. 3 | # Run `pod lib lint keypress_simulator_macos.podspec` to validate before publishing. 4 | # 5 | Pod::Spec.new do |s| 6 | s.name = 'keypress_simulator_macos' 7 | s.version = '0.0.1' 8 | s.summary = 'A new Flutter plugin project.' 9 | s.description = <<-DESC 10 | A new Flutter plugin project. 11 | DESC 12 | s.homepage = 'http://example.com' 13 | s.license = { :file => '../LICENSE' } 14 | s.author = { 'Your Company' => 'email@example.com' } 15 | 16 | s.source = { :path => '.' } 17 | s.source_files = 'Classes/**/*' 18 | s.dependency 'FlutterMacOS' 19 | 20 | s.platform = :osx, '10.11' 21 | s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' } 22 | s.swift_version = '5.0' 23 | end 24 | -------------------------------------------------------------------------------- /packages/keypress_simulator_macos/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: keypress_simulator_macos 2 | description: macOS implementation of the keypress_simulator plugin. 3 | version: 0.2.0 4 | repository: https://github.com/leanflutter/keypress_simulator/tree/main/packages/keypress_simulator_macos 5 | 6 | environment: 7 | sdk: '>=3.0.0 <4.0.0' 8 | flutter: '>=3.3.0' 9 | 10 | dependencies: 11 | flutter: 12 | sdk: flutter 13 | keypress_simulator_platform_interface: ^0.2.0 14 | 15 | dev_dependencies: 16 | flutter_test: 17 | sdk: flutter 18 | mostly_reasonable_lints: ^0.1.1 19 | 20 | flutter: 21 | plugin: 22 | implements: keypress_simulator 23 | platforms: 24 | macos: 25 | pluginClass: KeypressSimulatorMacosPlugin 26 | 27 | -------------------------------------------------------------------------------- /packages/keypress_simulator_platform_interface/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | migrate_working_dir/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # The .vscode folder contains launch configuration and tasks you configure in 20 | # VS Code which you may wish to be included in version control, so this line 21 | # is commented out by default. 22 | #.vscode/ 23 | 24 | # Flutter/Dart/Pub related 25 | # Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. 26 | /pubspec.lock 27 | **/doc/api/ 28 | .dart_tool/ 29 | build/ 30 | -------------------------------------------------------------------------------- /packages/keypress_simulator_platform_interface/.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: "67457e669f79e9f8d13d7a68fe09775fefbb79f4" 8 | channel: "stable" 9 | 10 | project_type: plugin 11 | 12 | # Tracks metadata for the flutter migrate command 13 | migration: 14 | platforms: 15 | - platform: root 16 | create_revision: 67457e669f79e9f8d13d7a68fe09775fefbb79f4 17 | base_revision: 67457e669f79e9f8d13d7a68fe09775fefbb79f4 18 | 19 | # User provided section 20 | 21 | # List of Local paths (relative to this file) that should be 22 | # ignored by the migrate tool. 23 | # 24 | # Files that are not part of the templates will be ignored by default. 25 | unmanaged_files: 26 | - 'lib/main.dart' 27 | - 'ios/Runner.xcodeproj/project.pbxproj' 28 | -------------------------------------------------------------------------------- /packages/keypress_simulator_platform_interface/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.2.0 2 | 3 | * First release. 4 | -------------------------------------------------------------------------------- /packages/keypress_simulator_platform_interface/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022-2024 LiJianying 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /packages/keypress_simulator_platform_interface/README.md: -------------------------------------------------------------------------------- 1 | # keypress_simulator_platform_interface 2 | 3 | [![pub version][pub-image]][pub-url] 4 | 5 | [pub-image]: https://img.shields.io/pub/v/keypress_simulator_platform_interface.svg 6 | [pub-url]: https://pub.dev/packages/keypress_simulator_platform_interface 7 | 8 | A common platform interface for the [keypress_simulator](https://pub.dev/packages/keypress_simulator) plugin. 9 | 10 | ## Usage 11 | 12 | To implement a new platform-specific implementation of keypress_simulator, extend `KeyPressSimulatorPlatform` with an implementation that performs the platform-specific behavior, and when you register your plugin, set the default `KeyPressSimulatorPlatform` by calling `KeyPressSimulatorPlatform.instance = MyPlatformKeyPressSimulator()`. 13 | 14 | ## License 15 | 16 | [MIT](./LICENSE) 17 | -------------------------------------------------------------------------------- /packages/keypress_simulator_platform_interface/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:mostly_reasonable_lints/flutter.yaml 2 | -------------------------------------------------------------------------------- /packages/keypress_simulator_platform_interface/lib/keypress_simulator_platform_interface.dart: -------------------------------------------------------------------------------- 1 | library keypress_simulator_platform_interface; 2 | 3 | export 'src/keypress_simulator_method_channel.dart'; 4 | export 'src/keypress_simulator_platform_interface.dart'; 5 | -------------------------------------------------------------------------------- /packages/keypress_simulator_platform_interface/lib/src/keypress_simulator_method_channel.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/services.dart'; 2 | import 'package:flutter/widgets.dart'; 3 | import 'package:keypress_simulator_platform_interface/src/keypress_simulator_platform_interface.dart'; 4 | // ignore: implementation_imports 5 | import 'package:uni_platform/src/extensions/keyboard_key.dart'; 6 | import 'package:uni_platform/uni_platform.dart'; 7 | 8 | /// An implementation of [KeyPressSimulatorPlatform] that uses method channels. 9 | class MethodChannelKeyPressSimulator extends KeyPressSimulatorPlatform { 10 | /// The method channel used to interact with the native platform. 11 | @visibleForTesting 12 | final methodChannel = const MethodChannel( 13 | 'dev.leanflutter.plugins/keypress_simulator', 14 | ); 15 | 16 | @override 17 | Future isAccessAllowed() async { 18 | if (UniPlatform.isMacOS) { 19 | return await methodChannel.invokeMethod('isAccessAllowed'); 20 | } 21 | return true; 22 | } 23 | 24 | @override 25 | Future requestAccess({ 26 | bool onlyOpenPrefPane = false, 27 | }) async { 28 | if (UniPlatform.isMacOS) { 29 | final Map arguments = { 30 | 'onlyOpenPrefPane': onlyOpenPrefPane, 31 | }; 32 | await methodChannel.invokeMethod('requestAccess', arguments); 33 | } 34 | } 35 | 36 | @override 37 | Future simulateKeyPress({ 38 | KeyboardKey? key, 39 | List modifiers = const [], 40 | bool keyDown = true, 41 | }) async { 42 | PhysicalKeyboardKey? physicalKey = key is PhysicalKeyboardKey ? key : null; 43 | if (key is LogicalKeyboardKey) { 44 | physicalKey = key.physicalKey; 45 | } 46 | if (key != null && physicalKey == null) { 47 | throw UnsupportedError('Unsupported key: $key.'); 48 | } 49 | final Map arguments = { 50 | 'keyCode': physicalKey?.keyCode, 51 | 'modifiers': modifiers.map((e) => e.name).toList(), 52 | 'keyDown': keyDown, 53 | }..removeWhere((key, value) => value == null); 54 | await methodChannel.invokeMethod('simulateKeyPress', arguments); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /packages/keypress_simulator_platform_interface/lib/src/keypress_simulator_platform_interface.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/services.dart'; 2 | import 'package:keypress_simulator_platform_interface/src/keypress_simulator_method_channel.dart'; 3 | import 'package:plugin_platform_interface/plugin_platform_interface.dart'; 4 | 5 | abstract class KeyPressSimulatorPlatform extends PlatformInterface { 6 | /// Constructs a KeyPressSimulatorPlatform. 7 | KeyPressSimulatorPlatform() : super(token: _token); 8 | 9 | static final Object _token = Object(); 10 | 11 | static KeyPressSimulatorPlatform _instance = MethodChannelKeyPressSimulator(); 12 | 13 | /// The default instance of [KeyPressSimulatorPlatform] to use. 14 | /// 15 | /// Defaults to [MethodChannelKeyPressSimulator]. 16 | static KeyPressSimulatorPlatform get instance => _instance; 17 | 18 | /// Platform-specific implementations should set this with their own 19 | /// platform-specific class that extends [KeyPressSimulatorPlatform] when 20 | /// they register themselves. 21 | static set instance(KeyPressSimulatorPlatform instance) { 22 | PlatformInterface.verifyToken(instance, _token); 23 | _instance = instance; 24 | } 25 | 26 | Future isAccessAllowed() { 27 | throw UnimplementedError('isAccessAllowed() has not been implemented.'); 28 | } 29 | 30 | Future requestAccess({ 31 | bool onlyOpenPrefPane = false, 32 | }) { 33 | throw UnimplementedError('requestAccess() has not been implemented.'); 34 | } 35 | 36 | Future simulateKeyPress({ 37 | KeyboardKey? key, 38 | List modifiers = const [], 39 | bool keyDown = true, 40 | }) { 41 | throw UnimplementedError('simulateKeyPress() has not been implemented.'); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /packages/keypress_simulator_platform_interface/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: keypress_simulator_platform_interface 2 | description: A common platform interface for the keypress_simulator plugin. 3 | version: 0.2.0 4 | homepage: https://github.com/leanflutter/keypress_simulator/blob/main/packages/keypress_simulator_platform_interface 5 | 6 | environment: 7 | sdk: '>=3.0.0 <4.0.0' 8 | flutter: '>=3.3.0' 9 | 10 | dependencies: 11 | collection: ^1.18.0 12 | flutter: 13 | sdk: flutter 14 | plugin_platform_interface: ^2.1.8 15 | uni_platform: ^0.1.2 16 | 17 | dev_dependencies: 18 | flutter_test: 19 | sdk: flutter 20 | mostly_reasonable_lints: ^0.1.1 21 | -------------------------------------------------------------------------------- /packages/keypress_simulator_platform_interface/test/src/keypress_simulator_method_channel_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/services.dart'; 2 | import 'package:flutter_test/flutter_test.dart'; 3 | import 'package:keypress_simulator_platform_interface/src/keypress_simulator_method_channel.dart'; 4 | 5 | void main() { 6 | TestWidgetsFlutterBinding.ensureInitialized(); 7 | 8 | MethodChannelKeyPressSimulator platform = MethodChannelKeyPressSimulator(); 9 | const MethodChannel channel = MethodChannel( 10 | 'dev.leanflutter.plugins/keypress_simulator', 11 | ); 12 | 13 | setUp(() { 14 | TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger 15 | .setMockMethodCallHandler( 16 | channel, 17 | (MethodCall methodCall) async { 18 | if (methodCall.method == 'isAccessAllowed') return true; 19 | return '42'; 20 | }, 21 | ); 22 | }); 23 | 24 | tearDown(() { 25 | TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger 26 | .setMockMethodCallHandler(channel, null); 27 | }); 28 | 29 | test('isAccessAllowed', () async { 30 | expect(await platform.isAccessAllowed(), true); 31 | }); 32 | } 33 | -------------------------------------------------------------------------------- /packages/keypress_simulator_windows/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | migrate_working_dir/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # The .vscode folder contains launch configuration and tasks you configure in 20 | # VS Code which you may wish to be included in version control, so this line 21 | # is commented out by default. 22 | #.vscode/ 23 | 24 | # Flutter/Dart/Pub related 25 | # Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. 26 | /pubspec.lock 27 | **/doc/api/ 28 | .dart_tool/ 29 | build/ 30 | -------------------------------------------------------------------------------- /packages/keypress_simulator_windows/.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: "67457e669f79e9f8d13d7a68fe09775fefbb79f4" 8 | channel: "stable" 9 | 10 | project_type: plugin 11 | 12 | # Tracks metadata for the flutter migrate command 13 | migration: 14 | platforms: 15 | - platform: root 16 | create_revision: 67457e669f79e9f8d13d7a68fe09775fefbb79f4 17 | base_revision: 67457e669f79e9f8d13d7a68fe09775fefbb79f4 18 | - platform: windows 19 | create_revision: 67457e669f79e9f8d13d7a68fe09775fefbb79f4 20 | base_revision: 67457e669f79e9f8d13d7a68fe09775fefbb79f4 21 | 22 | # User provided section 23 | 24 | # List of Local paths (relative to this file) that should be 25 | # ignored by the migrate tool. 26 | # 27 | # Files that are not part of the templates will be ignored by default. 28 | unmanaged_files: 29 | - 'lib/main.dart' 30 | - 'ios/Runner.xcodeproj/project.pbxproj' 31 | -------------------------------------------------------------------------------- /packages/keypress_simulator_windows/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.2.0 2 | 3 | * First release. 4 | -------------------------------------------------------------------------------- /packages/keypress_simulator_windows/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022-2024 LiJianying 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /packages/keypress_simulator_windows/README.md: -------------------------------------------------------------------------------- 1 | # keypress_simulator_windows 2 | 3 | [![pub version][pub-image]][pub-url] 4 | 5 | [pub-image]: https://img.shields.io/pub/v/keypress_simulator_windows.svg 6 | [pub-url]: https://pub.dev/packages/keypress_simulator_windows 7 | 8 | The Windows implementation of [keypress_simulator](https://pub.dev/packages/keypress_simulator). 9 | 10 | ## License 11 | 12 | [MIT](./LICENSE) 13 | -------------------------------------------------------------------------------- /packages/keypress_simulator_windows/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:mostly_reasonable_lints/flutter.yaml 2 | -------------------------------------------------------------------------------- /packages/keypress_simulator_windows/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: keypress_simulator_windows 2 | description: Windows implementation of the keypress_simulator plugin. 3 | version: 0.2.0 4 | repository: https://github.com/leanflutter/keypress_simulator/tree/main/packages/keypress_simulator_windows 5 | 6 | environment: 7 | sdk: '>=3.0.0 <4.0.0' 8 | flutter: '>=3.3.0' 9 | 10 | dependencies: 11 | flutter: 12 | sdk: flutter 13 | keypress_simulator_platform_interface: ^0.2.0 14 | 15 | dev_dependencies: 16 | flutter_test: 17 | sdk: flutter 18 | mostly_reasonable_lints: ^0.1.1 19 | 20 | flutter: 21 | plugin: 22 | implements: keypress_simulator 23 | platforms: 24 | windows: 25 | pluginClass: KeypressSimulatorWindowsPluginCApi 26 | -------------------------------------------------------------------------------- /packages/keypress_simulator_windows/windows/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ 2 | 3 | # Visual Studio user-specific files. 4 | *.suo 5 | *.user 6 | *.userosscache 7 | *.sln.docstates 8 | 9 | # Visual Studio build-related files. 10 | x64/ 11 | x86/ 12 | 13 | # Visual Studio cache files 14 | # files ending in .cache can be ignored 15 | *.[Cc]ache 16 | # but keep track of directories ending in .cache 17 | !*.[Cc]ache/ 18 | -------------------------------------------------------------------------------- /packages/keypress_simulator_windows/windows/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # The Flutter tooling requires that developers have a version of Visual Studio 2 | # installed that includes CMake 3.14 or later. You should not increase this 3 | # version, as doing so will cause the plugin to fail to compile for some 4 | # customers of the plugin. 5 | cmake_minimum_required(VERSION 3.14) 6 | 7 | # Project-level configuration. 8 | set(PROJECT_NAME "keypress_simulator_windows") 9 | project(${PROJECT_NAME} LANGUAGES CXX) 10 | 11 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent 12 | # versions of CMake. 13 | cmake_policy(VERSION 3.14...3.25) 14 | 15 | # This value is used when generating builds using this plugin, so it must 16 | # not be changed 17 | set(PLUGIN_NAME "keypress_simulator_windows_plugin") 18 | 19 | # Any new source files that you add to the plugin should be added here. 20 | list(APPEND PLUGIN_SOURCES 21 | "keypress_simulator_windows_plugin.cpp" 22 | "keypress_simulator_windows_plugin.h" 23 | ) 24 | 25 | # Define the plugin library target. Its name must not be changed (see comment 26 | # on PLUGIN_NAME above). 27 | add_library(${PLUGIN_NAME} SHARED 28 | "include/keypress_simulator_windows/keypress_simulator_windows_plugin_c_api.h" 29 | "keypress_simulator_windows_plugin_c_api.cpp" 30 | ${PLUGIN_SOURCES} 31 | ) 32 | 33 | # Apply a standard set of build settings that are configured in the 34 | # application-level CMakeLists.txt. This can be removed for plugins that want 35 | # full control over build settings. 36 | apply_standard_settings(${PLUGIN_NAME}) 37 | 38 | # Symbols are hidden by default to reduce the chance of accidental conflicts 39 | # between plugins. This should not be removed; any symbols that should be 40 | # exported should be explicitly exported with the FLUTTER_PLUGIN_EXPORT macro. 41 | set_target_properties(${PLUGIN_NAME} PROPERTIES 42 | CXX_VISIBILITY_PRESET hidden) 43 | target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL) 44 | 45 | # Source include directories and library dependencies. Add any plugin-specific 46 | # dependencies here. 47 | target_include_directories(${PLUGIN_NAME} INTERFACE 48 | "${CMAKE_CURRENT_SOURCE_DIR}/include") 49 | target_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin) 50 | 51 | # List of absolute paths to libraries that should be bundled with the plugin. 52 | # This list could contain prebuilt libraries, or libraries created by an 53 | # external build triggered from this build file. 54 | set(keypress_simulator_windows_bundled_libraries 55 | "" 56 | PARENT_SCOPE 57 | ) 58 | 59 | # === Tests === 60 | # These unit tests can be run from a terminal after building the example, or 61 | # from Visual Studio after opening the generated solution file. 62 | 63 | # Only enable test builds when building the example (which sets this variable) 64 | # so that plugin clients aren't building the tests. 65 | if (${include_${PROJECT_NAME}_tests}) 66 | set(TEST_RUNNER "${PROJECT_NAME}_test") 67 | enable_testing() 68 | 69 | # Add the Google Test dependency. 70 | include(FetchContent) 71 | FetchContent_Declare( 72 | googletest 73 | URL https://github.com/google/googletest/archive/release-1.11.0.zip 74 | ) 75 | # Prevent overriding the parent project's compiler/linker settings 76 | set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) 77 | # Disable install commands for gtest so it doesn't end up in the bundle. 78 | set(INSTALL_GTEST OFF CACHE BOOL "Disable installation of googletest" FORCE) 79 | FetchContent_MakeAvailable(googletest) 80 | 81 | # The plugin's C API is not very useful for unit testing, so build the sources 82 | # directly into the test binary rather than using the DLL. 83 | add_executable(${TEST_RUNNER} 84 | test/keypress_simulator_windows_plugin_test.cpp 85 | ${PLUGIN_SOURCES} 86 | ) 87 | apply_standard_settings(${TEST_RUNNER}) 88 | target_include_directories(${TEST_RUNNER} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") 89 | target_link_libraries(${TEST_RUNNER} PRIVATE flutter_wrapper_plugin) 90 | target_link_libraries(${TEST_RUNNER} PRIVATE gtest_main gmock) 91 | # flutter_wrapper_plugin has link dependencies on the Flutter DLL. 92 | add_custom_command(TARGET ${TEST_RUNNER} POST_BUILD 93 | COMMAND ${CMAKE_COMMAND} -E copy_if_different 94 | "${FLUTTER_LIBRARY}" $ 95 | ) 96 | 97 | # Enable automatic test discovery. 98 | include(GoogleTest) 99 | gtest_discover_tests(${TEST_RUNNER}) 100 | endif() 101 | -------------------------------------------------------------------------------- /packages/keypress_simulator_windows/windows/include/keypress_simulator_windows/keypress_simulator_windows_plugin_c_api.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUTTER_PLUGIN_KEYPRESS_SIMULATOR_WINDOWS_PLUGIN_C_API_H_ 2 | #define FLUTTER_PLUGIN_KEYPRESS_SIMULATOR_WINDOWS_PLUGIN_C_API_H_ 3 | 4 | #include 5 | 6 | #ifdef FLUTTER_PLUGIN_IMPL 7 | #define FLUTTER_PLUGIN_EXPORT __declspec(dllexport) 8 | #else 9 | #define FLUTTER_PLUGIN_EXPORT __declspec(dllimport) 10 | #endif 11 | 12 | #if defined(__cplusplus) 13 | extern "C" { 14 | #endif 15 | 16 | FLUTTER_PLUGIN_EXPORT void KeypressSimulatorWindowsPluginCApiRegisterWithRegistrar( 17 | FlutterDesktopPluginRegistrarRef registrar); 18 | 19 | #if defined(__cplusplus) 20 | } // extern "C" 21 | #endif 22 | 23 | #endif // FLUTTER_PLUGIN_KEYPRESS_SIMULATOR_WINDOWS_PLUGIN_C_API_H_ 24 | -------------------------------------------------------------------------------- /packages/keypress_simulator_windows/windows/keypress_simulator_windows_plugin.cpp: -------------------------------------------------------------------------------- 1 | #include "keypress_simulator_windows_plugin.h" 2 | 3 | // This must be included before many other Windows headers. 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | using flutter::EncodableList; 14 | using flutter::EncodableMap; 15 | using flutter::EncodableValue; 16 | 17 | namespace keypress_simulator_windows { 18 | 19 | // static 20 | void KeypressSimulatorWindowsPlugin::RegisterWithRegistrar( 21 | flutter::PluginRegistrarWindows* registrar) { 22 | auto channel = 23 | std::make_unique>( 24 | registrar->messenger(), "dev.leanflutter.plugins/keypress_simulator", 25 | &flutter::StandardMethodCodec::GetInstance()); 26 | 27 | auto plugin = std::make_unique(); 28 | 29 | channel->SetMethodCallHandler( 30 | [plugin_pointer = plugin.get()](const auto& call, auto result) { 31 | plugin_pointer->HandleMethodCall(call, std::move(result)); 32 | }); 33 | 34 | registrar->AddPlugin(std::move(plugin)); 35 | } 36 | 37 | KeypressSimulatorWindowsPlugin::KeypressSimulatorWindowsPlugin() {} 38 | 39 | KeypressSimulatorWindowsPlugin::~KeypressSimulatorWindowsPlugin() {} 40 | 41 | void KeypressSimulatorWindowsPlugin::SimulateKeyPress( 42 | const flutter::MethodCall& method_call, 43 | std::unique_ptr> result) { 44 | const EncodableMap& args = std::get(*method_call.arguments()); 45 | 46 | UINT keyCode = std::get(args.at(EncodableValue("keyCode"))); 47 | std::vector modifiers; 48 | bool keyDown = std::get(args.at(EncodableValue("keyDown"))); 49 | 50 | EncodableList key_modifier_list = 51 | std::get(args.at(EncodableValue("modifiers"))); 52 | for (flutter::EncodableValue key_modifier_value : key_modifier_list) { 53 | std::string key_modifier = std::get(key_modifier_value); 54 | modifiers.push_back(key_modifier); 55 | } 56 | 57 | INPUT input[6]; 58 | 59 | for (int32_t i = 0; i < modifiers.size(); i++) { 60 | if (modifiers[i].compare("shiftModifier") == 0) { 61 | input[i].ki.wVk = VK_SHIFT; 62 | } else if (modifiers[i].compare("controlModifier") == 0) { 63 | input[i].ki.wVk = VK_CONTROL; 64 | } else if (modifiers[i].compare("altModifier") == 0) { 65 | input[i].ki.wVk = VK_MENU; 66 | } else if (modifiers[i].compare("metaModifier") == 0) { 67 | input[i].ki.wVk = VK_LWIN; 68 | } 69 | 70 | input[i].ki.dwFlags = keyDown ? 0 : KEYEVENTF_KEYUP; 71 | input[i].type = INPUT_KEYBOARD; 72 | } 73 | 74 | int keyIndex = static_cast(modifiers.size()); 75 | input[keyIndex].ki.wVk = static_cast(keyCode); 76 | input[keyIndex].ki.dwFlags = keyDown ? 0 : KEYEVENTF_KEYUP; 77 | input[keyIndex].type = INPUT_KEYBOARD; 78 | 79 | // Send key sequence to system 80 | SendInput(static_cast(std::size(input)), input, sizeof(INPUT)); 81 | 82 | result->Success(flutter::EncodableValue(true)); 83 | } 84 | 85 | void KeypressSimulatorWindowsPlugin::HandleMethodCall( 86 | const flutter::MethodCall& method_call, 87 | std::unique_ptr> result) { 88 | if (method_call.method_name().compare("simulateKeyPress") == 0) { 89 | SimulateKeyPress(method_call, std::move(result)); 90 | } else { 91 | result->NotImplemented(); 92 | } 93 | } 94 | 95 | } // namespace keypress_simulator_windows 96 | -------------------------------------------------------------------------------- /packages/keypress_simulator_windows/windows/keypress_simulator_windows_plugin.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUTTER_PLUGIN_KEYPRESS_SIMULATOR_WINDOWS_PLUGIN_H_ 2 | #define FLUTTER_PLUGIN_KEYPRESS_SIMULATOR_WINDOWS_PLUGIN_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | namespace keypress_simulator_windows { 10 | 11 | class KeypressSimulatorWindowsPlugin : public flutter::Plugin { 12 | public: 13 | static void RegisterWithRegistrar(flutter::PluginRegistrarWindows* registrar); 14 | 15 | KeypressSimulatorWindowsPlugin(); 16 | 17 | virtual ~KeypressSimulatorWindowsPlugin(); 18 | 19 | // Disallow copy and assign. 20 | KeypressSimulatorWindowsPlugin(const KeypressSimulatorWindowsPlugin&) = 21 | delete; 22 | KeypressSimulatorWindowsPlugin& operator=( 23 | const KeypressSimulatorWindowsPlugin&) = delete; 24 | 25 | void KeypressSimulatorWindowsPlugin::SimulateKeyPress( 26 | const flutter::MethodCall& method_call, 27 | std::unique_ptr> result); 28 | 29 | // Called when a method is called on this plugin's channel from Dart. 30 | void HandleMethodCall( 31 | const flutter::MethodCall& method_call, 32 | std::unique_ptr> result); 33 | }; 34 | 35 | } // namespace keypress_simulator_windows 36 | 37 | #endif // FLUTTER_PLUGIN_KEYPRESS_SIMULATOR_WINDOWS_PLUGIN_H_ 38 | -------------------------------------------------------------------------------- /packages/keypress_simulator_windows/windows/keypress_simulator_windows_plugin_c_api.cpp: -------------------------------------------------------------------------------- 1 | #include "include/keypress_simulator_windows/keypress_simulator_windows_plugin_c_api.h" 2 | 3 | #include 4 | 5 | #include "keypress_simulator_windows_plugin.h" 6 | 7 | void KeypressSimulatorWindowsPluginCApiRegisterWithRegistrar( 8 | FlutterDesktopPluginRegistrarRef registrar) { 9 | keypress_simulator_windows::KeypressSimulatorWindowsPlugin::RegisterWithRegistrar( 10 | flutter::PluginRegistrarManager::GetInstance() 11 | ->GetRegistrar(registrar)); 12 | } 13 | -------------------------------------------------------------------------------- /packages/keypress_simulator_windows/windows/test/keypress_simulator_windows_plugin_test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include "keypress_simulator_windows_plugin.h" 12 | 13 | namespace keypress_simulator_windows { 14 | namespace test { 15 | 16 | namespace { 17 | 18 | using flutter::EncodableMap; 19 | using flutter::EncodableValue; 20 | using flutter::MethodCall; 21 | using flutter::MethodResultFunctions; 22 | 23 | } // namespace 24 | 25 | TEST(KeypressSimulatorWindowsPlugin, GetPlatformVersion) { 26 | KeypressSimulatorWindowsPlugin plugin; 27 | // Save the reply value from the success callback. 28 | std::string result_string; 29 | plugin.HandleMethodCall( 30 | MethodCall("getPlatformVersion", std::make_unique()), 31 | std::make_unique>( 32 | [&result_string](const EncodableValue* result) { 33 | result_string = std::get(*result); 34 | }, 35 | nullptr, nullptr)); 36 | 37 | // Since the exact string varies by host, just ensure that it's a string 38 | // with the expected format. 39 | EXPECT_TRUE(result_string.rfind("Windows ", 0) == 0); 40 | } 41 | 42 | } // namespace test 43 | } // namespace keypress_simulator_windows 44 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: keypress_simulator_workspace 2 | homepage: https://github.com/leanflutter/keypress_simulator 3 | publish_to: none 4 | 5 | environment: 6 | sdk: ">=3.0.0 <4.0.0" 7 | 8 | dev_dependencies: 9 | melos: ^3.1.0 10 | --------------------------------------------------------------------------------