├── .github
└── workflows
│ └── build.yml
├── .gitignore
├── LICENSE
├── README.md
├── Switchy.sln
└── Switchy
├── Switchy.vcxproj
├── Switchy.vcxproj.filters
└── main.c
/.github/workflows/build.yml:
--------------------------------------------------------------------------------
1 | # This workflow uses actions that are not certified by GitHub.
2 | # They are provided by a third-party and are governed by
3 | # separate terms of service, privacy policy, and support
4 | # documentation.
5 |
6 | name: Build
7 |
8 | on:
9 | push:
10 | branches: [ "master" ]
11 | pull_request:
12 | branches: [ "master" ]
13 |
14 | env:
15 | # Path to the solution file relative to the root of the project.
16 | SOLUTION_FILE_PATH: .
17 |
18 | # Configuration type to build.
19 | # You can convert this to a build matrix if you need coverage of multiple configuration types.
20 | # https://docs.github.com/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
21 | BUILD_CONFIGURATION: Release
22 |
23 | permissions:
24 | contents: read
25 |
26 | jobs:
27 | build:
28 | runs-on: windows-latest
29 |
30 | steps:
31 | - uses: actions/checkout@v3
32 |
33 | - name: Add MSBuild to PATH
34 | uses: microsoft/setup-msbuild@v1.0.2
35 |
36 | - name: Build
37 | working-directory: ${{env.GITHUB_WORKSPACE}}
38 | # Add additional options to the MSBuild command line here (like platform or verbosity level).
39 | # See https://docs.microsoft.com/visualstudio/msbuild/msbuild-command-line-reference
40 | run: msbuild /m /p:Configuration=${{env.BUILD_CONFIGURATION}} ${{env.SOLUTION_FILE_PATH}}
41 |
42 | - name: Upload artifact
43 | uses: actions/upload-artifact@v4.3.0
44 | with:
45 | name: Switchy.exe
46 | path: x64/Release/Switchy.exe
47 |
--------------------------------------------------------------------------------
/.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 | # User-specific files
7 | *.suo
8 | *.user
9 | *.userosscache
10 | *.sln.docstates
11 |
12 | # User-specific files (MonoDevelop/Xamarin Studio)
13 | *.userprefs
14 |
15 | # Build results
16 | [Dd]ebug/
17 | [Dd]ebugPublic/
18 | [Rr]elease/
19 | [Rr]eleases/
20 | x64/
21 | x86/
22 | bld/
23 | [Bb]in/
24 | [Oo]bj/
25 | [Ll]og/
26 |
27 | # Visual Studio 2015/2017 cache/options directory
28 | .vs/
29 | # Uncomment if you have tasks that create the project's static files in wwwroot
30 | #wwwroot/
31 |
32 | # Visual Studio 2017 auto generated files
33 | Generated\ Files/
34 |
35 | # MSTest test Results
36 | [Tt]est[Rr]esult*/
37 | [Bb]uild[Ll]og.*
38 |
39 | # NUNIT
40 | *.VisualState.xml
41 | TestResult.xml
42 |
43 | # Build Results of an ATL Project
44 | [Dd]ebugPS/
45 | [Rr]eleasePS/
46 | dlldata.c
47 |
48 | # Benchmark Results
49 | BenchmarkDotNet.Artifacts/
50 |
51 | # .NET Core
52 | project.lock.json
53 | project.fragment.lock.json
54 | artifacts/
55 | **/Properties/launchSettings.json
56 |
57 | # StyleCop
58 | StyleCopReport.xml
59 |
60 | # Files built by Visual Studio
61 | *_i.c
62 | *_p.c
63 | *_i.h
64 | *.ilk
65 | *.meta
66 | *.obj
67 | *.iobj
68 | *.pch
69 | *.pdb
70 | *.ipdb
71 | *.pgc
72 | *.pgd
73 | *.rsp
74 | *.sbr
75 | *.tlb
76 | *.tli
77 | *.tlh
78 | *.tmp
79 | *.tmp_proj
80 | *.log
81 | *.vspscc
82 | *.vssscc
83 | .builds
84 | *.pidb
85 | *.svclog
86 | *.scc
87 |
88 | # Chutzpah Test files
89 | _Chutzpah*
90 |
91 | # Visual C++ cache files
92 | ipch/
93 | *.aps
94 | *.ncb
95 | *.opendb
96 | *.opensdf
97 | *.sdf
98 | *.cachefile
99 | *.VC.db
100 | *.VC.VC.opendb
101 |
102 | # Visual Studio profiler
103 | *.psess
104 | *.vsp
105 | *.vspx
106 | *.sap
107 |
108 | # Visual Studio Trace Files
109 | *.e2e
110 |
111 | # TFS 2012 Local Workspace
112 | $tf/
113 |
114 | # Guidance Automation Toolkit
115 | *.gpState
116 |
117 | # ReSharper is a .NET coding add-in
118 | _ReSharper*/
119 | *.[Rr]e[Ss]harper
120 | *.DotSettings.user
121 |
122 | # JustCode is a .NET coding add-in
123 | .JustCode
124 |
125 | # TeamCity is a build add-in
126 | _TeamCity*
127 |
128 | # DotCover is a Code Coverage Tool
129 | *.dotCover
130 |
131 | # AxoCover is a Code Coverage Tool
132 | .axoCover/*
133 | !.axoCover/settings.json
134 |
135 | # Visual Studio code coverage results
136 | *.coverage
137 | *.coveragexml
138 |
139 | # NCrunch
140 | _NCrunch_*
141 | .*crunch*.local.xml
142 | nCrunchTemp_*
143 |
144 | # MightyMoose
145 | *.mm.*
146 | AutoTest.Net/
147 |
148 | # Web workbench (sass)
149 | .sass-cache/
150 |
151 | # Installshield output folder
152 | [Ee]xpress/
153 |
154 | # DocProject is a documentation generator add-in
155 | DocProject/buildhelp/
156 | DocProject/Help/*.HxT
157 | DocProject/Help/*.HxC
158 | DocProject/Help/*.hhc
159 | DocProject/Help/*.hhk
160 | DocProject/Help/*.hhp
161 | DocProject/Help/Html2
162 | DocProject/Help/html
163 |
164 | # Click-Once directory
165 | publish/
166 |
167 | # Publish Web Output
168 | *.[Pp]ublish.xml
169 | *.azurePubxml
170 | # Note: Comment the next line if you want to checkin your web deploy settings,
171 | # but database connection strings (with potential passwords) will be unencrypted
172 | *.pubxml
173 | *.publishproj
174 |
175 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
176 | # checkin your Azure Web App publish settings, but sensitive information contained
177 | # in these scripts will be unencrypted
178 | PublishScripts/
179 |
180 | # NuGet Packages
181 | *.nupkg
182 | # The packages folder can be ignored because of Package Restore
183 | **/[Pp]ackages/*
184 | # except build/, which is used as an MSBuild target.
185 | !**/[Pp]ackages/build/
186 | # Uncomment if necessary however generally it will be regenerated when needed
187 | #!**/[Pp]ackages/repositories.config
188 | # NuGet v3's project.json files produces more ignorable files
189 | *.nuget.props
190 | *.nuget.targets
191 |
192 | # Microsoft Azure Build Output
193 | csx/
194 | *.build.csdef
195 |
196 | # Microsoft Azure Emulator
197 | ecf/
198 | rcf/
199 |
200 | # Windows Store app package directories and files
201 | AppPackages/
202 | BundleArtifacts/
203 | Package.StoreAssociation.xml
204 | _pkginfo.txt
205 | *.appx
206 |
207 | # Visual Studio cache files
208 | # files ending in .cache can be ignored
209 | *.[Cc]ache
210 | # but keep track of directories ending in .cache
211 | !*.[Cc]ache/
212 |
213 | # Others
214 | ClientBin/
215 | ~$*
216 | *~
217 | *.dbmdl
218 | *.dbproj.schemaview
219 | *.jfm
220 | *.pfx
221 | *.publishsettings
222 | orleans.codegen.cs
223 |
224 | # Including strong name files can present a security risk
225 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
226 | #*.snk
227 |
228 | # Since there are multiple workflows, uncomment next line to ignore bower_components
229 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
230 | #bower_components/
231 |
232 | # RIA/Silverlight projects
233 | Generated_Code/
234 |
235 | # Backup & report files from converting an old project file
236 | # to a newer Visual Studio version. Backup files are not needed,
237 | # because we have git ;-)
238 | _UpgradeReport_Files/
239 | Backup*/
240 | UpgradeLog*.XML
241 | UpgradeLog*.htm
242 | ServiceFabricBackup/
243 | *.rptproj.bak
244 |
245 | # SQL Server files
246 | *.mdf
247 | *.ldf
248 | *.ndf
249 |
250 | # Business Intelligence projects
251 | *.rdl.data
252 | *.bim.layout
253 | *.bim_*.settings
254 | *.rptproj.rsuser
255 |
256 | # Microsoft Fakes
257 | FakesAssemblies/
258 |
259 | # GhostDoc plugin setting file
260 | *.GhostDoc.xml
261 |
262 | # Node.js Tools for Visual Studio
263 | .ntvs_analysis.dat
264 | node_modules/
265 |
266 | # Visual Studio 6 build log
267 | *.plg
268 |
269 | # Visual Studio 6 workspace options file
270 | *.opt
271 |
272 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
273 | *.vbw
274 |
275 | # Visual Studio LightSwitch build output
276 | **/*.HTMLClient/GeneratedArtifacts
277 | **/*.DesktopClient/GeneratedArtifacts
278 | **/*.DesktopClient/ModelManifest.xml
279 | **/*.Server/GeneratedArtifacts
280 | **/*.Server/ModelManifest.xml
281 | _Pvt_Extensions
282 |
283 | # Paket dependency manager
284 | .paket/paket.exe
285 | paket-files/
286 |
287 | # FAKE - F# Make
288 | .fake/
289 |
290 | # JetBrains Rider
291 | .idea/
292 | *.sln.iml
293 |
294 | # CodeRush
295 | .cr/
296 |
297 | # Python Tools for Visual Studio (PTVS)
298 | __pycache__/
299 | *.pyc
300 |
301 | # Cake - Uncomment if you are using it
302 | # tools/**
303 | # !tools/packages.config
304 |
305 | # Tabs Studio
306 | *.tss
307 |
308 | # Telerik's JustMock configuration file
309 | *.jmconfig
310 |
311 | # BizTalk build output
312 | *.btp.cs
313 | *.btm.cs
314 | *.odx.cs
315 | *.xsd.cs
316 |
317 | # OpenCover UI analysis results
318 | OpenCover/
319 |
320 | # Azure Stream Analytics local run output
321 | ASALocalRun/
322 |
323 | # MSBuild Binary and Structured Log
324 | *.binlog
325 |
326 | # NVidia Nsight GPU debugger configuration file
327 | *.nvuser
328 |
329 | # MFractors (Xamarin productivity tool) working folder
330 | .mfractor/
331 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2024 Max Ignatiev
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.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Switchy
2 |
3 | > [!WARNING]
4 | > At the moment, I have neither the time nor the inclination to support this program. If you have any issues with the stable version, you can try one of the preview builds in [this issue](https://github.com/erryox/Switchy/issues/14). Some bugs should be fixed in it, but there are other issues as well, which is why it’s a preview build. Feel free to fork this repo if you’d like to make any changes or improvements!
5 |
6 | Switches keyboard layout with the Caps Lock key.
7 |
8 | Just put [Switchy.exe](https://github.com/erryox/Switchy/releases/latest) in the startup folder (to open it press **Win+R** and type **shell:startup**).
9 | If you want to hide the pop-up in Windows 10/11, put in this folder a shortcut with **nopopup** parameter instead of the file itself.
10 |
11 | > Note: for keyboard layout switching to work in programs running with administrator privileges, Switchy must also be run with administrator privileges. This can be automated using Task Scheduler.
12 |
13 | Usage:
14 | * **CapsLock** to change keyboard layout
15 | * **Shift+CapsLock** to toggle CapsLock state
16 | * **Alt+CapsLock** to enable/disable Switchy
17 |
--------------------------------------------------------------------------------
/Switchy.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.29306.81
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Switchy", "Switchy\Switchy.vcxproj", "{16A46215-C3FC-4F84-966D-22B97CADE8C0}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {16A46215-C3FC-4F84-966D-22B97CADE8C0}.Debug|x64.ActiveCfg = Debug|x64
17 | {16A46215-C3FC-4F84-966D-22B97CADE8C0}.Debug|x64.Build.0 = Debug|x64
18 | {16A46215-C3FC-4F84-966D-22B97CADE8C0}.Debug|x86.ActiveCfg = Debug|Win32
19 | {16A46215-C3FC-4F84-966D-22B97CADE8C0}.Debug|x86.Build.0 = Debug|Win32
20 | {16A46215-C3FC-4F84-966D-22B97CADE8C0}.Release|x64.ActiveCfg = Release|x64
21 | {16A46215-C3FC-4F84-966D-22B97CADE8C0}.Release|x64.Build.0 = Release|x64
22 | {16A46215-C3FC-4F84-966D-22B97CADE8C0}.Release|x86.ActiveCfg = Release|Win32
23 | {16A46215-C3FC-4F84-966D-22B97CADE8C0}.Release|x86.Build.0 = Release|Win32
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {3A751753-9F42-4929-A0D8-8B9011CE60FB}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/Switchy/Switchy.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 | Debug
14 | x64
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 | 16.0
23 | {16A46215-C3FC-4F84-966D-22B97CADE8C0}
24 | Switchy
25 | 10.0
26 |
27 |
28 |
29 | Application
30 | true
31 | v143
32 | MultiByte
33 |
34 |
35 | Application
36 | false
37 | v143
38 | true
39 | MultiByte
40 |
41 |
42 | Application
43 | true
44 | v143
45 | MultiByte
46 |
47 |
48 | Application
49 | false
50 | v143
51 | true
52 | MultiByte
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 | Level3
76 | Disabled
77 | true
78 | true
79 |
80 |
81 |
82 |
83 | Console
84 |
85 |
86 |
87 |
88 | Level3
89 | Disabled
90 | true
91 | true
92 | %(AdditionalIncludeDirectories)
93 |
94 |
95 | Console
96 |
97 |
98 |
99 |
100 | Level3
101 | MaxSpeed
102 | true
103 | true
104 | true
105 | true
106 |
107 |
108 |
109 |
110 | Windows
111 | true
112 | true
113 | mainCRTStartup
114 |
115 |
116 |
117 |
118 | Level3
119 | MaxSpeed
120 | true
121 | true
122 | true
123 | true
124 |
125 |
126 |
127 |
128 | Windows
129 | true
130 | true
131 | mainCRTStartup
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
--------------------------------------------------------------------------------
/Switchy/Switchy.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 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
10 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
11 |
12 |
13 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
14 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Switchy/main.c:
--------------------------------------------------------------------------------
1 | #include
2 | #if _DEBUG
3 | #include
4 | #endif // _DEBUG
5 |
6 | typedef NTSTATUS(WINAPI* RtlGetVersionPtr)(PRTL_OSVERSIONINFOW);
7 |
8 | typedef struct {
9 | BOOL popup;
10 | } Settings;
11 |
12 | void ShowError(LPCSTR message);
13 | DWORD GetOSVersion();
14 | void PressKey(int keyCode);
15 | void ReleaseKey(int keyCode);
16 | void ToggleCapsLockState();
17 | LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam);
18 |
19 |
20 | HHOOK hHook;
21 | BOOL enabled = TRUE;
22 | BOOL keystrokeCapsProcessed = FALSE;
23 | BOOL keystrokeShiftProcessed = FALSE;
24 | BOOL winPressed = FALSE;
25 |
26 | Settings settings = {
27 | .popup = FALSE
28 | };
29 |
30 |
31 | int main(int argc, char** argv)
32 | {
33 | if (argc > 1 && strcmp(argv[1], "nopopup") == 0)
34 | {
35 | settings.popup = FALSE;
36 | }
37 | else
38 | {
39 | settings.popup = GetOSVersion() >= 10;
40 | }
41 | #if _DEBUG
42 | printf("Pop-up is %s\n", settings.popup ? "enabled" : "disabled");
43 | #endif
44 |
45 | HANDLE hMutex = CreateMutex(0, 0, "Switchy");
46 | if (GetLastError() == ERROR_ALREADY_EXISTS)
47 | {
48 | ShowError("Another instance of Switchy is already running!");
49 | return 1;
50 | }
51 |
52 | hHook = SetWindowsHookEx(WH_KEYBOARD_LL, LowLevelKeyboardProc, 0, 0);
53 | if (hHook == NULL)
54 | {
55 | ShowError("Error calling \"SetWindowsHookEx(...)\"");
56 | return 1;
57 | }
58 |
59 | MSG messages;
60 | while (GetMessage(&messages, NULL, 0, 0))
61 | {
62 | TranslateMessage(&messages);
63 | DispatchMessage(&messages);
64 | }
65 |
66 | UnhookWindowsHookEx(hHook);
67 |
68 | return 0;
69 | }
70 |
71 |
72 | void ShowError(LPCSTR message)
73 | {
74 | MessageBox(NULL, message, "Error", MB_OK | MB_ICONERROR);
75 | }
76 |
77 |
78 | DWORD GetOSVersion()
79 | {
80 | HMODULE hMod = GetModuleHandleW(L"ntdll.dll");
81 | RTL_OSVERSIONINFOW osvi = { 0 };
82 |
83 | if (hMod)
84 | {
85 | RtlGetVersionPtr p = (RtlGetVersionPtr)GetProcAddress(hMod, "RtlGetVersion");
86 |
87 | if (p)
88 | {
89 | osvi.dwOSVersionInfoSize = sizeof(osvi);
90 | p(&osvi);
91 | }
92 | }
93 |
94 | return osvi.dwMajorVersion;
95 | }
96 |
97 |
98 | void PressKey(int keyCode)
99 | {
100 | keybd_event(keyCode, 0, 0, 0);
101 | }
102 |
103 |
104 | void ReleaseKey(int keyCode)
105 | {
106 | keybd_event(keyCode, 0, KEYEVENTF_KEYUP, 0);
107 | }
108 |
109 |
110 | void ToggleCapsLockState()
111 | {
112 | PressKey(VK_CAPITAL);
113 | ReleaseKey(VK_CAPITAL);
114 | #if _DEBUG
115 | printf("Caps Lock state has been toggled\n");
116 | #endif // _DEBUG
117 | }
118 |
119 |
120 | LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
121 | {
122 | KBDLLHOOKSTRUCT* key = (KBDLLHOOKSTRUCT*)lParam;
123 | if (nCode == HC_ACTION && !(key->flags & LLKHF_INJECTED))
124 | {
125 | #if _DEBUG
126 | const char* keyStatus = (wParam == WM_KEYDOWN || wParam == WM_SYSKEYDOWN) ? "pressed" : "released";
127 | printf("Key %d has been %s\n", key->vkCode, keyStatus);
128 | #endif // _DEBUG
129 | if (key->vkCode == VK_CAPITAL)
130 | {
131 | if (wParam == WM_SYSKEYDOWN && !keystrokeCapsProcessed)
132 | {
133 | keystrokeCapsProcessed = TRUE;
134 | enabled = !enabled;
135 | #if _DEBUG
136 | printf("Switchy has been %s\n", enabled ? "enabled" : "disabled");
137 | #endif // _DEBUG
138 | return 1;
139 | }
140 |
141 | if (wParam == WM_KEYUP || wParam == WM_SYSKEYUP)
142 | {
143 | keystrokeCapsProcessed = FALSE;
144 |
145 | if (winPressed)
146 | {
147 | winPressed = FALSE;
148 | ReleaseKey(VK_LWIN);
149 | }
150 |
151 | if (enabled && !settings.popup)
152 | {
153 | if (!keystrokeShiftProcessed)
154 | {
155 | PressKey(VK_MENU);
156 | PressKey(VK_LSHIFT);
157 | ReleaseKey(VK_MENU);
158 | ReleaseKey(VK_LSHIFT);
159 | }
160 | else
161 | {
162 | keystrokeShiftProcessed = FALSE;
163 | }
164 | }
165 | }
166 |
167 | if (!enabled)
168 | {
169 | return CallNextHookEx(hHook, nCode, wParam, lParam);
170 | }
171 |
172 | if (wParam == WM_KEYDOWN && !keystrokeCapsProcessed)
173 | {
174 | keystrokeCapsProcessed = TRUE;
175 |
176 | if (keystrokeShiftProcessed == TRUE)
177 | {
178 | ToggleCapsLockState();
179 | return 1;
180 | }
181 | else
182 | {
183 | if (settings.popup)
184 | {
185 | PressKey(VK_LWIN);
186 | PressKey(VK_SPACE);
187 | ReleaseKey(VK_SPACE);
188 | winPressed = TRUE;
189 | }
190 | }
191 | }
192 | return 1;
193 | }
194 |
195 | else if (key->vkCode == VK_LSHIFT)
196 | {
197 |
198 | if ((wParam == WM_KEYUP || wParam == WM_SYSKEYUP) && !keystrokeCapsProcessed)
199 | {
200 | keystrokeShiftProcessed = FALSE;
201 | }
202 |
203 | if (!enabled)
204 | {
205 | return CallNextHookEx(hHook, nCode, wParam, lParam);
206 | }
207 |
208 | if (wParam == WM_KEYDOWN && !keystrokeShiftProcessed)
209 | {
210 | keystrokeShiftProcessed = TRUE;
211 |
212 | if (keystrokeCapsProcessed == TRUE)
213 | {
214 | ToggleCapsLockState();
215 | if (settings.popup)
216 | {
217 | PressKey(VK_LWIN);
218 | PressKey(VK_SPACE);
219 | ReleaseKey(VK_SPACE);
220 | winPressed = TRUE;
221 | }
222 |
223 | return 0;
224 | }
225 | }
226 | return 0;
227 | }
228 | }
229 |
230 | return CallNextHookEx(hHook, nCode, wParam, lParam);
231 | }
232 |
--------------------------------------------------------------------------------