-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModifierKeyLauncher.cpp
More file actions
52 lines (40 loc) · 1.25 KB
/
ModifierKeyLauncher.cpp
File metadata and controls
52 lines (40 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <tchar.h>
#include <windows.h>
#include <ShellAPI.h>
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
(void)hInstance;
(void)hPrevInstance;
(void)lpCmdLine;
(void)nCmdShow;
int selectedArg = -1;
int argc;
auto argv = CommandLineToArgvW(GetCommandLineW(), &argc);
bool isShift = (GetKeyState( VK_SHIFT ) & 0x8000)!=0;
bool isCtrl = (GetKeyState( VK_CONTROL) & 0x8000)!=0;
bool isAlt = (GetKeyState( VK_MENU ) & 0x8000)!=0;
//MessageBoxW(0, lpCmdLine, TEXT("commandline"), MB_OK );
//for( int i=0; i< argc; ++i){
// MessageBoxW(0, argv[i], TEXT("argv"), MB_OK );
//}
if(isShift && argc > 2){
selectedArg = 2;
}else if(isCtrl && argc > 3){
selectedArg = 3;
}else if(isAlt && argc > 4){
selectedArg = 4;
}else if(argc > 1){
selectedArg = 1;
}else{
MessageBoxW(0, TEXT("no args"), TEXT("error"), MB_OK );
}
if(selectedArg>=0){
//MessageBoxW(0, argv[selectedArg], TEXT("selected"), MB_OK );
ShellExecute(0, TEXT("open"), argv[selectedArg], NULL,NULL, SW_SHOWNORMAL );
}
LocalFree(argv);
return 0;
}