diff --git a/.vs/ProjectSettings.json b/.vs/ProjectSettings.json new file mode 100644 index 0000000..d33b3d6 --- /dev/null +++ b/.vs/ProjectSettings.json @@ -0,0 +1,3 @@ +{ + "CurrentProjectSetting": "Keine Konfigurationen" +} \ No newline at end of file diff --git a/.vs/VSWorkspaceState.json b/.vs/VSWorkspaceState.json new file mode 100644 index 0000000..d282b3b --- /dev/null +++ b/.vs/VSWorkspaceState.json @@ -0,0 +1,7 @@ +{ + "ExpandedNodes": [ + "" + ], + "SelectedNode": "\\README.md", + "PreviewInSolutionExplorer": false +} \ No newline at end of file diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite new file mode 100644 index 0000000..28fcc8c Binary files /dev/null and b/.vs/slnx.sqlite differ diff --git a/.vs/tinyhotcorner/v16/.suo b/.vs/tinyhotcorner/v16/.suo new file mode 100644 index 0000000..8ca4ca2 Binary files /dev/null and b/.vs/tinyhotcorner/v16/.suo differ diff --git a/.vs/tinyhotcorner/v16/Browse.VC.db b/.vs/tinyhotcorner/v16/Browse.VC.db new file mode 100644 index 0000000..afaae10 Binary files /dev/null and b/.vs/tinyhotcorner/v16/Browse.VC.db differ diff --git a/.vs/tinyhotcorner/v16/ipch/AutoPCH/374e2ccbc4bcc3a6/HOTCORNER.ipch b/.vs/tinyhotcorner/v16/ipch/AutoPCH/374e2ccbc4bcc3a6/HOTCORNER.ipch new file mode 100644 index 0000000..75a5138 Binary files /dev/null and b/.vs/tinyhotcorner/v16/ipch/AutoPCH/374e2ccbc4bcc3a6/HOTCORNER.ipch differ diff --git a/.vs/tinyhotcorner/v16/ipch/AutoPCH/7d01e4fedeec3397/HOTCORNER.ipch b/.vs/tinyhotcorner/v16/ipch/AutoPCH/7d01e4fedeec3397/HOTCORNER.ipch new file mode 100644 index 0000000..a7a882e Binary files /dev/null and b/.vs/tinyhotcorner/v16/ipch/AutoPCH/7d01e4fedeec3397/HOTCORNER.ipch differ diff --git a/README.md b/README.md index 9e47ddd..19ba4a0 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ This is a **very** minimal hotcorner app, written in C. You can adjust parameter Zero state is stored anywhere, no registry keys or configuration files. -- If you want to configure something, edit the code and recompile. +- If you want to configure something, use the arguments or edit the code and recompile. () - If you want to uninstall it, just delete it. ## Instructions @@ -55,7 +55,14 @@ Additionally, it is possible to build hotcorner on Linux using MinGW. ### Configuration -All configuration requires modifying the parameters in `hotcorner.c` and recompiling. +Use the arguments to define the reactangle position and the delay. +Size of the rectangle and delay until its activated can be changed via arguments. The first four arguments define the size and positon of the reactangle, +the fifth argument is the delay in milliseconds. +The order of the arguments is top, left, right, bottom. E.g. if you want a square at the top left, your arguments are -50 -50 50 50, for the bottom left on a 1080 pixel screen, you could use +1070, 20, -20, 1100. To use the arguments make a shortcut to your hotcorner.exe and put the shortcut into "%USERPROFILE%\Start Menu\Programs\Startup\" instead of hotcorner.exe +In the target of the shortcut add the arguments after hotcorner.exe. E.g. "your/path/to/hotcorner.exe -50 -50 50 50 100" +If no arguments are provided, the default is used. (-20 -20 20 20 300) +Further configuration requires modifying the parameters in `hotcorner.c` and recompiling. * `RECT kHotcorner` - The coordinates of the hot zone. * `INPUT kCornerInput[]` - Input sent on activation. @@ -70,6 +77,7 @@ GPL3 * Tavis Ormandy [@taviso](https://github.com/taviso/) - Original Author * Ahmed Samy [@asamy](https://github.com/asamy) - HotKey support +* Pascal Jaeger [@Schievel1]https://github.com/Schievel1/ - Command line arguments ## Variations diff --git a/hotcorner.c b/hotcorner.c index 84f0384..5ea8cbe 100644 --- a/hotcorner.c +++ b/hotcorner.c @@ -23,10 +23,10 @@ // If the mouse enters this rectangle, activate the hot corner function. // There are some hints about changing corners here // https://github.com/taviso/hotcorner/issues/7#issuecomment-269367351 -static const RECT kHotCorner = { - .top = -20, - .left = -20, - .right = +20, +static RECT kHotCorner = { + .top = -20, + .left = -20, + .right = +20, .bottom = +20, }; @@ -39,7 +39,7 @@ static const INPUT kCornerInput[] = { }; // How long cursor has to linger in the kHotCorner RECT to trigger input. -static const DWORD kHotDelay = 300; +static DWORD kHotDelay = 300; // You can exit the application using the hot key CTRL+ALT+C by default, if it // interferes with some application you're using (e.g. a full screen game). @@ -65,8 +65,8 @@ static DWORD WINAPI CornerHotFunc(LPVOID lpParameter) // Check if any modifier keys are pressed. if (GetKeyboardState(KeyState)) { if (KEYDOWN(KeyState[VK_SHIFT]) || KEYDOWN(KeyState[VK_CONTROL]) - || KEYDOWN(KeyState[VK_MENU]) || KEYDOWN(KeyState[VK_LWIN]) - || KEYDOWN(KeyState[VK_RWIN])) { + || KEYDOWN(KeyState[VK_MENU]) || KEYDOWN(KeyState[VK_LWIN]) + || KEYDOWN(KeyState[VK_RWIN])) { return 0; } } @@ -78,7 +78,7 @@ static DWORD WINAPI CornerHotFunc(LPVOID lpParameter) // Check co-ordinates. if (PtInRect(&kHotCorner, Point)) { - #pragma warning(suppress : 4090) +#pragma warning(suppress : 4090) if (SendInput(_countof(kCornerInput), kCornerInput, sizeof(INPUT)) != _countof(kCornerInput)) { return 1; } @@ -89,7 +89,7 @@ static DWORD WINAPI CornerHotFunc(LPVOID lpParameter) static LRESULT CALLBACK MouseHookCallback(int nCode, WPARAM wParam, LPARAM lParam) { - MSLLHOOKSTRUCT *evt = (MSLLHOOKSTRUCT *) lParam; + MSLLHOOKSTRUCT* evt = (MSLLHOOKSTRUCT*)lParam; // If the mouse hasn't moved, we're done. if (wParam != WM_MOUSEMOVE) @@ -136,6 +136,23 @@ int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi MSG Msg; HHOOK MouseHook; + // get arguments from the command line. First four arguments are the coordinates of the rectangle that activates the hot corner + // fifth argument is the delay it takes to activate the hot corner + char* ptr; + char* arg1 = { strtok_s(lpCmdLine, " ", &ptr) }; + char* arg2 = { strtok_s(NULL, " ", &ptr) }; + char* arg3 = { strtok_s(NULL, " ", &ptr) }; + char* arg4 = { strtok_s(NULL, " ", &ptr) }; + char* arg5 = { strtok_s(NULL, " ", &ptr) }; + + if (arg1 && arg1[0] && arg2 && arg2[0] && arg3 && arg3[0] && arg4 && arg4[0]) { + kHotCorner.top = atol(arg1); + kHotCorner.left = atol(arg2); + kHotCorner.right = atol(arg3); + kHotCorner.bottom = atol(arg4); + kHotDelay = atol(arg5); + } + if (!(MouseHook = SetWindowsHookEx(WH_MOUSE_LL, MouseHookCallback, NULL, 0))) return 1; diff --git a/hotcorner.exe b/hotcorner.exe new file mode 100644 index 0000000..bb732a8 Binary files /dev/null and b/hotcorner.exe differ diff --git a/hotcorner.obj b/hotcorner.obj new file mode 100644 index 0000000..62eef85 Binary files /dev/null and b/hotcorner.obj differ diff --git a/version.res b/version.res new file mode 100644 index 0000000..d722d4e Binary files /dev/null and b/version.res differ