コード例 #1
0
ファイル: windowfinder.c プロジェクト: easyfmxu/altdrag
// Hooks
LRESULT CALLBACK LowLevelMouseProc(int nCode, WPARAM wParam, LPARAM lParam) {
	if (nCode == HC_ACTION) {
		if (wParam == WM_LBUTTONDOWN && find) {
			POINT pt = ((PMSLLHOOKSTRUCT)lParam)->pt;

			// Make sure cursorwnd isn't in the way
			ShowWindow(g_hwnd, SW_HIDE);

			// Print window info
			POINT *p_pt = malloc(sizeof(pt));
			*p_pt = pt;
			CreateThread(NULL, 0, FindWnd, p_pt, 0, NULL);

			// Unhook mouse
			UnhookMouse();

			// Prevent mousedown from propagating
			return 1;
		}
		else if (wParam == WM_RBUTTONDOWN) {
			// Disable mouse
			DisableMouse();
			// Prevent mousedown from propagating
			return 1;
		}
		else if (wParam == WM_RBUTTONUP) {
			// Unhook mouse
			UnhookMouse();
			// Prevent mouseup from propagating
			return 1;
		}
	}

	return CallNextHookEx(NULL, nCode, wParam, lParam);
}
コード例 #2
0
ファイル: windowfinder.c プロジェクト: easyfmxu/altdrag
int UnhookMouse() {
	if (!mousehook) {
		// Mouse not hooked
		return 1;
	}

	// Disable
	DisableMouse();

	// Unhook
	CreateThread(NULL, 0, DelayedUnhookMouse, NULL, 0, NULL);

	// Success
	return 0;
}
コード例 #3
0
int UnhookMouse() {
  if (!mousehook) {
    // Mouse not hooked
    return 1;
  }

  // Disable
  DisableMouse();

  // Unhook
  HANDLE thread = CreateThread(NULL, 0, DelayedUnhookMouse, NULL, 0, NULL);
  CloseHandle(thread);

  // Success
  return 0;
}
コード例 #4
0
LRESULT CALLBACK LowLevelMouseProc(int nCode, WPARAM wParam, LPARAM lParam) {
  if (nCode == HC_ACTION) {
    if (wParam == WM_LBUTTONDOWN && superkill) {
      POINT pt = ((PMSLLHOOKSTRUCT)lParam)->pt;

      // Make sure the cursor window isn't in the way
      ShowWindow(g_hwnd, SW_HIDE);

      // Get hwnd
      HWND hwnd = WindowFromPoint(pt);
      if (hwnd == NULL) {
        #ifdef DEBUG
        Error(L"WindowFromPoint()", L"LowLevelMouseProc()", GetLastError());
        #endif
        return CallNextHookEx(NULL, nCode, wParam, lParam);
      }
      hwnd = GetAncestor(hwnd, GA_ROOT);

      // Kill it!
      Kill(hwnd);

      // Unhook mouse
      UnhookMouse();

      // Prevent mousedown from propagating
      return 1;
    }
    else if (wParam == WM_RBUTTONDOWN) {
      // Disable mouse
      DisableMouse();
      // Prevent mousedown from propagating
      return 1;
    }
    else if (wParam == WM_RBUTTONUP) {
      // Unhook mouse
      UnhookMouse();
      // Prevent mouseup from propagating
      return 1;
    }
  }

  return CallNextHookEx(NULL, nCode, wParam, lParam);
}