Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
iuchim committed Aug 22, 2019
0 parents commit 4a2bf12
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/zenhan
*.zip
13 changes: 13 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
mkdir -p zenhan/bin64
mkdir -p zenhan/bin32

out=zenhan/bin64/zenhan.exe
x86_64-w64-mingw32-g++-win32 -std=c++11 -mwindows main.cc -o $out -limm32
x86_64-w64-mingw32-strip $out

out=zenhan/bin32/zenhan.exe
i686-w64-mingw32-g++-win32 -std=c++11 -mwindows -static-libgcc main.cc -o $out -limm32
i686-w64-mingw32-strip $out

zip -r9 zenhan.zip zenhan/
28 changes: 28 additions & 0 deletions main.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <cstdio>
#include <cstdlib>
#include <windows.h>

int
main(int argc, char** argv)
{
constexpr LPARAM IMC_GETOPENSTATUS = 5;
constexpr LPARAM IMC_SETOPENSTATUS = 6;

auto hwnd = GetForegroundWindow();
if (!hwnd)
return 0;

auto ime = ImmGetDefaultIMEWnd(hwnd);
if (!ime)
return 0;

LPARAM stat;
if (argc < 2) {
stat = SendMessage(ime, WM_IME_CONTROL, IMC_GETOPENSTATUS, 0);
} else {
stat = std::atoi(argv[1]);
SendMessage(ime, WM_IME_CONTROL, IMC_SETOPENSTATUS, stat);
}
std::printf("%d\n", stat);
return 0;
}

0 comments on commit 4a2bf12

Please sign in to comment.