├── .github
└── dependabot.yml
├── .gitignore
├── Assets
├── Logo.afdesign
├── Logo.png
├── after.gif
├── before.gif
└── multilang.gif
├── IMEIndicator.sln
├── IMEIndicator
├── AssemblyInfo.cs
├── Events.cs
├── IMEIndicator.csproj
├── KeyboardHook.cs
├── Program.cs
├── ProgramHelpers.cs
├── Resources.Designer.cs
├── Resources.resx
├── Resources
│ ├── Logo.ico
│ └── iosevka-fixed-regular-capital.ttf
├── UpdateChecker.cs
└── WinAPI.cs
├── LICENSE
└── README.md
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: "nuget"
4 | directory: "/"
5 | schedule:
6 | interval: "daily"
7 | reviewers:
8 | - "Icecovery"
--------------------------------------------------------------------------------
/.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 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Mono auto generated files
17 | mono_crash.*
18 |
19 | # Build results
20 | [Dd]ebug/
21 | [Dd]ebugPublic/
22 | [Rr]elease/
23 | [Rr]eleases/
24 | x64/
25 | x86/
26 | [Aa][Rr][Mm]/
27 | [Aa][Rr][Mm]64/
28 | bld/
29 | [Bb]in/
30 | [Oo]bj/
31 | [Ll]og/
32 | [Ll]ogs/
33 |
34 | # Visual Studio 2015/2017 cache/options directory
35 | .vs/
36 | # Uncomment if you have tasks that create the project's static files in wwwroot
37 | #wwwroot/
38 |
39 | # Visual Studio 2017 auto generated files
40 | Generated\ Files/
41 |
42 | # MSTest test Results
43 | [Tt]est[Rr]esult*/
44 | [Bb]uild[Ll]og.*
45 |
46 | # NUnit
47 | *.VisualState.xml
48 | TestResult.xml
49 | nunit-*.xml
50 |
51 | # Build Results of an ATL Project
52 | [Dd]ebugPS/
53 | [Rr]eleasePS/
54 | dlldata.c
55 |
56 | # Benchmark Results
57 | BenchmarkDotNet.Artifacts/
58 |
59 | # .NET Core
60 | project.lock.json
61 | project.fragment.lock.json
62 | artifacts/
63 |
64 | # StyleCop
65 | StyleCopReport.xml
66 |
67 | # Files built by Visual Studio
68 | *_i.c
69 | *_p.c
70 | *_h.h
71 | *.ilk
72 | *.meta
73 | *.obj
74 | *.iobj
75 | *.pch
76 | *.pdb
77 | *.ipdb
78 | *.pgc
79 | *.pgd
80 | *.rsp
81 | *.sbr
82 | *.tlb
83 | *.tli
84 | *.tlh
85 | *.tmp
86 | *.tmp_proj
87 | *_wpftmp.csproj
88 | *.log
89 | *.vspscc
90 | *.vssscc
91 | .builds
92 | *.pidb
93 | *.svclog
94 | *.scc
95 |
96 | # Chutzpah Test files
97 | _Chutzpah*
98 |
99 | # Visual C++ cache files
100 | ipch/
101 | *.aps
102 | *.ncb
103 | *.opendb
104 | *.opensdf
105 | *.sdf
106 | *.cachefile
107 | *.VC.db
108 | *.VC.VC.opendb
109 |
110 | # Visual Studio profiler
111 | *.psess
112 | *.vsp
113 | *.vspx
114 | *.sap
115 |
116 | # Visual Studio Trace Files
117 | *.e2e
118 |
119 | # TFS 2012 Local Workspace
120 | $tf/
121 |
122 | # Guidance Automation Toolkit
123 | *.gpState
124 |
125 | # ReSharper is a .NET coding add-in
126 | _ReSharper*/
127 | *.[Rr]e[Ss]harper
128 | *.DotSettings.user
129 |
130 | # TeamCity is a build add-in
131 | _TeamCity*
132 |
133 | # DotCover is a Code Coverage Tool
134 | *.dotCover
135 |
136 | # AxoCover is a Code Coverage Tool
137 | .axoCover/*
138 | !.axoCover/settings.json
139 |
140 | # Visual Studio code coverage results
141 | *.coverage
142 | *.coveragexml
143 |
144 | # NCrunch
145 | _NCrunch_*
146 | .*crunch*.local.xml
147 | nCrunchTemp_*
148 |
149 | # MightyMoose
150 | *.mm.*
151 | AutoTest.Net/
152 |
153 | # Web workbench (sass)
154 | .sass-cache/
155 |
156 | # Installshield output folder
157 | [Ee]xpress/
158 |
159 | # DocProject is a documentation generator add-in
160 | DocProject/buildhelp/
161 | DocProject/Help/*.HxT
162 | DocProject/Help/*.HxC
163 | DocProject/Help/*.hhc
164 | DocProject/Help/*.hhk
165 | DocProject/Help/*.hhp
166 | DocProject/Help/Html2
167 | DocProject/Help/html
168 |
169 | # Click-Once directory
170 | publish/
171 |
172 | # Publish Web Output
173 | *.[Pp]ublish.xml
174 | *.azurePubxml
175 | # Note: Comment the next line if you want to checkin your web deploy settings,
176 | # but database connection strings (with potential passwords) will be unencrypted
177 | *.pubxml
178 | *.publishproj
179 |
180 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
181 | # checkin your Azure Web App publish settings, but sensitive information contained
182 | # in these scripts will be unencrypted
183 | PublishScripts/
184 |
185 | # NuGet Packages
186 | *.nupkg
187 | # NuGet Symbol Packages
188 | *.snupkg
189 | # The packages folder can be ignored because of Package Restore
190 | **/[Pp]ackages/*
191 | # except build/, which is used as an MSBuild target.
192 | !**/[Pp]ackages/build/
193 | # Uncomment if necessary however generally it will be regenerated when needed
194 | #!**/[Pp]ackages/repositories.config
195 | # NuGet v3's project.json files produces more ignorable files
196 | *.nuget.props
197 | *.nuget.targets
198 |
199 | # Microsoft Azure Build Output
200 | csx/
201 | *.build.csdef
202 |
203 | # Microsoft Azure Emulator
204 | ecf/
205 | rcf/
206 |
207 | # Windows Store app package directories and files
208 | AppPackages/
209 | BundleArtifacts/
210 | Package.StoreAssociation.xml
211 | _pkginfo.txt
212 | *.appx
213 | *.appxbundle
214 | *.appxupload
215 |
216 | # Visual Studio cache files
217 | # files ending in .cache can be ignored
218 | *.[Cc]ache
219 | # but keep track of directories ending in .cache
220 | !?*.[Cc]ache/
221 |
222 | # Others
223 | ClientBin/
224 | ~$*
225 | *~
226 | *.dbmdl
227 | *.dbproj.schemaview
228 | *.jfm
229 | *.pfx
230 | *.publishsettings
231 | orleans.codegen.cs
232 |
233 | # Including strong name files can present a security risk
234 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
235 | #*.snk
236 |
237 | # Since there are multiple workflows, uncomment next line to ignore bower_components
238 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
239 | #bower_components/
240 |
241 | # RIA/Silverlight projects
242 | Generated_Code/
243 |
244 | # Backup & report files from converting an old project file
245 | # to a newer Visual Studio version. Backup files are not needed,
246 | # because we have git ;-)
247 | _UpgradeReport_Files/
248 | Backup*/
249 | UpgradeLog*.XML
250 | UpgradeLog*.htm
251 | ServiceFabricBackup/
252 | *.rptproj.bak
253 |
254 | # SQL Server files
255 | *.mdf
256 | *.ldf
257 | *.ndf
258 |
259 | # Business Intelligence projects
260 | *.rdl.data
261 | *.bim.layout
262 | *.bim_*.settings
263 | *.rptproj.rsuser
264 | *- [Bb]ackup.rdl
265 | *- [Bb]ackup ([0-9]).rdl
266 | *- [Bb]ackup ([0-9][0-9]).rdl
267 |
268 | # Microsoft Fakes
269 | FakesAssemblies/
270 |
271 | # GhostDoc plugin setting file
272 | *.GhostDoc.xml
273 |
274 | # Node.js Tools for Visual Studio
275 | .ntvs_analysis.dat
276 | node_modules/
277 |
278 | # Visual Studio 6 build log
279 | *.plg
280 |
281 | # Visual Studio 6 workspace options file
282 | *.opt
283 |
284 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
285 | *.vbw
286 |
287 | # Visual Studio LightSwitch build output
288 | **/*.HTMLClient/GeneratedArtifacts
289 | **/*.DesktopClient/GeneratedArtifacts
290 | **/*.DesktopClient/ModelManifest.xml
291 | **/*.Server/GeneratedArtifacts
292 | **/*.Server/ModelManifest.xml
293 | _Pvt_Extensions
294 |
295 | # Paket dependency manager
296 | .paket/paket.exe
297 | paket-files/
298 |
299 | # FAKE - F# Make
300 | .fake/
301 |
302 | # CodeRush personal settings
303 | .cr/personal
304 |
305 | # Python Tools for Visual Studio (PTVS)
306 | __pycache__/
307 | *.pyc
308 |
309 | # Cake - Uncomment if you are using it
310 | # tools/**
311 | # !tools/packages.config
312 |
313 | # Tabs Studio
314 | *.tss
315 |
316 | # Telerik's JustMock configuration file
317 | *.jmconfig
318 |
319 | # BizTalk build output
320 | *.btp.cs
321 | *.btm.cs
322 | *.odx.cs
323 | *.xsd.cs
324 |
325 | # OpenCover UI analysis results
326 | OpenCover/
327 |
328 | # Azure Stream Analytics local run output
329 | ASALocalRun/
330 |
331 | # MSBuild Binary and Structured Log
332 | *.binlog
333 |
334 | # NVidia Nsight GPU debugger configuration file
335 | *.nvuser
336 |
337 | # MFractors (Xamarin productivity tool) working folder
338 | .mfractor/
339 |
340 | # Local History for Visual Studio
341 | .localhistory/
342 |
343 | # BeatPulse healthcheck temp database
344 | healthchecksdb
345 |
346 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
347 | MigrationBackup/
348 |
349 | # Ionide (cross platform F# VS Code tools) working folder
350 | .ionide/
351 |
--------------------------------------------------------------------------------
/Assets/Logo.afdesign:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Icecovery/IMEIndicator/43c01b7defa10950661a610bb775cac8af44fe5a/Assets/Logo.afdesign
--------------------------------------------------------------------------------
/Assets/Logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Icecovery/IMEIndicator/43c01b7defa10950661a610bb775cac8af44fe5a/Assets/Logo.png
--------------------------------------------------------------------------------
/Assets/after.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Icecovery/IMEIndicator/43c01b7defa10950661a610bb775cac8af44fe5a/Assets/after.gif
--------------------------------------------------------------------------------
/Assets/before.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Icecovery/IMEIndicator/43c01b7defa10950661a610bb775cac8af44fe5a/Assets/before.gif
--------------------------------------------------------------------------------
/Assets/multilang.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Icecovery/IMEIndicator/43c01b7defa10950661a610bb775cac8af44fe5a/Assets/multilang.gif
--------------------------------------------------------------------------------
/IMEIndicator.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.0.32014.148
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IMEIndicator", "IMEIndicator\IMEIndicator.csproj", "{3FBC95C7-EEB7-42D3-AC32-191899C49602}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {3FBC95C7-EEB7-42D3-AC32-191899C49602}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {3FBC95C7-EEB7-42D3-AC32-191899C49602}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {3FBC95C7-EEB7-42D3-AC32-191899C49602}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {3FBC95C7-EEB7-42D3-AC32-191899C49602}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {B1BC6F5D-FE6A-4378-9B31-28E1CEF69B02}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/IMEIndicator/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 |
3 | // In SDK-style projects such as this one, several assembly attributes that were historically
4 | // defined in this file are now automatically added during build and populated with
5 | // values defined in project properties. For details of which attributes are included
6 | // and how to customise this process see: https://aka.ms/assembly-info-properties
7 |
8 |
9 | // Setting ComVisible to false makes the types in this assembly not visible to COM
10 | // components. If you need to access a type in this assembly from COM, set the ComVisible
11 | // attribute to true on that type.
12 |
13 | [assembly: ComVisible(false)]
14 |
15 | // The following GUID is for the ID of the typelib if this project is exposed to COM.
16 |
17 | [assembly: Guid("2f97f34a-598a-4854-97dd-37d2fc13598b")]
18 |
--------------------------------------------------------------------------------
/IMEIndicator/Events.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using System.Threading.Tasks;
4 | using System.Windows.Forms;
5 |
6 | namespace IMEIndicator
7 | {
8 | public partial class Program
9 | {
10 | ///
11 | /// Global keyboard key up event
12 | ///
13 | ///
14 | private static async void KeyboardHook_KeyUp(KeyboardHook.VKeys key)
15 | {
16 | // detect key up for any win button so hold win and tap space will be supported
17 | if (key == KeyboardHook.VKeys.LWIN || key == KeyboardHook.VKeys.RWIN)
18 | {
19 | // delay a small time so Windows has time to react
20 | await Task.Delay(10).ContinueWith(t => UpdateIcon());
21 | }
22 | }
23 |
24 | ///
25 | /// Clean up code when exiting the application
26 | ///
27 | ///
28 | ///
29 | private static void CurrentDomain_ProcessExit(object? sender, EventArgs e)
30 | {
31 | notifyIcon.Dispose();
32 | keyboardHook.Uninstall();
33 | }
34 |
35 | ///
36 | /// Event when click notify icon
37 | ///
38 | ///
39 | ///
40 | private static void NotifyIcon_MouseClick(object? sender, MouseEventArgs e)
41 | {
42 | switch (e.Button)
43 | {
44 | case MouseButtons.Middle:
45 | Environment.Exit(0);
46 | break;
47 | }
48 | }
49 |
50 | ///
51 | /// Event when drop down setting button clicked
52 | ///
53 | ///
54 | ///
55 | private static void MenuItemSetting_Click(object? sender, EventArgs e)
56 | {
57 | ProgramHelpers.LaunchWindowSettingApp("ms-settings:keyboard");
58 | }
59 |
60 | ///
61 | /// Event when drop down open startup folder button clicked
62 | ///
63 | ///
64 | ///
65 | private static void MenuItemStartupFolder_Click(object? sender, EventArgs e)
66 | {
67 | Process.Start("explorer.exe", "shell:startup");
68 | }
69 |
70 | ///
71 | /// Event when drop down quit button clicked
72 | ///
73 | ///
74 | ///
75 | private static void MenuItemExit_Click(object? sender, EventArgs e)
76 | {
77 | Environment.Exit(0);
78 | }
79 |
80 | ///
81 | /// Event when update status text is clicked (when new update is available)
82 | ///
83 | ///
84 | ///
85 | private static void MenuItemUpdateStatus_Click(object? sender, EventArgs e)
86 | {
87 | Process.Start("explorer", UpdateChecker.GitHubReleaseAddress);
88 | }
89 |
90 | ///
91 | /// Event when check update button is clicked
92 | ///
93 | ///
94 | ///
95 | private static void MenuItemCheckUpdate_Click(object? sender, EventArgs e)
96 | {
97 | CheckUpdate();
98 | }
99 |
100 | ///
101 | /// Event when foreground window changes
102 | ///
103 | ///
104 | ///
105 | ///
106 | ///
107 | ///
108 | ///
109 | ///
110 | public static void WinEventProc(IntPtr hWinEventHook, uint eventType, IntPtr hwnd, int idObject, int idChild, uint dwEventThread, uint dwmsEventTime)
111 | {
112 | // https://stackoverflow.com/a/10280800
113 | UpdateIcon();
114 | }
115 | }
116 | }
117 |
--------------------------------------------------------------------------------
/IMEIndicator/IMEIndicator.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | WinExe
5 | net6.0-windows
6 | true
7 | false
8 | enable
9 | README.md
10 | MIT License
11 | https://github.com/Icecovery/IMEIndicator
12 | Resources\Logo.ico
13 | True
14 | 0.2
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 | True
32 | \
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 | True
43 | True
44 | Resources.resx
45 |
46 |
47 |
48 |
49 |
50 | ResXFileCodeGenerator
51 | Resources.Designer.cs
52 |
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/IMEIndicator/KeyboardHook.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.InteropServices;
3 | using System.Diagnostics;
4 |
5 | namespace IMEIndicator
6 | {
7 | // https://github.com/rvknth043/Global-Low-Level-Key-Board-And-Mouse-Hook
8 |
9 | ///
10 | /// Class for intercepting low level keyboard hooks
11 | ///
12 | public class KeyboardHook
13 | {
14 | ///
15 | /// Virtual Keys
16 | ///
17 | public enum VKeys
18 | {
19 | // Losely based on http://www.pinvoke.net/default.aspx/Enums/VK.html
20 |
21 | LBUTTON = 0x01, // Left mouse button
22 | RBUTTON = 0x02, // Right mouse button
23 | CANCEL = 0x03, // Control-break processing
24 | MBUTTON = 0x04, // Middle mouse button (three-button mouse)
25 | XBUTTON1 = 0x05, // Windows 2000/XP: X1 mouse button
26 | XBUTTON2 = 0x06, // Windows 2000/XP: X2 mouse button
27 | // 0x07 // Undefined
28 | BACK = 0x08, // BACKSPACE key
29 | TAB = 0x09, // TAB key
30 | // 0x0A-0x0B, // Reserved
31 | CLEAR = 0x0C, // CLEAR key
32 | RETURN = 0x0D, // ENTER key
33 | // 0x0E-0x0F, // Undefined
34 | SHIFT = 0x10, // SHIFT key
35 | CONTROL = 0x11, // CTRL key
36 | MENU = 0x12, // ALT key
37 | PAUSE = 0x13, // PAUSE key
38 | CAPITAL = 0x14, // CAPS LOCK key
39 | KANA = 0x15, // Input Method Editor (IME) Kana mode
40 | HANGUL = 0x15, // IME Hangul mode
41 | // 0x16, // Undefined
42 | JUNJA = 0x17, // IME Junja mode
43 | FINAL = 0x18, // IME final mode
44 | HANJA = 0x19, // IME Hanja mode
45 | KANJI = 0x19, // IME Kanji mode
46 | // 0x1A, // Undefined
47 | ESCAPE = 0x1B, // ESC key
48 | CONVERT = 0x1C, // IME convert
49 | NONCONVERT = 0x1D, // IME nonconvert
50 | ACCEPT = 0x1E, // IME accept
51 | MODECHANGE = 0x1F, // IME mode change request
52 | SPACE = 0x20, // SPACEBAR
53 | PRIOR = 0x21, // PAGE UP key
54 | NEXT = 0x22, // PAGE DOWN key
55 | END = 0x23, // END key
56 | HOME = 0x24, // HOME key
57 | LEFT = 0x25, // LEFT ARROW key
58 | UP = 0x26, // UP ARROW key
59 | RIGHT = 0x27, // RIGHT ARROW key
60 | DOWN = 0x28, // DOWN ARROW key
61 | SELECT = 0x29, // SELECT key
62 | PRINT = 0x2A, // PRINT key
63 | EXECUTE = 0x2B, // EXECUTE key
64 | SNAPSHOT = 0x2C, // PRINT SCREEN key
65 | INSERT = 0x2D, // INS key
66 | DELETE = 0x2E, // DEL key
67 | HELP = 0x2F, // HELP key
68 | KEY_0 = 0x30, // 0 key
69 | KEY_1 = 0x31, // 1 key
70 | KEY_2 = 0x32, // 2 key
71 | KEY_3 = 0x33, // 3 key
72 | KEY_4 = 0x34, // 4 key
73 | KEY_5 = 0x35, // 5 key
74 | KEY_6 = 0x36, // 6 key
75 | KEY_7 = 0x37, // 7 key
76 | KEY_8 = 0x38, // 8 key
77 | KEY_9 = 0x39, // 9 key
78 | // 0x3A-0x40, // Undefined
79 | KEY_A = 0x41, // A key
80 | KEY_B = 0x42, // B key
81 | KEY_C = 0x43, // C key
82 | KEY_D = 0x44, // D key
83 | KEY_E = 0x45, // E key
84 | KEY_F = 0x46, // F key
85 | KEY_G = 0x47, // G key
86 | KEY_H = 0x48, // H key
87 | KEY_I = 0x49, // I key
88 | KEY_J = 0x4A, // J key
89 | KEY_K = 0x4B, // K key
90 | KEY_L = 0x4C, // L key
91 | KEY_M = 0x4D, // M key
92 | KEY_N = 0x4E, // N key
93 | KEY_O = 0x4F, // O key
94 | KEY_P = 0x50, // P key
95 | KEY_Q = 0x51, // Q key
96 | KEY_R = 0x52, // R key
97 | KEY_S = 0x53, // S key
98 | KEY_T = 0x54, // T key
99 | KEY_U = 0x55, // U key
100 | KEY_V = 0x56, // V key
101 | KEY_W = 0x57, // W key
102 | KEY_X = 0x58, // X key
103 | KEY_Y = 0x59, // Y key
104 | KEY_Z = 0x5A, // Z key
105 | LWIN = 0x5B, // Left Windows key (Microsoft Natural keyboard)
106 | RWIN = 0x5C, // Right Windows key (Natural keyboard)
107 | APPS = 0x5D, // Applications key (Natural keyboard)
108 | // 0x5E, // Reserved
109 | SLEEP = 0x5F, // Computer Sleep key
110 | NUMPAD0 = 0x60, // Numeric keypad 0 key
111 | NUMPAD1 = 0x61, // Numeric keypad 1 key
112 | NUMPAD2 = 0x62, // Numeric keypad 2 key
113 | NUMPAD3 = 0x63, // Numeric keypad 3 key
114 | NUMPAD4 = 0x64, // Numeric keypad 4 key
115 | NUMPAD5 = 0x65, // Numeric keypad 5 key
116 | NUMPAD6 = 0x66, // Numeric keypad 6 key
117 | NUMPAD7 = 0x67, // Numeric keypad 7 key
118 | NUMPAD8 = 0x68, // Numeric keypad 8 key
119 | NUMPAD9 = 0x69, // Numeric keypad 9 key
120 | MULTIPLY = 0x6A, // Multiply key
121 | ADD = 0x6B, // Add key
122 | SEPARATOR = 0x6C, // Separator key
123 | SUBTRACT = 0x6D, // Subtract key
124 | DECIMAL = 0x6E, // Decimal key
125 | DIVIDE = 0x6F, // Divide key
126 | F1 = 0x70, // F1 key
127 | F2 = 0x71, // F2 key
128 | F3 = 0x72, // F3 key
129 | F4 = 0x73, // F4 key
130 | F5 = 0x74, // F5 key
131 | F6 = 0x75, // F6 key
132 | F7 = 0x76, // F7 key
133 | F8 = 0x77, // F8 key
134 | F9 = 0x78, // F9 key
135 | F10 = 0x79, // F10 key
136 | F11 = 0x7A, // F11 key
137 | F12 = 0x7B, // F12 key
138 | F13 = 0x7C, // F13 key
139 | F14 = 0x7D, // F14 key
140 | F15 = 0x7E, // F15 key
141 | F16 = 0x7F, // F16 key
142 | F17 = 0x80, // F17 key
143 | F18 = 0x81, // F18 key
144 | F19 = 0x82, // F19 key
145 | F20 = 0x83, // F20 key
146 | F21 = 0x84, // F21 key
147 | F22 = 0x85, // F22 key, (PPC only) Key used to lock device.
148 | F23 = 0x86, // F23 key
149 | F24 = 0x87, // F24 key
150 | // 0x88-0X8F, // Unassigned
151 | NUMLOCK = 0x90, // NUM LOCK key
152 | SCROLL = 0x91, // SCROLL LOCK key
153 | // 0x92-0x96, // OEM specific
154 | // 0x97-0x9F, // Unassigned
155 | LSHIFT = 0xA0, // Left SHIFT key
156 | RSHIFT = 0xA1, // Right SHIFT key
157 | LCONTROL = 0xA2, // Left CONTROL key
158 | RCONTROL = 0xA3, // Right CONTROL key
159 | LMENU = 0xA4, // Left MENU key
160 | RMENU = 0xA5, // Right MENU key
161 | BROWSER_BACK = 0xA6, // Windows 2000/XP: Browser Back key
162 | BROWSER_FORWARD = 0xA7, // Windows 2000/XP: Browser Forward key
163 | BROWSER_REFRESH = 0xA8, // Windows 2000/XP: Browser Refresh key
164 | BROWSER_STOP = 0xA9, // Windows 2000/XP: Browser Stop key
165 | BROWSER_SEARCH = 0xAA, // Windows 2000/XP: Browser Search key
166 | BROWSER_FAVORITES = 0xAB, // Windows 2000/XP: Browser Favorites key
167 | BROWSER_HOME = 0xAC, // Windows 2000/XP: Browser Start and Home key
168 | VOLUME_MUTE = 0xAD, // Windows 2000/XP: Volume Mute key
169 | VOLUME_DOWN = 0xAE, // Windows 2000/XP: Volume Down key
170 | VOLUME_UP = 0xAF, // Windows 2000/XP: Volume Up key
171 | MEDIA_NEXT_TRACK = 0xB0,// Windows 2000/XP: Next Track key
172 | MEDIA_PREV_TRACK = 0xB1,// Windows 2000/XP: Previous Track key
173 | MEDIA_STOP = 0xB2, // Windows 2000/XP: Stop Media key
174 | MEDIA_PLAY_PAUSE = 0xB3,// Windows 2000/XP: Play/Pause Media key
175 | LAUNCH_MAIL = 0xB4, // Windows 2000/XP: Start Mail key
176 | LAUNCH_MEDIA_SELECT = 0xB5, // Windows 2000/XP: Select Media key
177 | LAUNCH_APP1 = 0xB6, // Windows 2000/XP: Start Application 1 key
178 | LAUNCH_APP2 = 0xB7, // Windows 2000/XP: Start Application 2 key
179 | // 0xB8-0xB9, // Reserved
180 | OEM_1 = 0xBA, // Used for miscellaneous characters; it can vary by keyboard.
181 | // Windows 2000/XP: For the US standard keyboard, the ';:' key
182 | OEM_PLUS = 0xBB, // Windows 2000/XP: For any country/region, the '+' key
183 | OEM_COMMA = 0xBC, // Windows 2000/XP: For any country/region, the ',' key
184 | OEM_MINUS = 0xBD, // Windows 2000/XP: For any country/region, the '-' key
185 | OEM_PERIOD = 0xBE, // Windows 2000/XP: For any country/region, the '.' key
186 | OEM_2 = 0xBF, // Used for miscellaneous characters; it can vary by keyboard.
187 | // Windows 2000/XP: For the US standard keyboard, the '/?' key
188 | OEM_3 = 0xC0, // Used for miscellaneous characters; it can vary by keyboard.
189 | // Windows 2000/XP: For the US standard keyboard, the '`~' key
190 | // 0xC1-0xD7, // Reserved
191 | // 0xD8-0xDA, // Unassigned
192 | OEM_4 = 0xDB, // Used for miscellaneous characters; it can vary by keyboard.
193 | // Windows 2000/XP: For the US standard keyboard, the '[{' key
194 | OEM_5 = 0xDC, // Used for miscellaneous characters; it can vary by keyboard.
195 | // Windows 2000/XP: For the US standard keyboard, the '\|' key
196 | OEM_6 = 0xDD, // Used for miscellaneous characters; it can vary by keyboard.
197 | // Windows 2000/XP: For the US standard keyboard, the ']}' key
198 | OEM_7 = 0xDE, // Used for miscellaneous characters; it can vary by keyboard.
199 | // Windows 2000/XP: For the US standard keyboard, the 'single-quote/double-quote' key
200 | OEM_8 = 0xDF, // Used for miscellaneous characters; it can vary by keyboard.
201 | // 0xE0, // Reserved
202 | // 0xE1, // OEM specific
203 | OEM_102 = 0xE2, // Windows 2000/XP: Either the angle bracket key or the backslash key on the RT 102-key keyboard
204 | // 0xE3-E4, // OEM specific
205 | PROCESSKEY = 0xE5, // Windows 95/98/Me, Windows NT 4.0, Windows 2000/XP: IME PROCESS key
206 | // 0xE6, // OEM specific
207 | PACKET = 0xE7, // Windows 2000/XP: Used to pass Unicode characters as if they were keystrokes. The VK_PACKET key is the low word of a 32-bit Virtual Key value used for non-keyboard input methods. For more information, see Remark in KEYBDINPUT, SendInput, WM_KEYDOWN, and WM_KEYUP
208 | // 0xE8, // Unassigned
209 | // 0xE9-F5, // OEM specific
210 | ATTN = 0xF6, // Attn key
211 | CRSEL = 0xF7, // CrSel key
212 | EXSEL = 0xF8, // ExSel key
213 | EREOF = 0xF9, // Erase EOF key
214 | PLAY = 0xFA, // Play key
215 | ZOOM = 0xFB, // Zoom key
216 | NONAME = 0xFC, // Reserved
217 | PA1 = 0xFD, // PA1 key
218 | OEM_CLEAR = 0xFE // Clear key
219 | }
220 |
221 | ///
222 | /// Internal callback processing function
223 | ///
224 | private delegate IntPtr KeyboardHookHandler(int nCode, IntPtr wParam, IntPtr lParam);
225 | private KeyboardHookHandler? hookHandler;
226 |
227 | ///
228 | /// Function that will be called when defined events occur
229 | ///
230 | /// VKeys
231 | public delegate void KeyboardHookCallback(VKeys key);
232 |
233 | #region Events
234 | public event KeyboardHookCallback? KeyDown;
235 | public event KeyboardHookCallback? KeyUp;
236 | #endregion
237 |
238 | ///
239 | /// Hook ID
240 | ///
241 | private IntPtr hookID = IntPtr.Zero;
242 |
243 | ///
244 | /// Install low level keyboard hook
245 | ///
246 | public void Install()
247 | {
248 | hookHandler = HookFunc;
249 | hookID = SetHook(hookHandler);
250 | }
251 |
252 | ///
253 | /// Remove low level keyboard hook
254 | ///
255 | public void Uninstall()
256 | {
257 | UnhookWindowsHookEx(hookID);
258 | }
259 |
260 | ///
261 | /// Registers hook with Windows API
262 | ///
263 | /// Callback function
264 | /// Hook ID
265 | private IntPtr SetHook(KeyboardHookHandler proc)
266 | {
267 | using (ProcessModule module = Process.GetCurrentProcess().MainModule!)
268 | return SetWindowsHookEx(13, proc, GetModuleHandle(module.ModuleName!), 0);
269 | }
270 |
271 | ///
272 | /// Default hook call, which analyses pressed keys
273 | ///
274 | private IntPtr HookFunc(int nCode, IntPtr wParam, IntPtr lParam)
275 | {
276 | if (nCode >= 0)
277 | {
278 | int iwParam = wParam.ToInt32();
279 |
280 | if ((iwParam == WM_KEYDOWN || iwParam == WM_SYSKEYDOWN))
281 | if (KeyDown != null)
282 | KeyDown((VKeys)Marshal.ReadInt32(lParam));
283 | if ((iwParam == WM_KEYUP || iwParam == WM_SYSKEYUP))
284 | if (KeyUp != null)
285 | KeyUp((VKeys)Marshal.ReadInt32(lParam));
286 | }
287 |
288 | return CallNextHookEx(hookID, nCode, wParam, lParam);
289 | }
290 |
291 | ///
292 | /// Destructor. Unhook current hook
293 | ///
294 | ~KeyboardHook()
295 | {
296 | Uninstall();
297 | }
298 |
299 | ///
300 | /// Low-Level function declarations
301 | ///
302 | #region WinAPI
303 | private const int WM_KEYDOWN = 0x100;
304 | private const int WM_SYSKEYDOWN = 0x104;
305 | private const int WM_KEYUP = 0x101;
306 | private const int WM_SYSKEYUP = 0x105;
307 |
308 | [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
309 | private static extern IntPtr SetWindowsHookEx(int idHook, KeyboardHookHandler lpfn, IntPtr hMod, uint dwThreadId);
310 |
311 | [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
312 | [return: MarshalAs(UnmanagedType.Bool)]
313 | private static extern bool UnhookWindowsHookEx(IntPtr hhk);
314 |
315 | [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
316 | private static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, IntPtr wParam, IntPtr lParam);
317 |
318 | [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
319 | private static extern IntPtr GetModuleHandle(string lpModuleName);
320 | #endregion
321 | }
322 | }
--------------------------------------------------------------------------------
/IMEIndicator/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using System.Drawing.Text;
5 | using System.Globalization;
6 | using System.Linq;
7 | using System.Runtime.InteropServices;
8 | using System.Windows.Forms;
9 |
10 | namespace IMEIndicator
11 | {
12 | public partial class Program
13 | {
14 | private static readonly NotifyIcon notifyIcon = new();
15 | private static readonly KeyboardHook keyboardHook = new();
16 | private static readonly StringFormat iconStringFormat = new()
17 | {
18 | Alignment = StringAlignment.Center,
19 | LineAlignment = StringAlignment.Center,
20 | };
21 | private static readonly Dictionary iconMap = new();
22 | private static bool darkModeIcon = true;
23 | private static Font? iconFont;
24 | private static WinAPI.WinEventDelegate? winEventDelegate;
25 | private const string notifyIconText =
26 | "{0} Keyboard\n" +
27 | "\n" +
28 | "Right click to show all options\n" +
29 | "Middle click to exit";
30 |
31 | private static bool? needUpdate = null;
32 |
33 | ///
34 | /// Main entry point of the program
35 | ///
36 | public static void Main()
37 | {
38 | Setup();
39 | Application.Run();
40 | }
41 |
42 | ///
43 | /// Setup process
44 | ///
45 | private static void Setup()
46 | {
47 | SetupProcessExitHook();
48 | SetupNotifyIcon();
49 | SetupKeyboardHook();
50 | SetupWindowEventHook();
51 | LoadFont();
52 | UpdateIcon();
53 | CheckUpdate();
54 | }
55 |
56 | ///
57 | /// Initialize process exit hook
58 | ///
59 | private static void SetupProcessExitHook()
60 | {
61 | AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit;
62 | }
63 |
64 | ///
65 | /// Initialize notify icon
66 | ///
67 | private static void SetupNotifyIcon()
68 | {
69 | notifyIcon.Visible = true;
70 | notifyIcon.MouseClick += NotifyIcon_MouseClick;
71 |
72 | // setup drop down menu
73 | ToolStripMenuItem menuItemSetting = new("Settings");
74 | menuItemSetting.Click += MenuItemSetting_Click;
75 |
76 | ToolStripMenuItem menuItemStartupFolder = new("Open Startup Folder");
77 | menuItemStartupFolder.Click += MenuItemStartupFolder_Click;
78 |
79 | ToolStripMenuItem menuItemUpdateStatus = new("Update Status")
80 | {
81 | Name = "UpdateStatus",
82 | Enabled = false
83 | };
84 | menuItemUpdateStatus.Click += MenuItemUpdateStatus_Click;
85 | ToolStripMenuItem menuItemCheckUpdate = new("Check for updates...");
86 | menuItemCheckUpdate.Click += MenuItemCheckUpdate_Click;
87 |
88 | ToolStripMenuItem menuItemExit = new("Exit");
89 | menuItemExit.Click += MenuItemExit_Click;
90 |
91 | ContextMenuStrip contextMenuStrip = new();
92 | contextMenuStrip.Items.Add(menuItemSetting);
93 | contextMenuStrip.Items.Add(menuItemStartupFolder);
94 | contextMenuStrip.Items.Add(new ToolStripSeparator());
95 | contextMenuStrip.Items.Add(menuItemUpdateStatus);
96 | contextMenuStrip.Items.Add(menuItemCheckUpdate);
97 | contextMenuStrip.Items.Add(new ToolStripSeparator());
98 | contextMenuStrip.Items.Add(menuItemExit);
99 |
100 | notifyIcon.ContextMenuStrip = contextMenuStrip;
101 | }
102 |
103 | ///
104 | /// Initialize keyboard hook
105 | ///
106 | private static void SetupKeyboardHook()
107 | {
108 | keyboardHook.KeyUp += KeyboardHook_KeyUp;
109 | keyboardHook.Install();
110 | }
111 |
112 | ///
113 | /// Initialize foreground window event hook
114 | ///
115 | private static void SetupWindowEventHook()
116 | {
117 | // https://stackoverflow.com/a/10280800
118 | winEventDelegate = new WinAPI.WinEventDelegate(WinEventProc);
119 | IntPtr m_hhook = WinAPI.SetWinEventHook(WinAPI.EVENT_SYSTEM_FOREGROUND, WinAPI.EVENT_SYSTEM_FOREGROUND, IntPtr.Zero, winEventDelegate, 0, 0, WinAPI.WINEVENT_OUTOFCONTEXT);
120 | }
121 |
122 | ///
123 | /// Load font from resources
124 | ///
125 | public static void LoadFont()
126 | {
127 | // https://stackoverflow.com/a/23519499
128 | byte[] fontData = Resources.iosevka_fixed_regular_capital;
129 | IntPtr fontPtr = Marshal.AllocCoTaskMem(fontData.Length);
130 | Marshal.Copy(fontData, 0, fontPtr, fontData.Length);
131 | uint dummy = 0;
132 | PrivateFontCollection iconFonts = new();
133 | iconFonts.AddMemoryFont(fontPtr, Resources.iosevka_fixed_regular_capital.Length);
134 | WinAPI.AddFontMemResourceEx(fontPtr, (uint)Resources.iosevka_fixed_regular_capital.Length, IntPtr.Zero, ref dummy);
135 | Marshal.FreeCoTaskMem(fontPtr);
136 |
137 | iconFont = new Font(iconFonts.Families[0], 84.0f);
138 | }
139 |
140 | ///
141 | /// Update notify icon
142 | ///
143 | private static void UpdateIcon()
144 | {
145 | bool isDarkMode = ProgramHelpers.IsDarkMode();
146 |
147 | if (isDarkMode != darkModeIcon)
148 | {
149 | iconMap.Clear();
150 | darkModeIcon = isDarkMode;
151 | }
152 |
153 | CultureInfo? cultureInfo = ProgramHelpers.GetCurrentKeyboardLayout();
154 |
155 | string text = (cultureInfo?.TwoLetterISOLanguageName.ToUpper()) ?? "XX";
156 |
157 | if (!iconMap.ContainsKey(text))
158 | {
159 | Icon newIcon = ProgramHelpers.MakeIcon(text, iconFont, iconStringFormat);
160 | iconMap.Add(text, newIcon);
161 | }
162 |
163 | notifyIcon.Icon = iconMap[text];
164 | notifyIcon.Text = string.Format(notifyIconText, (cultureInfo?.DisplayName) ?? "ERROR");
165 | }
166 |
167 | ///
168 | /// Check if the program needs to be updated
169 | ///
170 | private static void CheckUpdate()
171 | {
172 | needUpdate = UpdateChecker.Check();
173 |
174 | ToolStripItem status = notifyIcon.ContextMenuStrip.Items.Find("UpdateStatus", true).First();
175 |
176 | if (needUpdate == null)
177 | {
178 | status.Text = "Failed to Fetch Updates";
179 | status.Enabled = false;
180 | }
181 | else if (needUpdate.Value)
182 | {
183 | status.Text = "New Update Available! (Click to view)";
184 | status.Enabled = true;
185 | }
186 | else
187 | {
188 | status.Text = "No Update Available";
189 | status.Enabled = false;
190 | }
191 | }
192 | }
193 | }
--------------------------------------------------------------------------------
/IMEIndicator/ProgramHelpers.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Win32;
2 | using System;
3 | using System.Diagnostics;
4 | using System.Drawing;
5 | using System.Drawing.Drawing2D;
6 | using System.Globalization;
7 |
8 | namespace IMEIndicator
9 | {
10 | internal static class ProgramHelpers
11 | {
12 |
13 | ///
14 | /// Use low level win32 API to get keyboard layout info for current foreground window
15 | ///
16 | ///
17 | public static CultureInfo? GetCurrentKeyboardLayout()
18 | {
19 | // https://yal.cc/csharp-get-current-keyboard-layout/
20 | try
21 | {
22 | IntPtr foregroundWindow = WinAPI.GetForegroundWindow();
23 | uint foregroundProcess = WinAPI.GetWindowThreadProcessId(foregroundWindow, IntPtr.Zero);
24 | int keyboardLayout = WinAPI.GetKeyboardLayout(foregroundProcess).ToInt32() & 0xFFFF;
25 | return new CultureInfo(keyboardLayout);
26 | }
27 | catch
28 | {
29 | return null;
30 | }
31 | }
32 |
33 | ///
34 | /// Check if Windows theme is dark mode
35 | ///
36 | /// if Windows is dark mode
37 | public static bool IsDarkMode()
38 | {
39 | try
40 | {
41 | if (Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize", "SystemUsesLightTheme", "1") is object v)
42 | {
43 | return v.ToString() == "0";
44 | }
45 | else return true;
46 | }
47 | catch
48 | {
49 | return true;
50 | }
51 | }
52 |
53 | ///
54 | /// Launch windows setting APP
55 | ///
56 | ///
57 | /// URL of the setting page
58 | ///
59 | /// MS docs
60 | ///
61 | ///
62 | public static void LaunchWindowSettingApp(string url)
63 | {
64 | ProcessStartInfo processStartInfo = new(url);
65 | processStartInfo.UseShellExecute = true;
66 | Process.Start(processStartInfo);
67 | }
68 |
69 | ///
70 | /// Make icon with two letter language code
71 | ///
72 | /// Two letter code
73 | /// Generated icon
74 | public static Icon MakeIcon(string text, Font? iconFont, StringFormat iconStringFormat)
75 | {
76 | Bitmap bitmap = new(128, 128);
77 |
78 | Graphics g = Graphics.FromImage(bitmap);
79 | g.SmoothingMode = SmoothingMode.AntiAlias;
80 | g.InterpolationMode = InterpolationMode.HighQualityBicubic;
81 | g.PixelOffsetMode = PixelOffsetMode.HighQuality;
82 |
83 | g.DrawString(text, iconFont!, IsDarkMode() ? Brushes.White : Brushes.Black, 64, 72, iconStringFormat);
84 | g.Flush();
85 |
86 | Icon newIcon = Icon.FromHandle(bitmap.GetHicon());
87 | return newIcon;
88 | }
89 | }
90 | }
--------------------------------------------------------------------------------
/IMEIndicator/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace IMEIndicator {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// Returns the cached ResourceManager instance used by this class.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("IMEIndicator.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 |
63 | ///
64 | /// Looks up a localized resource of type System.Byte[].
65 | ///
66 | internal static byte[] iosevka_fixed_regular_capital {
67 | get {
68 | object obj = ResourceManager.GetObject("iosevka_fixed_regular_capital", resourceCulture);
69 | return ((byte[])(obj));
70 | }
71 | }
72 |
73 | ///
74 | /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
75 | ///
76 | internal static System.Drawing.Icon Logo {
77 | get {
78 | object obj = ResourceManager.GetObject("Logo", resourceCulture);
79 | return ((System.Drawing.Icon)(obj));
80 | }
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/IMEIndicator/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
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 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 |
122 | Resources\iosevka-fixed-regular-capital.ttf;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
123 |
124 |
125 | Resources\Logo.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
126 |
127 |
--------------------------------------------------------------------------------
/IMEIndicator/Resources/Logo.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Icecovery/IMEIndicator/43c01b7defa10950661a610bb775cac8af44fe5a/IMEIndicator/Resources/Logo.ico
--------------------------------------------------------------------------------
/IMEIndicator/Resources/iosevka-fixed-regular-capital.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Icecovery/IMEIndicator/43c01b7defa10950661a610bb775cac8af44fe5a/IMEIndicator/Resources/iosevka-fixed-regular-capital.ttf
--------------------------------------------------------------------------------
/IMEIndicator/UpdateChecker.cs:
--------------------------------------------------------------------------------
1 | using Octokit;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Diagnostics;
5 | using System.Reflection;
6 |
7 | namespace IMEIndicator
8 | {
9 | internal static class UpdateChecker
10 | {
11 | private static readonly string gitHubUserName = "Icecovery";
12 | private static readonly string gitHubRepoName = "IMEIndicator";
13 |
14 | public static string GitHubReleaseAddress => $"https://github.com/{gitHubUserName}/{gitHubRepoName}/releases";
15 |
16 | ///
17 | /// Check if need update
18 | ///
19 | /// true if need update, false if not, null if failed
20 | public static bool? Check()
21 | {
22 | try
23 | {
24 | FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
25 | if (fvi.FileVersion == null)
26 | {
27 | return null;
28 | }
29 | Version currentVersion = new(fvi.FileVersion);
30 |
31 | GitHubClient client = new(new ProductHeaderValue("IMEIndicator", currentVersion.ToString()));
32 | IReadOnlyList releases = client.Repository.Release.GetAll(gitHubUserName, gitHubRepoName).Result;
33 | if (releases is null || releases.Count == 0)
34 | {
35 | return null;
36 | }
37 |
38 | Version onlineVersion = new(releases[0].TagName.Replace("v", string.Empty));
39 | static int NegativeCheck(int input) => input == -1 ? 0 : input;
40 | onlineVersion = new(NegativeCheck(onlineVersion.Major),
41 | NegativeCheck(onlineVersion.Minor),
42 | NegativeCheck(onlineVersion.Build),
43 | NegativeCheck(onlineVersion.Revision));
44 |
45 | int result = currentVersion.CompareTo(onlineVersion);
46 | return result < 0;
47 | }
48 | catch
49 | {
50 | return null;
51 | }
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/IMEIndicator/WinAPI.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.InteropServices;
3 |
4 | namespace IMEIndicator
5 | {
6 | internal class WinAPI
7 | {
8 | public const uint WINEVENT_OUTOFCONTEXT = 0;
9 | public const uint EVENT_SYSTEM_FOREGROUND = 3;
10 |
11 | [DllImport("user32.dll")] public static extern IntPtr GetForegroundWindow();
12 | [DllImport("user32.dll")] public static extern uint GetWindowThreadProcessId(IntPtr hwnd, IntPtr proccess);
13 | [DllImport("user32.dll")] public static extern IntPtr GetKeyboardLayout(uint thread);
14 | [DllImport("user32.dll")] public static extern bool DestroyIcon(IntPtr handle);
15 | [DllImport("gdi32.dll")] public static extern IntPtr AddFontMemResourceEx(IntPtr pbFont, uint cbFont, IntPtr pdv, [In] ref uint pcFonts);
16 | [DllImport("user32.dll")] public static extern IntPtr SetWinEventHook(uint eventMin, uint eventMax, IntPtr hmodWinEventProc, WinEventDelegate lpfnWinEventProc, uint idProcess, uint idThread, uint dwFlags);
17 |
18 | // https://stackoverflow.com/a/10280800
19 | public delegate void WinEventDelegate(IntPtr hWinEventHook, uint eventType, IntPtr hwnd, int idObject, int idChild, uint dwEventThread, uint dwmsEventTime);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 Icecovery
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 | # IME Indicator
2 |
3 | 
4 |
5 | A better IME (Input Method Editor) indicator for Windows 10/11
6 |
7 | ## Features
8 |
9 | Have you ever run into this problem before?
10 |
11 | 
12 |
13 | Microsoft never fixed it, so I did:
14 |
15 | 
16 |
17 | It supports any keyboard layout, it uses
18 | [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) two-letter
19 | language codes to indicate the current keyboard layout.
20 |
21 | 
22 |
23 | ## Quick Start
24 |
25 | 1. Open setting, go to Personalization - Taskbar, under `Notification area`,
26 | click on `Turn system icons on or off`.
27 |
28 | 2. Set `Input Indicator` to `Off`.
29 |
30 | 3. Open `IMEIndicator.exe`.
31 |
32 | 4. Enjoy!
33 |
34 | ## Launch on Windows Startup
35 |
36 | 1. Create a shortcut for IME Indicator.
37 |
38 | 2. Click `Open Startup Folder` button in the system tray icon drop down menu, or
39 |
40 | 3. Alternately, Open `%APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup`
41 | in file explorer, or
42 |
43 | 4. Alternately, type `shell:startup` in the Run dialog (open by pressing
44 | `Win + R` keys).
45 |
46 | 5. Move the shortcut to that location.
47 |
48 | 6. IME Indicator should launch next time you start Windows.
49 |
50 | ## Usage
51 |
52 | - Right-click on the system tray icon will display the drop-down menu containing
53 | all the options.
54 |
55 | - Middle click on the system tray icon will quit the application.
56 |
57 | ## Acknowledgment
58 |
59 | Icon text font: [Iosevka](https://github.com/be5invis/Iosevka)
60 |
61 | Font subset tool: [Fonttools](https://github.com/fonttools/fonttools)
62 |
63 | Keyboard hook: [Global Low Level Key Board And Mouse Hook](https://github.com/rvknth043/Global-Low-Level-Key-Board-And-Mouse-Hook)
64 |
65 | ## License
66 |
67 | [MIT License](https://github.com/Icecovery/IMEIndicator/blob/master/LICENSE)
--------------------------------------------------------------------------------