Last active
December 21, 2015 00:28
-
-
Save sjoness/6220034 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// Author: Kyle Fuller | |
#include <windows.h> | |
#include <shlwapi.h> | |
#include <string.h> | |
#define LIST_COUNT 4 | |
char *list[LIST_COUNT] = { "intype", "portable", "opera", "duty" }; | |
BOOL EnumWinProc(HWND hWnd, LPARAM lParam) { | |
char buf[256]; | |
GetWindowText(hWnd, buf, 256); | |
CharLower(buf); | |
for(int i = 0; i < LIST_COUNT; i++) { | |
if(StrStr(buf, list[i]) != 0) | |
ShowWindow(hWnd, lParam); | |
} | |
return TRUE; | |
} | |
void execute(const char *path) { | |
PROCESS_INFORMATION pi; | |
STARTUPINFO si; | |
ZeroMemory(&si, sizeof(si)); | |
si.cb = sizeof(si); | |
si.dwFlags = STARTF_USESHOWWINDOW | STARTF_FORCEOFFFEEDBACK; | |
if (CreateProcess(0, path, 0, 0, TRUE, 0, 0, NULL, &si, &pi) == 0) { | |
MessageBox(NULL, "Failed", "CreateProcess", MB_OK); | |
} | |
} | |
void create_shell(void) { | |
execute("\\PortablePython_1.1_py2.6.1\\CommandPromptPortable.exe"); | |
} | |
void intype(void) { | |
execute("\\PortablePython_1.1_py2.6.1\\intype.exe"); | |
} | |
void opera(void) { | |
execute("\\Downloads\\OperaPortable\\App\\Opera\\opera.exe"); | |
} | |
void unmount(void) { | |
/* | |
HANDLE f = CreateFile("F:\\", | |
__in DWORD dwDesiredAccess, | |
__in DWORD dwShareMode, | |
__in_opt LPSECURITY_ATTRIBUTES lpSecurityAttributes, | |
__in DWORD dwCreationDisposition, | |
__in DWORD dwFlagsAndAttributes, | |
__in_opt HANDLE hTemplateFile | |
); | |
*/ | |
} | |
void logout(void) { | |
ExitWindowsEx(EWX_LOGOFF, 0x00040000); | |
} | |
int window_visibility = 0; | |
void toggle_window_visibility(void) { | |
EnumWindows(EnumWinProc, window_visibility); | |
if (window_visibility == 1) { | |
window_visibility = 0; | |
} else { | |
window_visibility = 1; | |
} | |
} | |
void install(void) { | |
} | |
void WndProcPaint(HWND hWnd) { | |
} | |
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { | |
switch (message) { | |
case WM_DESTROY: | |
PostQuitMessage(WM_QUIT); | |
break; | |
case WM_PAINT: | |
WndProcPaint(hWnd); | |
break; | |
case WM_HOTKEY: | |
MessageBox(NULL, "s", "s", MB_OK); | |
break; | |
default: | |
return DefWindowProc(hWnd, message, wParam, lParam); | |
} | |
return 0L; | |
} | |
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { | |
MSG msg; | |
RegisterHotKey(NULL, 1, MOD_CONTROL, VK_SPACE); // CTRL + SPACE | |
RegisterHotKey(NULL, 2, MOD_CONTROL | MOD_ALT, VK_SPACE); // CTRL + ALT + SPACE | |
RegisterHotKey(NULL, 3, MOD_CONTROL, 0x4C); // CTRL + L | |
RegisterHotKey(NULL, 4, MOD_CONTROL | MOD_ALT, 0x4C); // CTRL + ALT + L | |
RegisterHotKey(NULL, 5, MOD_CONTROL, 0x49); // CTRL + I | |
RegisterHotKey(NULL, 6, MOD_CONTROL | MOD_ALT, 0x49); // CTRL + ALT + I | |
RegisterHotKey(NULL, 7, MOD_ALT, 0x52); // ALT + R | |
/* | |
WNDCLASSEX wcex; | |
wcex.cbSize = sizeof(WNDCLASSEX); | |
wcex.style = CS_HREDRAW | CS_VREDRAW; | |
wcex.lpfnWndProc = WndProc; | |
wcex.cbClsExtra = 0; | |
wcex.cbWndExtra = 0; | |
wcex.hInstance = hInst; | |
wcex.hIcon = LoadIcon(NULL, IDI_APPLICATION); | |
wcex.hCursor = LoadCursor(NULL, IDC_ARROW); | |
wcex.hbrBackground = GetStockObject(WHITE_BRUSH); | |
wcex.lpszMenuName = NULL; | |
wcex.lpszClassName = "LoginBox"; | |
wcex.hIconSm = LoadIcon(NULL, IDI_APPLICATION); | |
RegisterClassEx(&wcex); | |
HWND hWnd; | |
hWnd = CreateWindow("LoginBox", "Unlock Portable", WS_POPUP | WS_OVERLAPPED | WS_CAPTION, CW_USEDEFAULT, CW_USEDEFAULT, 434, 192, NULL, NULL, hInst, NULL); | |
CreateWindow("edit", "", WS_CHILD | WS_VISIBLE | WS_BORDER, 15, 15, 237, 16, hWnd, NULL, hInst, NULL); | |
ShowWindow(hWnd, 1); | |
UpdateWindow(hWnd); | |
*/ | |
while (GetMessage(&msg, NULL, 0, 0)) { | |
if (msg.message == WM_HOTKEY) { | |
switch (msg.wParam) { | |
case 1: | |
toggle_window_visibility(); | |
break; | |
case 2: | |
create_shell(); | |
break; | |
case 3: | |
unmount(); | |
MessageBox(NULL, "Remove USB Drive", "Please remove your USB Drive.", MB_OK); | |
logout(); | |
ExitProcess(1); | |
break; | |
case 4: | |
ExitProcess(1); | |
break; | |
case 5: | |
intype(); | |
break; | |
case 6: | |
opera(); | |
break; | |
case 7: | |
MessageBox(NULL, "Run", "Run Dialogue.", MB_OK); | |
break; | |
} | |
} | |
TranslateMessage(&msg); | |
DispatchMessage(&msg); | |
} | |
return msg.wParam; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment