Skip to content

Instantly share code, notes, and snippets.

@rubyu
Last active March 2, 2019 08:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rubyu/04d74d5e3d11f22684c469169dbd1526 to your computer and use it in GitHub Desktop.
Save rubyu/04d74d5e3d11f22684c469169dbd1526 to your computer and use it in GitHub Desktop.
フォアグラウンドウィンドウをマウスのあるディスプレイ上で最大化する(Ctrl+Shift+F11)
// Script for Crevice https://creviceapp.github.io
[System.Runtime.InteropServices.DllImport("user32.dll")]
static extern short GetKeyState(int nVirtKey);
[System.Runtime.InteropServices.DllImport("user32.dll")]
static extern bool SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int y, int cx, int cy, int uFlags);
{
var activated = false;
var Whenever = When(ctx =>
{
return true;
});
Whenever.
OnDecomposed(Keys.F11).
Press(ctx =>
{
activated = GetKeyState(Keys.ShiftKey) < 0 && GetKeyState(Keys.ControlKey) < 0;
if (!activated) {
SendInput.KeyDown(Keys.F11);
}
}).
Release(ctx => {
if (!activated) {
SendInput.KeyUp(Keys.F11);
return;
}
var wa = Screen.GetWorkingArea(Window.GetPhysicalCursorPos());
var x = wa.Location.X;
var y = wa.Location.Y;
var w = wa.Size.Width;
var h = wa.Size.Height;
var HWND_TOP = 0;
var SWP_SHOWWINDOW = 0x0040;
SetWindowPos(ctx.ForegroundWindow.WindowHandle, HWND_TOP, x, y, w, h, SWP_SHOWWINDOW);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment