├── .gitignore ├── README.md ├── lib ├── keys.dart └── main.dart ├── pubspec.yaml └── windows ├── .gitignore ├── AppConfiguration.props ├── FlutterBuild.vcxproj ├── FlutterPlugins.props ├── Runner.rc ├── Runner.sln ├── Runner.vcxproj ├── Runner.vcxproj.filters ├── flutter ├── generated_plugin_registrant.cc └── generated_plugin_registrant.h ├── main.cpp ├── resource.h ├── resources └── app_icon.ico ├── runner.exe.manifest ├── scripts ├── bundle_assets_and_deps.bat └── prepare_dependencies.bat ├── win32_window.cc ├── win32_window.h ├── window_configuration.cpp └── window_configuration.h /.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 | .dart_tool/ 26 | .flutter-plugins 27 | .flutter-plugins-dependencies 28 | .packages 29 | .pub-cache/ 30 | .pub/ 31 | /build/ 32 | 33 | # Web related 34 | lib/generated_plugin_registrant.dart 35 | 36 | # Exceptions to above rules. 37 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages 38 | /.metadata 39 | /pubspec.lock 40 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # windows_autoclick 2 | 3 | Autoclicker for windows built with flutter desktop using dart ffi. 4 | -------------------------------------------------------------------------------- /lib/keys.dart: -------------------------------------------------------------------------------- 1 | const keys = { 2 | '0': 0x30, 3 | '1': 0x31, 4 | '2': 0x32, 5 | '3': 0x33, 6 | '4': 0x34, 7 | '5': 0x35, 8 | '6': 0x36, 9 | '7': 0x37, 10 | '8': 0x38, 11 | '9': 0x39, 12 | 'A': 0x41, 13 | 'B': 0x42, 14 | 'C': 0x43, 15 | 'D': 0x44, 16 | 'E': 0x45, 17 | 'F': 0x46, 18 | 'G': 0x47, 19 | 'H': 0x48, 20 | 'I': 0x49, 21 | 'J': 0x4A, 22 | 'K': 0x4B, 23 | 'L': 0x4C, 24 | 'M': 0x4D, 25 | 'N': 0x4E, 26 | 'O': 0x4F, 27 | 'P': 0x50, 28 | 'Q': 0x51, 29 | 'R': 0x52, 30 | 'S': 0x53, 31 | 'T': 0x54, 32 | 'U': 0x55, 33 | 'V': 0x56, 34 | 'W': 0x57, 35 | 'X': 0x58, 36 | 'Y': 0x59, 37 | 'Z': 0x5A, 38 | 'TAB': 0x09, 39 | 'SHIFT': 0x10, 40 | 'CTRL': 0x11, 41 | 'ALT': 0x12, 42 | }; 43 | -------------------------------------------------------------------------------- /lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:flutter/material.dart'; 4 | 5 | import 'package:flutter/foundation.dart' 6 | show debugDefaultTargetPlatformOverride; 7 | import 'package:dart_winapi/user32.dart'; 8 | import 'package:flutter/services.dart'; 9 | 10 | import 'keys.dart'; 11 | 12 | void main() { 13 | // See https://github.com/flutter/flutter/wiki/Desktop-shells#target-platform-override 14 | debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia; 15 | 16 | runApp(new MyApp()); 17 | } 18 | 19 | class MyApp extends StatelessWidget { 20 | // This widget is the root of your application. 21 | @override 22 | Widget build(BuildContext context) { 23 | return MaterialApp( 24 | title: 'Flutter AutoClicker', 25 | theme: ThemeData( 26 | primarySwatch: Colors.blue, 27 | ), 28 | home: MyHomePage(title: 'Flutter AutoClicker'), 29 | ); 30 | } 31 | } 32 | 33 | class MyHomePage extends StatefulWidget { 34 | MyHomePage({Key key, this.title}) : super(key: key); 35 | 36 | final String title; 37 | 38 | @override 39 | _MyHomePageState createState() => _MyHomePageState(); 40 | } 41 | 42 | class _MyHomePageState extends State { 43 | var _leftClick = true; 44 | var _start = false; 45 | var _cps = 100; 46 | var _key = 'ALT'; 47 | var _clickCount = 0; 48 | Timer _timer; 49 | Timer _timer2; 50 | 51 | @override 52 | Widget build(BuildContext context) { 53 | return Scaffold( 54 | appBar: AppBar( 55 | title: Text(widget.title), 56 | ), 57 | body: Center( 58 | child: Column( 59 | mainAxisAlignment: MainAxisAlignment.center, 60 | children: [ 61 | Text('Press ${_key ?? 'INVALID'} to toggle'), 62 | Container( 63 | alignment: Alignment.center, 64 | width: 400, 65 | padding: const EdgeInsets.all(8.0), 66 | child: TextFormField( 67 | inputFormatters: [ 68 | WhitelistingTextInputFormatter.digitsOnly 69 | ], 70 | readOnly: _start, 71 | initialValue: '100', 72 | onChanged: (string) { 73 | var n = int.tryParse(string.trim()); 74 | if (n == null || 0 >= n) { 75 | _cps = null; 76 | return; 77 | } 78 | _cps = n; 79 | }, 80 | decoration: InputDecoration(labelText: 'Click speed in ms'), 81 | ), 82 | ), 83 | Container( 84 | alignment: Alignment.center, 85 | width: 400, 86 | padding: const EdgeInsets.all(8.0), 87 | child: TextFormField( 88 | inputFormatters: [ 89 | WhitelistingTextInputFormatter.digitsOnly 90 | ], 91 | readOnly: _start, 92 | initialValue: '0', 93 | onChanged: (string) { 94 | var n = int.tryParse(string.trim()); 95 | if (n == null || 0 >= n) { 96 | _clickCount = null; 97 | return; 98 | } 99 | _clickCount = n; 100 | }, 101 | decoration: InputDecoration( 102 | labelText: 'Click count (0 = until stopped)'), 103 | ), 104 | ), 105 | Container( 106 | alignment: Alignment.center, 107 | width: 400, 108 | padding: const EdgeInsets.all(8.0), 109 | child: TextFormField( 110 | maxLength: 5, 111 | readOnly: _start, 112 | initialValue: 'ALT', 113 | onChanged: (string) { 114 | var valid = keys[string.toUpperCase()] != null; 115 | print('Changed: $valid'); 116 | if (valid) { 117 | setState(() { 118 | _key = string.toUpperCase(); 119 | }); 120 | } else { 121 | setState(() { 122 | _key = null; 123 | _start = false; 124 | }); 125 | } 126 | }, 127 | decoration: InputDecoration(labelText: 'Toggle Key'), 128 | ), 129 | ), 130 | RaisedButton( 131 | child: _leftClick ? Text('Left Click') : Text('Right Click'), 132 | onPressed: () { 133 | if (_start) { 134 | return; 135 | } 136 | setState(() { 137 | _leftClick = !_leftClick; 138 | }); 139 | }, 140 | ), 141 | RaisedButton( 142 | child: _start ? Text('Started') : Text('Stopped'), 143 | onPressed: () async { 144 | if (_cps == null || _key == null) { 145 | return; 146 | } 147 | print('Cps: $_cps'); 148 | setState(() { 149 | _start = !_start; 150 | }); 151 | if (_start) { 152 | print('Waiting keypress...'); 153 | Future.doWhile(() async { 154 | if (!_start) { 155 | return false; 156 | } 157 | var key = keys[_key]; 158 | if (key == null) { 159 | // Avoid too many calls. 160 | await Future.delayed(Duration(milliseconds: 100)); 161 | return true; 162 | } 163 | await keyPress(key); 164 | var count = 0; 165 | _timer2 = 166 | Timer.periodic(Duration(milliseconds: _cps), (timer) { 167 | if (_clickCount != 0) { 168 | count++; 169 | } 170 | if (_leftClick) { 171 | MouseEvent(dwFlags: MOUSEEVENTF_LEFTDOWN); 172 | MouseEvent(dwFlags: MOUSEEVENTF_LEFTUP); 173 | } else { 174 | MouseEvent(dwFlags: MOUSEEVENTF_RIGHTDOWN); 175 | MouseEvent(dwFlags: MOUSEEVENTF_RIGHTUP); 176 | } 177 | if (_clickCount != 0 && count == _clickCount) { 178 | _timer.cancel(); 179 | timer.cancel(); 180 | setState(() { 181 | _start = false; 182 | }); 183 | } 184 | }); 185 | if (!_start) { 186 | return false; 187 | } 188 | await keyPress(key); 189 | _timer2?.cancel(); 190 | return true; 191 | }); 192 | } else { 193 | print('Stop Waiting'); 194 | _timer?.cancel(); 195 | _timer2?.cancel(); 196 | } 197 | }, 198 | ), 199 | ], 200 | ), 201 | ), 202 | ); 203 | } 204 | 205 | /// Completes when the key is pressed and released. 206 | Future keyPress(int key) async { 207 | var completer = Completer(); 208 | bool pressing = false; 209 | _timer = Timer.periodic(Duration(milliseconds: 10), (timer) { 210 | var x = GetKeyState(key) & 0x8000; 211 | if (x == 0) { 212 | if (pressing) { 213 | timer.cancel(); 214 | completer.complete(); 215 | return; 216 | } 217 | return; 218 | } 219 | pressing = true; 220 | return; 221 | }); 222 | return completer.future; 223 | } 224 | } 225 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: windows_autoclick 2 | description: Autoclicker for windows. 3 | 4 | version: 1.0.0+1 5 | 6 | environment: 7 | sdk: ">=2.7.0 <3.0.0" 8 | 9 | dependencies: 10 | flutter: 11 | sdk: flutter 12 | 13 | dart_winapi: ^0.0.2 14 | 15 | flutter: 16 | uses-material-design: true -------------------------------------------------------------------------------- /windows/.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # Local additions, not from the link above 7 | flutter/ephemeral/ 8 | 9 | # User-specific files 10 | *.suo 11 | *.user 12 | *.userosscache 13 | *.sln.docstates 14 | 15 | # User-specific files (MonoDevelop/Xamarin Studio) 16 | *.userprefs 17 | 18 | # Build results 19 | [Dd]ebug/ 20 | [Dd]ebugPublic/ 21 | [Rr]elease/ 22 | [Rr]eleases/ 23 | x64/ 24 | x86/ 25 | bld/ 26 | [Bb]in/ 27 | [Oo]bj/ 28 | [Ll]og/ 29 | 30 | # Visual Studio 2015/2017 cache/options directory 31 | .vs/ 32 | # Uncomment if you have tasks that create the project's static files in wwwroot 33 | #wwwroot/ 34 | 35 | # Visual Studio 2017 auto generated files 36 | Generated\ Files/ 37 | 38 | # MSTest test Results 39 | [Tt]est[Rr]esult*/ 40 | [Bb]uild[Ll]og.* 41 | 42 | # NUNIT 43 | *.VisualState.xml 44 | TestResult.xml 45 | 46 | # Build Results of an ATL Project 47 | [Dd]ebugPS/ 48 | [Rr]eleasePS/ 49 | dlldata.c 50 | 51 | # Benchmark Results 52 | BenchmarkDotNet.Artifacts/ 53 | 54 | # .NET Core 55 | project.lock.json 56 | project.fragment.lock.json 57 | artifacts/ 58 | 59 | # StyleCop 60 | StyleCopReport.xml 61 | 62 | # Files built by Visual Studio 63 | *_i.c 64 | *_p.c 65 | *_i.h 66 | *.ilk 67 | *.meta 68 | *.obj 69 | *.iobj 70 | *.pch 71 | *.pdb 72 | *.ipdb 73 | *.pgc 74 | *.pgd 75 | *.rsp 76 | *.sbr 77 | *.tlb 78 | *.tli 79 | *.tlh 80 | *.tmp 81 | *.tmp_proj 82 | *.log 83 | *.vspscc 84 | *.vssscc 85 | .builds 86 | *.pidb 87 | *.svclog 88 | *.scc 89 | 90 | # Chutzpah Test files 91 | _Chutzpah* 92 | 93 | # Visual C++ cache files 94 | ipch/ 95 | *.aps 96 | *.ncb 97 | *.opendb 98 | *.opensdf 99 | *.sdf 100 | *.cachefile 101 | *.VC.db 102 | *.VC.VC.opendb 103 | 104 | # Visual Studio profiler 105 | *.psess 106 | *.vsp 107 | *.vspx 108 | *.sap 109 | 110 | # Visual Studio Trace Files 111 | *.e2e 112 | 113 | # TFS 2012 Local Workspace 114 | $tf/ 115 | 116 | # Guidance Automation Toolkit 117 | *.gpState 118 | 119 | # ReSharper is a .NET coding add-in 120 | _ReSharper*/ 121 | *.[Rr]e[Ss]harper 122 | *.DotSettings.user 123 | 124 | # JustCode is a .NET coding add-in 125 | .JustCode 126 | 127 | # TeamCity is a build add-in 128 | _TeamCity* 129 | 130 | # DotCover is a Code Coverage Tool 131 | *.dotCover 132 | 133 | # AxoCover is a Code Coverage Tool 134 | .axoCover/* 135 | !.axoCover/settings.json 136 | 137 | # Visual Studio code coverage results 138 | *.coverage 139 | *.coveragexml 140 | 141 | # NCrunch 142 | _NCrunch_* 143 | .*crunch*.local.xml 144 | nCrunchTemp_* 145 | 146 | # MightyMoose 147 | *.mm.* 148 | AutoTest.Net/ 149 | 150 | # Web workbench (sass) 151 | .sass-cache/ 152 | 153 | # Installshield output folder 154 | [Ee]xpress/ 155 | 156 | # DocProject is a documentation generator add-in 157 | DocProject/buildhelp/ 158 | DocProject/Help/*.HxT 159 | DocProject/Help/*.HxC 160 | DocProject/Help/*.hhc 161 | DocProject/Help/*.hhk 162 | DocProject/Help/*.hhp 163 | DocProject/Help/Html2 164 | DocProject/Help/html 165 | 166 | # Click-Once directory 167 | publish/ 168 | 169 | # Publish Web Output 170 | *.[Pp]ublish.xml 171 | *.azurePubxml 172 | # Note: Comment the next line if you want to checkin your web deploy settings, 173 | # but database connection strings (with potential passwords) will be unencrypted 174 | *.pubxml 175 | *.publishproj 176 | 177 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 178 | # checkin your Azure Web App publish settings, but sensitive information contained 179 | # in these scripts will be unencrypted 180 | PublishScripts/ 181 | 182 | # NuGet Packages 183 | *.nupkg 184 | # The packages folder can be ignored because of Package Restore 185 | **/[Pp]ackages/* 186 | # except build/, which is used as an MSBuild target. 187 | !**/[Pp]ackages/build/ 188 | # Uncomment if necessary however generally it will be regenerated when needed 189 | #!**/[Pp]ackages/repositories.config 190 | # NuGet v3's project.json files produces more ignorable files 191 | *.nuget.props 192 | *.nuget.targets 193 | 194 | # Microsoft Azure Build Output 195 | csx/ 196 | *.build.csdef 197 | 198 | # Microsoft Azure Emulator 199 | ecf/ 200 | rcf/ 201 | 202 | # Windows Store app package directories and files 203 | AppPackages/ 204 | BundleArtifacts/ 205 | Package.StoreAssociation.xml 206 | _pkginfo.txt 207 | *.appx 208 | 209 | # Visual Studio cache files 210 | # files ending in .cache can be ignored 211 | *.[Cc]ache 212 | # but keep track of directories ending in .cache 213 | !*.[Cc]ache/ 214 | 215 | # Others 216 | ClientBin/ 217 | ~$* 218 | *~ 219 | *.dbmdl 220 | *.dbproj.schemaview 221 | *.jfm 222 | *.pfx 223 | *.publishsettings 224 | orleans.codegen.cs 225 | 226 | # Including strong name files can present a security risk 227 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 228 | #*.snk 229 | 230 | # Since there are multiple workflows, uncomment next line to ignore bower_components 231 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 232 | #bower_components/ 233 | 234 | # RIA/Silverlight projects 235 | Generated_Code/ 236 | 237 | # Backup & report files from converting an old project file 238 | # to a newer Visual Studio version. Backup files are not needed, 239 | # because we have git ;-) 240 | _UpgradeReport_Files/ 241 | Backup*/ 242 | UpgradeLog*.XML 243 | UpgradeLog*.htm 244 | ServiceFabricBackup/ 245 | *.rptproj.bak 246 | 247 | # SQL Server files 248 | *.mdf 249 | *.ldf 250 | *.ndf 251 | 252 | # Business Intelligence projects 253 | *.rdl.data 254 | *.bim.layout 255 | *.bim_*.settings 256 | *.rptproj.rsuser 257 | 258 | # Microsoft Fakes 259 | FakesAssemblies/ 260 | 261 | # GhostDoc plugin setting file 262 | *.GhostDoc.xml 263 | 264 | # Node.js Tools for Visual Studio 265 | .ntvs_analysis.dat 266 | node_modules/ 267 | 268 | # Visual Studio 6 build log 269 | *.plg 270 | 271 | # Visual Studio 6 workspace options file 272 | *.opt 273 | 274 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 275 | *.vbw 276 | 277 | # Visual Studio LightSwitch build output 278 | **/*.HTMLClient/GeneratedArtifacts 279 | **/*.DesktopClient/GeneratedArtifacts 280 | **/*.DesktopClient/ModelManifest.xml 281 | **/*.Server/GeneratedArtifacts 282 | **/*.Server/ModelManifest.xml 283 | _Pvt_Extensions 284 | 285 | # Paket dependency manager 286 | .paket/paket.exe 287 | paket-files/ 288 | 289 | # FAKE - F# Make 290 | .fake/ 291 | 292 | # JetBrains Rider 293 | .idea/ 294 | *.sln.iml 295 | 296 | # CodeRush 297 | .cr/ 298 | 299 | # Python Tools for Visual Studio (PTVS) 300 | __pycache__/ 301 | *.pyc 302 | 303 | # Cake - Uncomment if you are using it 304 | # tools/** 305 | # !tools/packages.config 306 | 307 | # Tabs Studio 308 | *.tss 309 | 310 | # Telerik's JustMock configuration file 311 | *.jmconfig 312 | 313 | # BizTalk build output 314 | *.btp.cs 315 | *.btm.cs 316 | *.odx.cs 317 | *.xsd.cs 318 | 319 | # OpenCover UI analysis results 320 | OpenCover/ 321 | 322 | # Azure Stream Analytics local run output 323 | ASALocalRun/ 324 | 325 | # MSBuild Binary and Structured Log 326 | *.binlog 327 | 328 | # NVidia Nsight GPU debugger configuration file 329 | *.nvuser 330 | 331 | # MFractors (Xamarin productivity tool) working folder 332 | .mfractor/ 333 | -------------------------------------------------------------------------------- /windows/AppConfiguration.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Flutter Desktop Example 5 | 6 | 7 | -------------------------------------------------------------------------------- /windows/FlutterBuild.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | x64 7 | 8 | 9 | Release 10 | x64 11 | 12 | 13 | 14 | 15.0 15 | {6419BF13-6ECD-4CD2-9E85-E566A1F03F8F} 16 | Flutter Build 17 | 10.0.17763.0 18 | 19 | 20 | 21 | v141 22 | v142 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | "$(ProjectDir)scripts\prepare_dependencies" $(Configuration) 37 | Running Flutter backend build 38 | force_to_run_every_time 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /windows/FlutterPlugins.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | %(AdditionalDependencies) 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /windows/Runner.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hexer10/flutter_autoclicker/e0e69b8f0b59d445c5688f73f8d73a5b93898e87/windows/Runner.rc -------------------------------------------------------------------------------- /windows/Runner.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.645 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Runner", "Runner.vcxproj", "{5A827760-CF8B-408A-99A3-B6C0AD2271E7}" 7 | ProjectSection(ProjectDependencies) = postProject 8 | {6419BF13-6ECD-4CD2-9E85-E566A1F03F8F} = {6419BF13-6ECD-4CD2-9E85-E566A1F03F8F} 9 | EndProjectSection 10 | EndProject 11 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Flutter Build", "FlutterBuild.vcxproj", "{6419BF13-6ECD-4CD2-9E85-E566A1F03F8F}" 12 | EndProject 13 | Global 14 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 15 | Debug|x64 = Debug|x64 16 | Release|x64 = Release|x64 17 | EndGlobalSection 18 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 19 | {5A827760-CF8B-408A-99A3-B6C0AD2271E7}.Debug|x64.ActiveCfg = Debug|x64 20 | {5A827760-CF8B-408A-99A3-B6C0AD2271E7}.Debug|x64.Build.0 = Debug|x64 21 | {5A827760-CF8B-408A-99A3-B6C0AD2271E7}.Release|x64.ActiveCfg = Release|x64 22 | {5A827760-CF8B-408A-99A3-B6C0AD2271E7}.Release|x64.Build.0 = Release|x64 23 | {6419BF13-6ECD-4CD2-9E85-E566A1F03F8F}.Debug|x64.ActiveCfg = Debug|x64 24 | {6419BF13-6ECD-4CD2-9E85-E566A1F03F8F}.Debug|x64.Build.0 = Debug|x64 25 | {6419BF13-6ECD-4CD2-9E85-E566A1F03F8F}.Release|x64.ActiveCfg = Release|x64 26 | {6419BF13-6ECD-4CD2-9E85-E566A1F03F8F}.Release|x64.Build.0 = Release|x64 27 | EndGlobalSection 28 | GlobalSection(SolutionProperties) = preSolution 29 | HideSolutionNode = FALSE 30 | EndGlobalSection 31 | GlobalSection(ExtensibilityGlobals) = postSolution 32 | SolutionGuid = {B8A69CB0-A974-4774-9EBD-1E5EECACD186} 33 | EndGlobalSection 34 | EndGlobal 35 | -------------------------------------------------------------------------------- /windows/Runner.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | x64 7 | 8 | 9 | Release 10 | x64 11 | 12 | 13 | 14 | 15.0 15 | {5A827760-CF8B-408A-99A3-B6C0AD2271E7} 16 | GLFWExample 17 | 10.0.17763.0 18 | 19 | 20 | 21 | Application 22 | true 23 | v141 24 | v142 25 | Unicode 26 | 27 | 28 | Application 29 | false 30 | v141 31 | v142 32 | true 33 | Unicode 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | $(ProjectDir)..\build\windows\$(Platform)\$(Configuration)\$(ProjectName)\ 55 | $(ProjectDir)..\build\windows\intermediates\$(Platform)\$(Configuration)\$(ProjectName)\ 56 | $(ProjectDir);$(FLUTTER_EPHEMERAL_DIR)\;$(FLUTTER_EPHEMERAL_DIR)\cpp_client_wrapper\include\;$(OutDir)..\Plugins;$(IncludePath) 57 | $(FLUTTER_EPHEMERAL_DIR);$(OutDir)..\Plugins;$(LibraryPath) 58 | 59 | 60 | $(ProjectDir)..\build\windows\$(Platform)\$(Configuration)\$(ProjectName)\ 61 | $(ProjectDir)..\build\windows\intermediates\$(Platform)\$(Configuration)\$(ProjectName)\ 62 | $(ProjectDir);$(FLUTTER_EPHEMERAL_DIR)\;$(FLUTTER_EPHEMERAL_DIR)\cpp_client_wrapper\include\;$(OutDir)..\Plugins;$(IncludePath) 63 | $(FLUTTER_EPHEMERAL_DIR);$(OutDir)..\Plugins;$(LibraryPath) 64 | 65 | 66 | 67 | Level3 68 | Disabled 69 | true 70 | true 71 | 72 | 73 | _MBCS;%(PreprocessorDefinitions) 74 | 75 | 76 | flutter_windows.dll.lib;Shcore.lib;%(AdditionalDependencies) 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | "$(ProjectDir)scripts\bundle_assets_and_deps" "$(FLUTTER_EPHEMERAL_DIR)\" "$(OutputPath)" "$(OutputPath)..\Plugins\" "$(TargetFileName)" 100 | 101 | 102 | Bundling dependencies 103 | Dummy_Run_Always 104 | 105 | 106 | 107 | 108 | 109 | 110 | Level3 111 | MaxSpeed 112 | true 113 | true 114 | true 115 | true 116 | 117 | 118 | _MBCS;%(PreprocessorDefinitions) 119 | 120 | 121 | true 122 | true 123 | flutter_windows.dll.lib;Shcore.lib;%(AdditionalDependencies) 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | "$(ProjectDir)scripts\bundle_assets_and_deps" "$(FLUTTER_EPHEMERAL_DIR)\" "$(OutputPath)" "$(OutputPath)..\Plugins\" "$(TargetFileName)" 147 | 148 | 149 | Bundling dependencies 150 | Dummy_Run_Always 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 | $(SolutionDir) 184 | 185 | 186 | -------------------------------------------------------------------------------- /windows/Runner.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | {2761a4b5-57b2-4d50-a677-d20ddc17a7f1} 18 | 19 | 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | Source Files 32 | 33 | 34 | Source Files\Client Wrapper 35 | 36 | 37 | Source Files\Client Wrapper 38 | 39 | 40 | Source Files\Client Wrapper 41 | 42 | 43 | 44 | 45 | Header Files 46 | 47 | 48 | Header Files 49 | 50 | 51 | Header Files 52 | 53 | 54 | Header Files 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | Resource Files 63 | 64 | 65 | 66 | 67 | Resource Files 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | #include "generated_plugin_registrant.h" 6 | 7 | 8 | void RegisterPlugins(flutter::PluginRegistry* registry) { 9 | } 10 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 6 | #define GENERATED_PLUGIN_REGISTRANT_ 7 | 8 | #include 9 | 10 | // Registers Flutter plugins. 11 | void RegisterPlugins(flutter::PluginRegistry* registry); 12 | 13 | #endif // GENERATED_PLUGIN_REGISTRANT_ 14 | -------------------------------------------------------------------------------- /windows/main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | #include 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #include "flutter/generated_plugin_registrant.h" 25 | #include "win32_window.h" 26 | #include "window_configuration.h" 27 | 28 | namespace { 29 | 30 | // Returns the path of the directory containing this executable, or an empty 31 | // string if the directory cannot be found. 32 | std::string GetExecutableDirectory() { 33 | wchar_t buffer[MAX_PATH]; 34 | if (GetModuleFileName(nullptr, buffer, MAX_PATH) == 0) { 35 | std::cerr << "Couldn't locate executable" << std::endl; 36 | return ""; 37 | } 38 | std::wstring_convert> wide_to_utf8; 39 | std::string executable_path = wide_to_utf8.to_bytes(buffer); 40 | size_t last_separator_position = executable_path.find_last_of('\\'); 41 | if (last_separator_position == std::string::npos) { 42 | std::cerr << "Unabled to find parent directory of " << executable_path 43 | << std::endl; 44 | return ""; 45 | } 46 | return executable_path.substr(0, last_separator_position); 47 | } 48 | 49 | } // namespace 50 | 51 | int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE prev, wchar_t *command_line, 52 | int show_command) { 53 | // Attach to console when present (e.g., 'flutter run') or create a 54 | // new console when running with a debugger. 55 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { 56 | ::AllocConsole(); 57 | } 58 | 59 | // Resources are located relative to the executable. 60 | std::string base_directory = GetExecutableDirectory(); 61 | if (base_directory.empty()) { 62 | base_directory = "."; 63 | } 64 | std::string data_directory = base_directory + "\\data"; 65 | std::string assets_path = data_directory + "\\flutter_assets"; 66 | std::string icu_data_path = data_directory + "\\icudtl.dat"; 67 | 68 | // Arguments for the Flutter Engine. 69 | std::vector arguments; 70 | 71 | // Top-level window frame. 72 | Win32Window::Point origin(kFlutterWindowOriginX, kFlutterWindowOriginY); 73 | Win32Window::Size size(kFlutterWindowWidth, kFlutterWindowHeight); 74 | 75 | flutter::FlutterViewController flutter_controller( 76 | icu_data_path, size.width, size.height, assets_path, arguments); 77 | RegisterPlugins(&flutter_controller); 78 | 79 | // Create a top-level win32 window to host the Flutter view. 80 | Win32Window window; 81 | if (!window.CreateAndShow(kFlutterWindowTitle, origin, size)) { 82 | return EXIT_FAILURE; 83 | } 84 | 85 | // Parent and resize Flutter view into top-level window. 86 | window.SetChildContent(flutter_controller.GetNativeWindow()); 87 | 88 | // Run messageloop with a hook for flutter_controller to do work until 89 | // the window is closed. 90 | std::chrono::nanoseconds wait_duration(0); 91 | // Run until the window is closed. 92 | while (window.GetHandle() != nullptr) { 93 | MsgWaitForMultipleObjects(0, NULL, FALSE, 94 | static_cast(wait_duration.count() / 1000), 95 | QS_ALLINPUT); 96 | MSG message; 97 | // All pending Windows messages must be processed; MsgWaitForMultipleObjects 98 | // won't return again for items left in the queue after PeekMessage. 99 | while (PeekMessage(&message, nullptr, 0, 0, PM_REMOVE)) { 100 | if (message.message == WM_QUIT) { 101 | window.Destroy(); 102 | break; 103 | } 104 | TranslateMessage(&message); 105 | DispatchMessage(&message); 106 | } 107 | // Allow Flutter to process its messages. 108 | // TODO: Consider interleaving processing on a per-message basis to avoid 109 | // the possibility of one queue starving the other. 110 | wait_duration = flutter_controller.ProcessMessages(); 111 | } 112 | 113 | return EXIT_SUCCESS; 114 | } 115 | -------------------------------------------------------------------------------- /windows/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 | -------------------------------------------------------------------------------- /windows/resources/app_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hexer10/flutter_autoclicker/e0e69b8f0b59d445c5688f73f8d73a5b93898e87/windows/resources/app_icon.ico -------------------------------------------------------------------------------- /windows/runner.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PerMonitorV2 6 | 7 | 8 | -------------------------------------------------------------------------------- /windows/scripts/bundle_assets_and_deps.bat: -------------------------------------------------------------------------------- 1 | :: Copyright 2018 Google LLC 2 | :: 3 | :: Licensed under the Apache License, Version 2.0 (the "License"); 4 | :: you may not use this file except in compliance with the License. 5 | :: You may obtain a copy of the License at 6 | :: 7 | :: http://www.apache.org/licenses/LICENSE-2.0 8 | :: 9 | :: Unless required by applicable law or agreed to in writing, software 10 | :: distributed under the License is distributed on an "AS IS" BASIS, 11 | :: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | :: See the License for the specific language governing permissions and 13 | :: limitations under the License. 14 | @echo off 15 | 16 | set FLUTTER_CACHE_DIR=%~1 17 | set BUNDLE_DIR=%~2 18 | set PLUGIN_DIR=%~3 19 | set EXE_NAME=%~4 20 | 21 | set DATA_DIR=%BUNDLE_DIR%data 22 | 23 | if not exist "%DATA_DIR%" call mkdir "%DATA_DIR%" 24 | if %errorlevel% neq 0 exit /b %errorlevel% 25 | 26 | :: Write the executable name to the location expected by the Flutter tool. 27 | echo %EXE_NAME%>"%FLUTTER_CACHE_DIR%exe_filename" 28 | 29 | :: Copy the Flutter assets to the data directory. 30 | set FLUTTER_APP_DIR=%~dp0..\.. 31 | set ASSET_DIR_NAME=flutter_assets 32 | set TARGET_ASSET_DIR=%DATA_DIR%\%ASSET_DIR_NAME% 33 | if exist "%TARGET_ASSET_DIR%" call rmdir /s /q "%TARGET_ASSET_DIR%" 34 | if %errorlevel% neq 0 exit /b %errorlevel% 35 | call xcopy /s /e /i /q "%FLUTTER_APP_DIR%\build\%ASSET_DIR_NAME%" "%TARGET_ASSET_DIR%" 36 | if %errorlevel% neq 0 exit /b %errorlevel% 37 | 38 | :: Copy the icudtl.dat file from the Flutter tree to the data directory. 39 | call xcopy /y /d /q "%FLUTTER_CACHE_DIR%icudtl.dat" "%DATA_DIR%" 40 | if %errorlevel% neq 0 exit /b %errorlevel% 41 | 42 | :: Copy the Flutter DLL to the target location. 43 | call xcopy /y /d /q "%FLUTTER_CACHE_DIR%flutter_windows.dll" "%BUNDLE_DIR%" 44 | if %errorlevel% neq 0 exit /b %errorlevel% 45 | 46 | :: Copy any Plugin DLLs to the target location. 47 | if exist "%PLUGIN_DIR%" ( 48 | call xcopy /y /d /q "%PLUGIN_DIR%"*.dll "%BUNDLE_DIR%" 49 | if %errorlevel% neq 0 exit /b %errorlevel% 50 | ) 51 | -------------------------------------------------------------------------------- /windows/scripts/prepare_dependencies.bat: -------------------------------------------------------------------------------- 1 | :: Copyright 2018 Google LLC 2 | :: 3 | :: Licensed under the Apache License, Version 2.0 (the "License"); 4 | :: you may not use this file except in compliance with the License. 5 | :: You may obtain a copy of the License at 6 | :: 7 | :: http://www.apache.org/licenses/LICENSE-2.0 8 | :: 9 | :: Unless required by applicable law or agreed to in writing, software 10 | :: distributed under the License is distributed on an "AS IS" BASIS, 11 | :: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | :: See the License for the specific language governing permissions and 13 | :: limitations under the License. 14 | @echo off 15 | 16 | :: Run flutter tool backend. 17 | set BUILD_MODE=%~1 18 | "%FLUTTER_ROOT%\packages\flutter_tools\bin\tool_backend" windows-x64 %BUILD_MODE% 19 | -------------------------------------------------------------------------------- /windows/win32_window.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Flutter Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "win32_window.h" 6 | 7 | #include "resource.h" 8 | #include "shellscalingapi.h" 9 | 10 | namespace { 11 | 12 | // the Windows DPI system is based on this 13 | // constant for machines running at 100% scaling. 14 | constexpr int kBaseDpi = 96; 15 | 16 | constexpr LPCWSTR kClassName = L"CLASSNAME"; 17 | 18 | // Scale helper to convert logical scaler values to physical using passed in 19 | // scale factor 20 | int Scale(int source, double scale_factor) { 21 | return static_cast(source * scale_factor); 22 | } 23 | 24 | } // namespace 25 | 26 | Win32Window::Win32Window() {} 27 | 28 | Win32Window::~Win32Window() { Destroy(); } 29 | 30 | bool Win32Window::CreateAndShow(const std::wstring &title, const Point &origin, 31 | const Size &size) { 32 | Destroy(); 33 | 34 | WNDCLASS window_class = RegisterWindowClass(); 35 | 36 | HMONITOR defaut_monitor = 37 | MonitorFromWindow(nullptr, MONITOR_DEFAULTTOPRIMARY); 38 | UINT dpi_x = 0, dpi_y = 0; 39 | GetDpiForMonitor(defaut_monitor, MDT_EFFECTIVE_DPI, &dpi_x, &dpi_y); 40 | 41 | double scale_factor = static_cast(dpi_x) / kBaseDpi; 42 | 43 | HWND window = CreateWindow( 44 | window_class.lpszClassName, title.c_str(), 45 | WS_OVERLAPPEDWINDOW | WS_VISIBLE, Scale(origin.x, scale_factor), 46 | Scale(origin.y, scale_factor), Scale(size.width, scale_factor), 47 | Scale(size.height, scale_factor), nullptr, nullptr, 48 | window_class.hInstance, this); 49 | return window != nullptr; 50 | } 51 | 52 | WNDCLASS Win32Window::RegisterWindowClass() { 53 | WNDCLASS window_class{}; 54 | window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); 55 | window_class.lpszClassName = kClassName; 56 | window_class.style = CS_HREDRAW | CS_VREDRAW; 57 | window_class.cbClsExtra = 0; 58 | window_class.cbWndExtra = 0; 59 | window_class.hInstance = GetModuleHandle(nullptr); 60 | window_class.hIcon = 61 | LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); 62 | window_class.hbrBackground = 0; 63 | window_class.lpszMenuName = nullptr; 64 | window_class.lpfnWndProc = WndProc; 65 | RegisterClass(&window_class); 66 | return window_class; 67 | } 68 | 69 | LRESULT CALLBACK Win32Window::WndProc(HWND const window, UINT const message, 70 | WPARAM const wparam, 71 | LPARAM const lparam) noexcept { 72 | if (message == WM_NCCREATE) { 73 | auto cs = reinterpret_cast(lparam); 74 | SetWindowLongPtr(window, GWLP_USERDATA, 75 | reinterpret_cast(cs->lpCreateParams)); 76 | 77 | auto that = static_cast(cs->lpCreateParams); 78 | 79 | that->window_handle_ = window; 80 | } else if (Win32Window *that = GetThisFromHandle(window)) { 81 | return that->MessageHandler(window, message, wparam, lparam); 82 | } 83 | 84 | return DefWindowProc(window, message, wparam, lparam); 85 | } 86 | 87 | LRESULT 88 | Win32Window::MessageHandler(HWND hwnd, UINT const message, WPARAM const wparam, 89 | LPARAM const lparam) noexcept { 90 | auto window = 91 | reinterpret_cast(GetWindowLongPtr(hwnd, GWLP_USERDATA)); 92 | 93 | if (window == nullptr) { 94 | return 0; 95 | } 96 | 97 | switch (message) { 98 | case WM_DESTROY: 99 | window_handle_ = nullptr; 100 | Destroy(); 101 | return 0; 102 | 103 | case WM_SIZE: 104 | RECT rect; 105 | GetClientRect(hwnd, &rect); 106 | if (child_content_ != nullptr) { 107 | // Size and position the child window. 108 | MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left, 109 | rect.bottom - rect.top, TRUE); 110 | } 111 | return 0; 112 | 113 | case WM_ACTIVATE: 114 | if (child_content_ != nullptr) { 115 | SetFocus(child_content_); 116 | } 117 | return 0; 118 | 119 | // Messages that are directly forwarded to embedding. 120 | case WM_FONTCHANGE: 121 | SendMessage(child_content_, WM_FONTCHANGE, NULL, NULL); 122 | return 0; 123 | } 124 | 125 | return DefWindowProc(window_handle_, message, wparam, lparam); 126 | } 127 | 128 | void Win32Window::Destroy() { 129 | if (window_handle_) { 130 | DestroyWindow(window_handle_); 131 | window_handle_ = nullptr; 132 | } 133 | 134 | UnregisterClass(kClassName, nullptr); 135 | } 136 | 137 | Win32Window *Win32Window::GetThisFromHandle(HWND const window) noexcept { 138 | return reinterpret_cast( 139 | GetWindowLongPtr(window, GWLP_USERDATA)); 140 | } 141 | 142 | void Win32Window::SetChildContent(HWND content) { 143 | child_content_ = content; 144 | auto res = SetParent(content, window_handle_); 145 | RECT frame; 146 | GetClientRect(window_handle_, &frame); 147 | 148 | MoveWindow(content, frame.left, frame.top, frame.right - frame.left, 149 | frame.bottom - frame.top, true); 150 | 151 | SetFocus(child_content_); 152 | } 153 | 154 | HWND Win32Window::GetHandle() { return window_handle_; } 155 | -------------------------------------------------------------------------------- /windows/win32_window.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Flutter Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef WIN32_WINDOW_H_ 6 | #define WIN32_WINDOW_H_ 7 | 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | // A class abstraction for a high DPI-aware Win32 Window. Intended to be 16 | // inherited from by classes that wish to specialize with custom 17 | // rendering and input handling 18 | class Win32Window { 19 | public: 20 | struct Point { 21 | unsigned int x; 22 | unsigned int y; 23 | Point(unsigned int x, unsigned int y) : x(x), y(y) {} 24 | }; 25 | 26 | struct Size { 27 | unsigned int width; 28 | unsigned int height; 29 | Size(unsigned int width, unsigned int height) 30 | : width(width), height(height) {} 31 | }; 32 | 33 | Win32Window(); 34 | ~Win32Window(); 35 | 36 | // Creates and shows a win32 window with |title| and position and size using 37 | // |origin| and |size|. New windows are created on the default monitor. Window 38 | // sizes are specified to the OS in physical pixels, hence to ensure a 39 | // consistent size to will treat the width height passed in to this function 40 | // as logical pixels and scale to appropriate for the default monitor. Returns 41 | // true if the window was created successfully. 42 | bool CreateAndShow(const std::wstring &title, const Point &origin, 43 | const Size &size); 44 | 45 | // Release OS resources asociated with window. 46 | void Destroy(); 47 | 48 | // Inserts |content| into the window tree. 49 | void SetChildContent(HWND content); 50 | 51 | // Returns the backing Window handle to enable clients to set icon and other 52 | // window properties. Returns nullptr if the window has been destroyed. 53 | HWND GetHandle(); 54 | 55 | protected: 56 | // Registers a window class with default style attributes, cursor and 57 | // icon. 58 | WNDCLASS RegisterWindowClass(); 59 | 60 | // OS callback called by message pump. Handles the WM_NCCREATE message which 61 | // is passed when the non-client area is being created and enables automatic 62 | // non-client DPI scaling so that the non-client area automatically 63 | // responsponds to changes in DPI. All other messages are handled by 64 | // MessageHandler. 65 | static LRESULT CALLBACK WndProc(HWND const window, UINT const message, 66 | WPARAM const wparam, 67 | LPARAM const lparam) noexcept; 68 | 69 | // Processes and route salient window messages for mouse handling, 70 | // size change and DPI. Delegates handling of these to member overloads that 71 | // inheriting classes can handle. 72 | LRESULT 73 | MessageHandler(HWND window, UINT const message, WPARAM const wparam, 74 | LPARAM const lparam) noexcept; 75 | 76 | private: 77 | // should message loop keep running 78 | bool messageloop_running_ = true; 79 | 80 | // Retrieves a class instance pointer for |window| 81 | static Win32Window *GetThisFromHandle(HWND const window) noexcept; 82 | 83 | // window handle for top level window. 84 | HWND window_handle_ = nullptr; 85 | 86 | // window handle for hosted content. 87 | HWND child_content_ = nullptr; 88 | }; 89 | 90 | #endif // WIN32_WINDOW_H_ 91 | -------------------------------------------------------------------------------- /windows/window_configuration.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "window_configuration.h" 16 | 17 | const wchar_t *kFlutterWindowTitle = L"Flutter AutoClicker"; 18 | const unsigned int kFlutterWindowOriginX = 10; 19 | const unsigned int kFlutterWindowOriginY = 10; 20 | const unsigned int kFlutterWindowWidth = 800; 21 | const unsigned int kFlutterWindowHeight = 600; 22 | -------------------------------------------------------------------------------- /windows/window_configuration.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef WINDOW_CONFIGURATION_ 16 | #define WINDOW_CONFIGURATION_ 17 | 18 | // This is a temporary approach to isolate changes that people are likely to 19 | // make to the example project from main.cpp, where the APIs are still in flux. 20 | // This will avoid people needing to resolve conflicts or re-create changes 21 | // slightly different every time the Windows Flutter API surface changes just 22 | // because of, e.g., a local change to the window title. 23 | // 24 | // Longer term there should be simpler configuration options for common 25 | // customizations like this, without requiring native code changes. 26 | 27 | extern const wchar_t *kFlutterWindowTitle; 28 | extern const unsigned int kFlutterWindowOriginX; 29 | extern const unsigned int kFlutterWindowOriginY; 30 | extern const unsigned int kFlutterWindowWidth; 31 | extern const unsigned int kFlutterWindowHeight; 32 | 33 | #endif // WINDOW_CONFIGURATION_ 34 | --------------------------------------------------------------------------------