Last active
March 2, 2019 08:18
-
-
Save rubyu/04d74d5e3d11f22684c469169dbd1526 to your computer and use it in GitHub Desktop.
フォアグラウンドウィンドウをマウスのあるディスプレイ上で最大化する(Ctrl+Shift+F11)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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