void NotepadHook::Uninstall() { Autosaver::GetInstance()->Stop(); UnhookWindowsHookEx(_keyboardHookHandle); }
// // Called at exit // void _USERENTRY CleanupApp() { if ( hKeyboardHook != NULL ) UnhookWindowsHookEx (hKeyboardHook); CleanupWindeu(); }
void UninitializeCbtHook() { if (hookCbt != NULL) UnhookWindowsHookEx(hookCbt); hookCbt = NULL; }
EventLoop::~EventLoop() { stop(); DestroyWindow(m_messageWindow); UnhookWindowsHookEx(m_idleHook); }
void UninitializeKeyboardLLHook() { if (hookKeyboardLL != NULL) UnhookWindowsHookEx(hookKeyboardLL); hookKeyboardLL = NULL; }
void UninitializeCallWndProcHook() { if (hookCallWndProc != NULL) UnhookWindowsHookEx(hookCallWndProc); hookCallWndProc = NULL; }
int UnhookSystem() { if (!keyhook && !msghook) { // System not hooked return 1; } // Remove keyboard hook if (keyhook) { if (UnhookWindowsHookEx(keyhook) == 0) { #ifdef DEBUG Error(L"UnhookWindowsHookEx(keyhook)", L"Could not unhook keyboard. Try restarting "APP_NAME".", GetLastError()); #else if (showerror) { MessageBox(NULL, l10n->unhook_error, APP_NAME, MB_ICONINFORMATION|MB_OK|MB_TOPMOST|MB_SETFOREGROUND); } #endif } keyhook = NULL; } // Remove message hook if (msghook) { if (UnhookWindowsHookEx(msghook) == 0) { #ifdef DEBUG Error(L"UnhookWindowsHookEx(msghook)", L"Could not unhook message hook. Try restarting "APP_NAME".", GetLastError()); #endif } msghook = NULL; // Close HookWindows_x64.exe if (x64) { HWND window = FindWindow(L"AltDrag-x64", NULL); if (window != NULL) { PostMessage(window, WM_CLOSE, 0, 0); } } // Send dummy messages to all processes to make them unload hooks.dll EnumWindows(EnumWindowsProc, 0); } // Tell dll file that we are unloading void (*Unload)() = (void*) GetProcAddress(hinstDLL, "Unload"); if (Unload == NULL) { Error(L"GetProcAddress('Unload')", L"This probably means that the file hooks.dll is from an old version or corrupt. You can try reinstalling "APP_NAME".", GetLastError()); } else { Unload(); } // Unload library if (hinstDLL) { if (FreeLibrary(hinstDLL) == 0) { Error(L"FreeLibrary()", L"Could not free hooks.dll. Try restarting "APP_NAME".", GetLastError()); } hinstDLL = NULL; } // Success UpdateTray(); return 0; }
void UninitializeKeyboardHook() { if (hookKeyboard != NULL) UnhookWindowsHookEx(hookKeyboard); hookKeyboard = NULL; }
TESTDLL_API void RemoveHook() { OutputDebugString( "TESTDLL hook removed.\n" ); UnhookWindowsHookEx( hHook ); }
LRESULT CALLBACK notificationWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { PAINTSTRUCT ps; HDC hdc; RECT rc = {0}; UINT notify_duration = 0; static BOOL is_fading_out = FALSE; static HHOOK hook_mouse_over = NULL; static NotifyNotification notification_data_copy = {L"", L"", ICON_INFO}; switch (message) { case WM_LIBNOTIFYSHOW: /* close if already running */ if(IsWindowVisible(hWnd)) { SendMessage(hWnd, WM_LIBNOTIFYCLOSE, 0, 0); } /* guarded by CS to make sure notification_data doesn't get corrupted when this code and notify_notification_update is running in parallel */ { EnterCriticalSection(&thread_guard); NotifyNotification *notification_data = (NotifyNotification*) lParam; if(notification_data && notification_data->body && notification_data->summary) { notification_data_copy = *notification_data; } else { LeaveCriticalSection(&thread_guard); break; } LeaveCriticalSection(&thread_guard); } /* deduce the allowed text width from the max width; see geometry for rationale */ rc.right = notification_window_width_max - (icon_size + (icon_padding * 3)); hdc = GetDC(hWnd); if(hdc) { HRGN hRgn = NULL; HGDIOBJ hOldFont = SelectObject(hdc, (HGDIOBJ) font_body); if(hOldFont) { DrawText(hdc, notification_data_copy.body, -1, &rc, DT_CALCRECT | DT_WORDBREAK | DT_EDITCONTROL | DT_NOCLIP | DT_NOPREFIX | DT_EXTERNALLEADING); SelectObject(hdc, hOldFont); } ReleaseDC(hWnd, hdc); if(!hOldFont) return 0; /* exit if font selection failed */ /* calculate the actual bounding rectangle from the DrawText output */ notify_wnd.notification_window_height = notify_wnd.summary_body_divider + rc.bottom + (icon_padding * 3); notify_wnd.notification_window_width = rc.right + icon_size + (icon_padding * 3); /* word count * milliseconds per word */ notify_duration = word_count(notification_data_copy.body) * milliseconds_per_word; /* in case the calculation renders too low a value, replace it with a de facto minimum */ notify_duration = MAX(notify_duration, min_notification_timeout); /* get the screen area uncluttered by the taskbar */ if(SystemParametersInfo(SPI_GETWORKAREA, 0, &rc, 0)) { LONG window_x = 0, window_y = 0; /* system tray @ right bottom */ if((rc.bottom != GetSystemMetrics(SM_CYSCREEN)) || (rc.right != GetSystemMetrics(SM_CXSCREEN))) { window_x = rc.right - (GetSystemMetrics(SM_CXSCREEN) / window_offset_factor) - notify_wnd.notification_window_width; window_y = rc.bottom - (GetSystemMetrics(SM_CYSCREEN) / window_offset_factor) - notify_wnd.notification_window_height; } else if(rc.left != 0) /* left bottom */ { window_x = rc.left + (GetSystemMetrics(SM_CXSCREEN) / window_offset_factor); window_y = rc.bottom - (GetSystemMetrics(SM_CYSCREEN) / window_offset_factor) - notify_wnd.notification_window_height; } else /* right top */ { window_x = rc.right - (GetSystemMetrics(SM_CXSCREEN) / window_offset_factor) - notify_wnd.notification_window_width; window_y = rc.top + (GetSystemMetrics(SM_CYSCREEN) / window_offset_factor); } /* resize and reposition the window */ MoveWindow(hWnd, window_x, window_y, notify_wnd.notification_window_width, notify_wnd.notification_window_height, TRUE); /* set the new positions to be used by the mouse over hook */ notify_wnd.notification_window_rect.left = window_x; notify_wnd.notification_window_rect.top = window_y; notify_wnd.notification_window_rect.right = window_x + notify_wnd.notification_window_width; notify_wnd.notification_window_rect.bottom = window_y + notify_wnd.notification_window_height; /* make it as a rounded rect. */ hRgn = CreateRoundRectRgn(0, 0, notify_wnd.notification_window_width, notify_wnd.notification_window_height, rounded_rect_edge, rounded_rect_edge); SetWindowRgn(hWnd, hRgn, TRUE); /* since bRedraw is set to TRUE in SetWindowRgn invalidation isn't required */ /*InvalidateRect(hWnd, NULL, TRUE);*/ /* show the window and set the timers for animation and overall visibility */ ShowWindow(hWnd, SW_SHOWNOACTIVATE); SetTimer(hWnd, TIMER_ANIMATION, fade_duration, NULL); SetTimer(hWnd, TIMER_NOTIFICATION, notify_duration, NULL); } } break; case WM_LIBNOTIFYCLOSE: /* clean up and reset flags */ { if(hook_mouse_over) { UnhookWindowsHookEx(hook_mouse_over); hook_mouse_over = NULL; } KillTimer(hWnd, TIMER_ANIMATION); KillTimer(hWnd, TIMER_NOTIFICATION); is_fading_out = FALSE; ShowWindow(hWnd, SW_HIDE); } break; case WM_PAINT: if((L'\0' != notification_data_copy.body[0]) && (L'\0' != notification_data_copy.summary[0])) { hdc = BeginPaint(hWnd, &ps); SetTextColor(hdc, RGB(255, 255, 255)); SetBkMode(hdc, TRANSPARENT); HGDIOBJ hOldFont = SelectObject(hdc, (HGDIOBJ) font_summary); if(hOldFont) { /* set the padding as left offset and center the icon horizontally */ DrawIcon(hdc, icon_padding, (notify_wnd.notification_window_height / 2) - (icon_size / 2), notification_icons[notification_data_copy.icon_req]); /* calculate and DrawText for both summary and body based on the geometry given above */ rc.left = icon_size + (icon_padding * 2); rc.right = notify_wnd.notification_window_width - icon_padding; rc.top = icon_padding; rc.bottom = notify_wnd.summary_body_divider + (icon_padding * 2); DrawText(hdc, notification_data_copy.summary, -1, &rc, DT_SINGLELINE | DT_VCENTER | DT_END_ELLIPSIS | DT_NOPREFIX); if(SelectObject(hdc, (HGDIOBJ) font_body)) { rc.top = rc.bottom; rc.bottom = notify_wnd.notification_window_height - icon_padding; DrawText(hdc, notification_data_copy.body, -1, &rc, DT_WORDBREAK | DT_EDITCONTROL | DT_NOCLIP | DT_NOPREFIX | DT_EXTERNALLEADING); } SelectObject(hdc, hOldFont); } EndPaint(hWnd, &ps); } break; case WM_LIBNOTIFYEXIT: if(hook_mouse_over) { UnhookWindowsHookEx(hook_mouse_over); hook_mouse_over = NULL; } KillTimer(notify_wnd.notification_window, TIMER_ANIMATION); KillTimer(notify_wnd.notification_window, TIMER_NOTIFICATION); PostQuitMessage(0); break; case WM_TIMER: if(IsWindowVisible(hWnd)) { if(wParam == TIMER_ANIMATION) /* notification animation timer */ { if(is_fading_out) { if(notify_wnd.notification_window_alpha > 5) { notify_wnd.notification_window_alpha -= 25; } else { /* once fully faded out, self destroy and reset the flags */ KillTimer(hWnd, TIMER_ANIMATION); is_fading_out = FALSE; notify_wnd.notification_window_alpha = 0; SendMessage(hWnd, WM_LIBNOTIFYCLOSE, 0, 0); } } else { if(notify_wnd.notification_window_alpha < 250) { notify_wnd.notification_window_alpha += 25; } else { /* self destory as alpha reaches the maximum */ KillTimer(hWnd, TIMER_ANIMATION); notify_wnd.notification_window_alpha = 255; /* set the mouse over hook once the window is fully visible */ hook_mouse_over = SetWindowsHookEx(WH_MOUSE_LL, mouse_over_hook_proc, (HINSTANCE) GetModuleHandle(NULL), 0); } } /* for all the above cases set the newly calculated alpha */ SetLayeredWindowAttributes(notify_wnd.notification_window, 0, notify_wnd.notification_window_alpha, LWA_ALPHA); } else /* notification duration timer */ { /* self destruct once timed out */ KillTimer(hWnd, TIMER_NOTIFICATION); /* kill the hook set by animation timer */ if(hook_mouse_over) { UnhookWindowsHookEx(hook_mouse_over); hook_mouse_over = NULL; } /* start fading out sequence */ is_fading_out = TRUE; SetTimer(hWnd, TIMER_ANIMATION, fade_duration, NULL); } } break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
static DWORD WINAPI ScreenSaverThreadMain( IN LPVOID lpParameter) { PWLSESSION Session = (PWLSESSION)lpParameter; HANDLE HandleArray[3]; #ifdef USE_GETLASTINPUTINFO LASTINPUTINFO lastInputInfo; #else DWORD LastActivity; #endif DWORD TimeToWait; DWORD Timeout; /* Timeout before screen saver starts, in milliseconds */ DWORD ret; if (!ImpersonateLoggedOnUser(Session->UserToken)) { ERR("ImpersonateLoggedOnUser() failed with error %lu\n", GetLastError()); return 0; } Session->hUserActivity = CreateEventW(NULL, FALSE, FALSE, NULL); if (!Session->hUserActivity) { ERR("WL: Unable to create event (error %lu)\n", GetLastError()); goto cleanup; } Session->hEndOfScreenSaver = CreateEventW(NULL, FALSE, FALSE, NULL); if (!Session->hEndOfScreenSaver) { ERR("WL: Unable to create event (error %lu)\n", GetLastError()); goto cleanup; } HandleArray[0] = Session->hEndOfScreenSaverThread; HandleArray[1] = Session->hScreenSaverParametersChanged; HandleArray[2] = Session->hEndOfScreenSaver; LoadScreenSaverParameters(&Timeout); #ifndef USE_GETLASTINPUTINFO InterlockedExchange((LONG*)&Session->LastActivity, GetTickCount()); #else lastInputInfo.cbSize = sizeof(LASTINPUTINFO); #endif for (;;) { /* See the time of last activity and calculate a timeout */ #ifndef USE_GETLASTINPUTINFO LastActivity = InterlockedCompareExchange((LONG*)&Session->LastActivity, 0, 0); TimeToWait = Timeout - (GetTickCount() - LastActivity); #else if (GetLastInputInfo(&lastInputInfo)) TimeToWait = Timeout - (GetTickCount() - lastInputInfo.dwTime); else { WARN("GetLastInputInfo() failed with error %lu\n", GetLastError()); TimeToWait = 10; /* Try again in 10 ms */ } #endif if (TimeToWait > Timeout) { /* GetTickCount() got back to 0 */ TimeToWait = Timeout; } /* Wait for the timeout, or the end of this thread */ ret = WaitForMultipleObjects(2, HandleArray, FALSE, TimeToWait); if (ret == WAIT_OBJECT_0) break; else if (ret == WAIT_OBJECT_0 + 1) LoadScreenSaverParameters(&Timeout); /* Check if we didn't had recent activity */ #ifndef USE_GETLASTINPUTINFO LastActivity = InterlockedCompareExchange((LONG*)&Session->LastActivity, 0, 0); if (LastActivity + Timeout > GetTickCount()) continue; #else if (!GetLastInputInfo(&lastInputInfo)) { WARN("GetLastInputInfo() failed with error %lu\n", GetLastError()); continue; } if (lastInputInfo.dwTime + Timeout > GetTickCount()) continue; #endif /* Run screen saver */ PostMessageW(Session->SASWindow, WLX_WM_SAS, WLX_SAS_TYPE_SCRNSVR_TIMEOUT, 0); /* Wait for the end of this thread or of the screen saver */ ret = WaitForMultipleObjects(3, HandleArray, FALSE, INFINITE); if (ret == WAIT_OBJECT_0) break; else if (ret == WAIT_OBJECT_0 + 1) LoadScreenSaverParameters(&Timeout); else if (ret == WAIT_OBJECT_0 + 2) SystemParametersInfoW(SPI_SETSCREENSAVERRUNNING, FALSE, NULL, 0); } cleanup: RevertToSelf(); if (Session->hUserActivity) CloseHandle(Session->hUserActivity); if (Session->hEndOfScreenSaver) CloseHandle(Session->hEndOfScreenSaver); #ifndef USE_GETLASTINPUTINFO if (Session->KeyboardHook) UnhookWindowsHookEx(Session->KeyboardHook); if (Session->MouseHook) UnhookWindowsHookEx(Session->MouseHook); #endif CloseHandle(Session->hEndOfScreenSaverThread); CloseHandle(Session->hScreenSaverParametersChanged); return 0; }
void _stdcall RemoveHook() { UnhookWindowsHookEx(KeyHookHandle); //fclose (f1); }
AFX_CLASS_EXPORT void removehook() { UnhookWindowsHookEx(hook); }
__declspec (dllexport) void CALLBACK UninstallHook (void) { //this function unhooks all threads UnhookWindowsHookEx(hHook); return; }
void DestroyTooltips() { UnhookWindowsHookEx(g_tip.hook); }
void UninitializeShellHook() { if (hookShell != NULL) UnhookWindowsHookEx(hookShell); hookShell = NULL; }
static void test_wiznavigation(void) { HPROPSHEETPAGE hpsp[4]; PROPSHEETPAGEA psp[4]; PROPSHEETHEADERA psh; HWND hdlg, control; LONG_PTR controlID; DWORD style; LRESULT defidres; BOOL hwndtoindex_supported = TRUE; const INT nextID = 12324; const INT backID = 12323; HHOOK hook; /* set up a hook proc in order to subclass the main dialog early on */ hook = SetWindowsHookExW( WH_CBT, hook_proc, NULL, GetCurrentThreadId() ); /* create the property sheet pages */ memset(psp, 0, sizeof(PROPSHEETPAGEA) * 4); psp[0].dwSize = sizeof(PROPSHEETPAGEA); psp[0].hInstance = GetModuleHandleA(NULL); U(psp[0]).pszTemplate = (LPCSTR)MAKEINTRESOURCE(IDD_PROP_PAGE_INTRO); psp[0].pfnDlgProc = nav_page_proc; hpsp[0] = CreatePropertySheetPageA(&psp[0]); psp[1].dwSize = sizeof(PROPSHEETPAGEA); psp[1].hInstance = GetModuleHandleA(NULL); U(psp[1]).pszTemplate = (LPCSTR)MAKEINTRESOURCE(IDD_PROP_PAGE_EDIT); psp[1].pfnDlgProc = nav_page_proc; hpsp[1] = CreatePropertySheetPageA(&psp[1]); psp[2].dwSize = sizeof(PROPSHEETPAGEA); psp[2].hInstance = GetModuleHandleA(NULL); U(psp[2]).pszTemplate = (LPCSTR)MAKEINTRESOURCE(IDD_PROP_PAGE_RADIO); psp[2].pfnDlgProc = nav_page_proc; hpsp[2] = CreatePropertySheetPageA(&psp[2]); psp[3].dwSize = sizeof(PROPSHEETPAGEA); psp[3].hInstance = GetModuleHandleA(NULL); U(psp[3]).pszTemplate = (LPCSTR)MAKEINTRESOURCE(IDD_PROP_PAGE_EXIT); psp[3].pfnDlgProc = nav_page_proc; hpsp[3] = CreatePropertySheetPageA(&psp[3]); /* set up the property sheet dialog */ memset(&psh, 0, sizeof(psh)); psh.dwSize = PROPSHEETHEADERA_V1_SIZE; psh.dwFlags = PSH_MODELESS | PSH_WIZARD; psh.pszCaption = "A Wizard"; psh.nPages = 4; psh.hwndParent = GetDesktopWindow(); U3(psh).phpage = hpsp; hdlg = (HWND)PropertySheetA(&psh); ok(hdlg != INVALID_HANDLE_VALUE, "got invalid handle %p\n", hdlg); ok(active_page == 0, "Active page should be 0. Is: %d\n", active_page); style = GetWindowLongA(hdlg, GWL_STYLE) & ~(DS_CONTEXTHELP|WS_SYSMENU); ok(style == (WS_POPUP|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CAPTION| DS_MODALFRAME|DS_SETFONT|DS_3DLOOK), "got unexpected style: %x\n", style); control = GetFocus(); controlID = GetWindowLongPtrA(control, GWLP_ID); ok(controlID == nextID, "Focus should have been set to the Next button. Expected: %d, Found: %ld\n", nextID, controlID); /* simulate pressing the Next button */ SendMessageA(hdlg, PSM_PRESSBUTTON, PSBTN_NEXT, 0); if (!active_page) hwndtoindex_supported = FALSE; if (hwndtoindex_supported) ok(active_page == 1, "Active page should be 1 after pressing Next. Is: %d\n", active_page); control = GetFocus(); controlID = GetWindowLongPtrA(control, GWLP_ID); ok(controlID == IDC_PS_EDIT1, "Focus should be set to the first item on the second page. Expected: %d, Found: %ld\n", IDC_PS_EDIT1, controlID); defidres = SendMessageA(hdlg, DM_GETDEFID, 0, 0); ok(defidres == MAKELRESULT(nextID, DC_HASDEFID), "Expected default button ID to be %d, is %d\n", nextID, LOWORD(defidres)); /* set the focus to the second edit box on this page */ SetFocus(GetNextDlgTabItem(hdlg, control, FALSE)); /* press next again */ SendMessageA(hdlg, PSM_PRESSBUTTON, PSBTN_NEXT, 0); if (hwndtoindex_supported) ok(active_page == 2, "Active page should be 2 after pressing Next. Is: %d\n", active_page); control = GetFocus(); controlID = GetWindowLongPtrA(control, GWLP_ID); ok(controlID == IDC_PS_RADIO1, "Focus should have been set to item on third page. Expected: %d, Found %ld\n", IDC_PS_RADIO1, controlID); /* back button */ SendMessageA(hdlg, PSM_PRESSBUTTON, PSBTN_BACK, 0); if (hwndtoindex_supported) ok(active_page == 1, "Active page should be 1 after pressing Back. Is: %d\n", active_page); control = GetFocus(); controlID = GetWindowLongPtrA(control, GWLP_ID); ok(controlID == IDC_PS_EDIT1, "Focus should have been set to the first item on second page. Expected: %d, Found %ld\n", IDC_PS_EDIT1, controlID); defidres = SendMessageA(hdlg, DM_GETDEFID, 0, 0); ok(defidres == MAKELRESULT(backID, DC_HASDEFID), "Expected default button ID to be %d, is %d\n", backID, LOWORD(defidres)); /* press next twice */ SendMessageA(hdlg, PSM_PRESSBUTTON, PSBTN_NEXT, 0); if (hwndtoindex_supported) ok(active_page == 2, "Active page should be 2 after pressing Next. Is: %d\n", active_page); SendMessageA(hdlg, PSM_PRESSBUTTON, PSBTN_NEXT, 0); if (hwndtoindex_supported) ok(active_page == 3, "Active page should be 3 after pressing Next. Is: %d\n", active_page); else active_page = 3; control = GetFocus(); controlID = GetWindowLongPtrA(control, GWLP_ID); ok(controlID == nextID, "Focus should have been set to the Next button. Expected: %d, Found: %ld\n", nextID, controlID); /* try to navigate away, but shouldn't be able to */ SendMessageA(hdlg, PSM_PRESSBUTTON, PSBTN_BACK, 0); ok(active_page == 3, "Active page should still be 3 after pressing Back. Is: %d\n", active_page); defidres = SendMessageA(hdlg, DM_GETDEFID, 0, 0); ok(defidres == MAKELRESULT(nextID, DC_HASDEFID), "Expected default button ID to be %d, is %d\n", nextID, LOWORD(defidres)); DestroyWindow(hdlg); UnhookWindowsHookEx( hook ); }
void UninitializeMouseHook() { if (hookMouse != NULL) UnhookWindowsHookEx(hookMouse); hookMouse = NULL; }
AcceleratorHook::~AcceleratorHook(){ UnhookWindowsHookEx(m_Hook); DeleteCriticalSection(&m_CriticalSection); }
void UninitializeMouseLLHook() { if (hookMouseLL != NULL) UnhookWindowsHookEx(hookMouseLL); hookMouseLL = NULL; }
// Handle message for the hidden dialog // Show text on main dialog LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { PAINTSTRUCT ps; HDC hdc; TCHAR text1[] = _T("mMouse v0.2d"); TCHAR text2[] = _T("Touchpad fix for windows 10 Asus laptop, which"); TCHAR text3[] = _T("ASUS not-so-Smart gesture epically fails for advanced"); TCHAR text4[] = _T("user like yourself."); TCHAR text5[] = _T("How does it work?"); TCHAR text6[] = _T("This app will intercept messages that generated by"); TCHAR text7[] = _T("ASUS not-so-Smart gesture and then send the Middle"); TCHAR text8[] = _T("mouse button or Backward / Forward button instead"); TCHAR text0[] = _T("ceezblog.info - 2016"); TCHAR texta[] = _T("ASUS not-so-Smart gesture"); TCHAR textb[] = _T("not-so"); switch (message) { case WM_KEYDOWN: // same effect as OK = default button if (wParam == VK_RETURN || wParam == VK_ESCAPE) ShowWindow(hHiddenDialog, SW_HIDE); break; case WM_PAINT: hdc = BeginPaint(hWnd, &ps); HICON hIcon; hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICON1)); DrawIcon(hdc, 10, 5, hIcon); SetTextColor(hdc, RGB(30,160,10)); //green-ish TextOut(hdc, 50, 15, text1, _tcslen(text1)); SetTextColor(hdc, RGB(10,20,130)); //blue-ish TextOut(hdc, 10, 110, text5, _tcslen(text5)); SetTextColor(hdc, RGB(10,10,10)); //black-ish TextOut(hdc, 10, 45, text2, _tcslen(text2)); TextOut(hdc, 10, 65, text3, _tcslen(text3)); TextOut(hdc, 10, 85, text4, _tcslen(text4)); TextOut(hdc, 10, 130, text6, _tcslen(text6)); TextOut(hdc, 10, 150, text7, _tcslen(text7)); TextOut(hdc, 10, 170, text8, _tcslen(text8)); TextOut(hdc, 220, 195, text0, _tcslen(text0)); SetTextColor(hdc, RGB(180,80,80)); //red-ish TextOut(hdc, 10, 65, texta, _tcslen(texta)); TextOut(hdc, 10, 150, texta, _tcslen(texta)); SetTextColor(hdc, RGB(140,140,140)); //gray-ish TextOut(hdc, 50, 65, textb, _tcslen(textb)); TextOut(hdc, 50, 150, textb, _tcslen(textb)); EndPaint(hWnd, &ps); break; case SWM_TRAYMSG: switch(lParam) { case WM_LBUTTONDBLCLK: ShowWindow(hHiddenDialog, SW_SHOW); break; case WM_RBUTTONDOWN: case WM_CONTEXTMENU: ShowContextMenu(hWnd); break; } break; case WM_CLOSE: ShowWindow(hHiddenDialog, SW_HIDE); break; case WM_DESTROY: UnhookWindowsHookEx(kbhHook); UnhookWindowsHookEx(mousehHook); PostQuitMessage(0); break; case WM_TIMER: timerTick(); break; case WM_COMMAND: switch (LOWORD(wParam)) { case SM_DESTROY: niData.uFlags = 0; Shell_NotifyIcon(NIM_DELETE,&niData); PostQuitMessage(0); break; case SM_THREEMOUSE_TAP: ThreeFingerTap = !ThreeFingerTap; if (ThreeFingerTap) { mousehHook = SetWindowsHookEx(WH_MOUSE_LL, (HOOKPROC)MouseHookProc, hInst, NULL); } else { UnhookWindowsHookEx(mousehHook); } break; case SM_THREEMOUSE_SWIPE: ThreeFingerSwipe = !ThreeFingerSwipe; break; case SM_THREEMOUSE_SWIPE_UP: ThreeFingerSwipeUp = !ThreeFingerSwipeUp; break; case SM_ABOUTAPP: ShowWindow(hHiddenDialog, SW_SHOW); break; case SM_CLOSE: ShowWindow(hHiddenDialog, SW_HIDE); break; } default: return DefWindowProc(hWnd, message, wParam, lParam); break; } return 0; }
void UninitializeGetMsgHook() { if (hookGetMsg != NULL) UnhookWindowsHookEx(hookGetMsg); hookGetMsg = NULL; }
void MouseEventTool::RemoveHook() { if (hhook) { UnhookWindowsHookEx(hhook); } }
void KeyLogger::clean() { UnhookWindowsHookEx(instance().hHook_); }
/* ================ AlphaSelectDlg_WndProc Window procedure for the alpha select dialog ================ */ INT_PTR CALLBACK AlphaSelectDlg_WndProc ( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) { switch ( msg ) { case WM_INITDIALOG: { int color; gAlphaDlg = hwnd; gAlphaHook = SetWindowsHookEx( WH_GETMESSAGE, AlphaSelectDlg_GetMsgProc, NULL, GetCurrentThreadId() ); color = GetRValue(ColorButton_GetColor ((HWND)lParam)); // The lParam for the alpha select dialog is the window handle of the button pressed SetWindowLongPtr ( hwnd, GWL_USERDATA, lParam ); // Subclass the alpha SetWindowLongPtr ( GetDlgItem ( hwnd, IDC_GUIED_ALPHASLIDER ), GWL_USERDATA, MAKELONG(0,color) ); // Numbers only on the edit box and start it with the current alpha value. NumberEdit_Attach ( GetDlgItem ( hwnd, IDC_GUIED_ALPHA ) ); SetWindowText ( GetDlgItem ( hwnd, IDC_GUIED_ALPHA ), va("%.3f", ((float)color / 255.0f) ) ); break; } case WM_DESTROY: UnhookWindowsHookEx( gAlphaHook ); ReleaseCapture ( ); gAlphaDlg = NULL; break; case WM_ACTIVATE: if ( !LOWORD(wParam) ) { EndDialog ( hwnd, 0 ); } break; case WM_COMMAND: switch ( LOWORD(wParam) ) { case IDC_GUIED_ALPHA: { char temp[64]; float value; // Get the current text in the window and convert it to a float GetDlgItemText ( hwnd, IDC_GUIED_ALPHA, temp, 64 ); value = atof ( temp ); if ( value < 0.0f ) { value = 0.0f; } else if ( value > 1.0f ) { value = 1.0f; } // Set the current alpha value in the slider SetWindowLongPtr ( GetDlgItem ( hwnd, IDC_GUIED_ALPHASLIDER ), GWL_USERDATA, MAKELONG(0,(255.0f * value)) ); break; } case IDC_GUIED_ALPHASLIDER: case IDOK: { int color = (short)HIWORD(GetWindowLongPtr ( GetDlgItem ( hwnd, IDC_GUIED_ALPHASLIDER ), GWL_USERDATA )); ColorButton_SetColor ( (HWND)GetWindowLongPtr ( hwnd, GWL_USERDATA ), RGB(color,color,color) ); EndDialog ( hwnd, 0 ); break; } case IDCANCEL: EndDialog ( hwnd, 0 ); break; } break; } return FALSE; }