Get window handle on which mouse button was clicked
-
Hey, I'm using Windows Hook, I installed the mouse hook, system-wide and its working perfectly. Now there is a problem, I need to the get window handle on which the mouse was clicked.. How do I do that? Does the Mouse hook event passes us that information?
Top Web Hosting Providers[^] Do, or do not. There is no 'try'.
-
Hey, I'm using Windows Hook, I installed the mouse hook, system-wide and its working perfectly. Now there is a problem, I need to the get window handle on which the mouse was clicked.. How do I do that? Does the Mouse hook event passes us that information?
Top Web Hosting Providers[^] Do, or do not. There is no 'try'.
Are you using
WH_MOUSE
?"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
-
Are you using
WH_MOUSE
?"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
Well, I was using WH_MOUSE_LL earlier. I changed my code to WH_MOUSE. Now the code is:
HWND hWnd = NULL;
HWND hDesktopListWnd = NULL;hWnd = FindWindow(_T("ProgMan"), NULL);
hWnd = GetWindow(hWnd, GW_CHILD);
hDesktopListWnd = GetWindow(hWnd, GW_CHILD);threadID = GetWindowThreadProcessId(hDesktopListWnd, NULL);
hookMouse = SetWindowsHookEx(WH_MOUSE, (HOOKPROC)InternalMouseHookCallback, g_appInstance, threadID);
It installs the hook successfully, but I don't get the mouse hook events now. Basically I want to get click events when any icon on the desktop is clicked.
Top Web Hosting Providers[^] Do, or do not. There is no 'try'.
-
Well, I was using WH_MOUSE_LL earlier. I changed my code to WH_MOUSE. Now the code is:
HWND hWnd = NULL;
HWND hDesktopListWnd = NULL;hWnd = FindWindow(_T("ProgMan"), NULL);
hWnd = GetWindow(hWnd, GW_CHILD);
hDesktopListWnd = GetWindow(hWnd, GW_CHILD);threadID = GetWindowThreadProcessId(hDesktopListWnd, NULL);
hookMouse = SetWindowsHookEx(WH_MOUSE, (HOOKPROC)InternalMouseHookCallback, g_appInstance, threadID);
It installs the hook successfully, but I don't get the mouse hook events now. Basically I want to get click events when any icon on the desktop is clicked.
Top Web Hosting Providers[^] Do, or do not. There is no 'try'.
Ahmed Manzoor wrote:
Well, I was using WH_MOUSE_LL earlier.
In the
LowLevelMouseProc()
function, thelParam
is aMSLLHOOKSTRUCT
structure.Ahmed Manzoor wrote:
I changed my code to WH_MOUSE.
In the
MouseProc()
function,lParam
is aMOUSEHOOKSTRUCT
structure. Both of these structures have apt
member."Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
-
Ahmed Manzoor wrote:
Well, I was using WH_MOUSE_LL earlier.
In the
LowLevelMouseProc()
function, thelParam
is aMSLLHOOKSTRUCT
structure.Ahmed Manzoor wrote:
I changed my code to WH_MOUSE.
In the
MouseProc()
function,lParam
is aMOUSEHOOKSTRUCT
structure. Both of these structures have apt
member."Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
Hmmm. But I ran into another problem. Since I only needed Desktop's ListView (SysListView32) mouse events. I used WH_MOUSE because it can be thread specific whereas WH_MOUSE_LL can be global hook only that's why. Now when I did this change, I'm not getting any events when I click on the desktop icons or anywhere in the desktop.
hookMouse = SetWindowsHookEx(WH_MOUSE, (HOOKPROC)InternalMouseHookCallback, g_appInstance, threadID);
Here g_appInstance is the address of the DLL. threadID is the ID of the thread in which there is the SysListView32 (which is the desktop). InternalMouseHookCallback is a callback of .NET function. But now its not working. Please help me out. I'm using the Global System Hooks in .NETTop Web Hosting Providers[^] Do, or do not. There is no 'try'.
-
Hmmm. But I ran into another problem. Since I only needed Desktop's ListView (SysListView32) mouse events. I used WH_MOUSE because it can be thread specific whereas WH_MOUSE_LL can be global hook only that's why. Now when I did this change, I'm not getting any events when I click on the desktop icons or anywhere in the desktop.
hookMouse = SetWindowsHookEx(WH_MOUSE, (HOOKPROC)InternalMouseHookCallback, g_appInstance, threadID);
Here g_appInstance is the address of the DLL. threadID is the ID of the thread in which there is the SysListView32 (which is the desktop). InternalMouseHookCallback is a callback of .NET function. But now its not working. Please help me out. I'm using the Global System Hooks in .NETTop Web Hosting Providers[^] Do, or do not. There is no 'try'.
-
The first parameter is wrong.
hookMouse = SetWindowsHookEx(WH_MOUSE, (HOOKPROC)InternalMouseHookCallback, g_appInstance, threadID);
You should handle "WM_MOUSE" in the "InternalMouseHookCallback".
Top Web Hosting Providers[^] Do, or do not. There is no 'try'.
-
The first parameter is wrong.
hookMouse = SetWindowsHookEx(WH_MOUSE, (HOOKPROC)InternalMouseHookCallback, g_appInstance, threadID);
You should handle "WM_MOUSE" in the "InternalMouseHookCallback".
transoft wrote:
The first parameter is wrong.
No,
WH_MOUSE
is correct.transoft wrote:
You should handle "WM_MOUSE" in the "InternalMouseHookCallback".
:confused:
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons