Hello! I have a piece of software called X-Mouse Button Control, and its able to intercept mouse events. The website for my mouse had this instead of a driver specifically for the mouse. In the program, I am able to "Intercept" the functions of Leftclick, Rightclick, ect, globally for windows.

My problem is, that this, and any other mouse software I have tried doesn't intercept Double click =(

Is there any way to intercept doubleclicks too? I would like to program my own little utility, so that when I am gaming I can change the doubleclick's function to a single keystroke or something.

The X-Mouse software already does this with all mouse functions except the double click.

Thanks for any help!

edit-

I found this:
http://www.codeproject.com/KB/audio-video/ReprogramYourMouse.aspx

but I can't make any sense of it =/

A double click is nothing more than two clicks in rapid succession. Your program will get two click events, not one.

[edit]Never say never! If you are using Windows hooks then you might want to read this article, especially one of the comments at the end of the article.

Are you sure? I mean, I found this:

http://msdn.microsoft.com/en-us/library/ms645606%28VS.85%29.aspx(WM_LBUTTONDBLCLK)


isn't there something like this, that I can detect globally in windows, and then intercept it, and then use keybd_event() or SendInput() to send a single keystroke?

I'm gonna keep looking up these procs from the the example I found to see If I can figure out how its working.

Oki!

INPUT Input;
	
			ZeroMemory(&Input, sizeof(INPUT));

			Input.type = INPUT_KEYBOARD;
			Input.ki.dwFlags  = KEYEVENTF_SCANCODE;
			Input.ki.wScan = MapVirtualKey(VK_NUMPAD0, 0);
			SendInput(1, &Input, sizeof(INPUT));
			
			ZeroMemory(&Input, sizeof(INPUT));

			Input.type = INPUT_KEYBOARD;
			Input.ki.dwFlags  = KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP;
			Input.ki.wScan = MapVirtualKey(VK_NUMPAD0, 0);
			SendInput(1, &Input, sizeof(INPUT));
			
			Sleep(1000);

I used the above code in a loop to successfully send global keyboard input to the OS.

Now all I have to do is intercept the double clicks somehow.

and Ancient, if I remember correctly, I asked for help a long time ago with a little 3D app I was making didn't I? I put a good deal more work into it, and actually came out with a software renderer that does clipping, texturing, and dynamic lighting at like 12FPS at 1280x800 on a 1.6Ghz cpu. I can post a few screenies or the code if your interested =D

ps: 3000polys+ too! I actually imported a mesh of a human head...pretty kewl

OK! Im almost there.

I successfully hooked my own application by doing this:

hook = SetWindowsHookEx(WH_MOUSE, proc, hInstance, GetCurrentThreadId());

but I can't get it to work for all windows, and I think it's supposed to.

I tried this:
hook = SetWindowsHookEx(WH_MOUSE, proc, GetModuleHandle(NULL), 0);

but it fails =(

is it true that I can't make this global unless it's in a DLL? because I have it in a windowed program right now..

edit- from MSDN:
WH_MOUSE Thread or global

ah hah!
"All global hook functions must be in libraries"

ugh...how do you make a DLL? lolz...

OK! I've done it.

This DLL will catch global doubleclick, and send a keystroke out.

#include "stdafx.h"
#include <windows.h>
#include <stdio.h>

HHOOK hook = 0;
bool quit = false;
LRESULT CALLBACK ClickProc(int disabled, WPARAM wparam, LPARAM lparam);
HMODULE modcpy;

BOOL APIENTRY DllMain( HMODULE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
					 )
{
	switch (ul_reason_for_call)
	{
	case DLL_PROCESS_ATTACH:
	case DLL_THREAD_ATTACH:
	case DLL_THREAD_DETACH:
	case DLL_PROCESS_DETACH:
		break;
	}
	modcpy = hModule;
	return TRUE;
}
extern "C" __declspec(dllexport) void Install()
{
    hook = SetWindowsHookEx(WH_MOUSE, ClickProc, modcpy, 0);
    MSG msg;
	Beep(660, 100);
	if(hook != 0)  //Hook Succeeded
	{
		Beep(880, 300);
	}
	else           //Hook Failed
	{
		Beep(440, 300);
	}
	while(GetMessage(&msg,0,0,0) && (quit==false))
	{
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}
}
LRESULT CALLBACK ClickProc(int disabled, WPARAM wparam, LPARAM lparam)
{
	
	if(wparam == WM_LBUTTONDBLCLK)
	{
		Beep(110, 30);
		INPUT Input;

		ZeroMemory(&Input, sizeof(INPUT));

		Input.type = INPUT_KEYBOARD;
		Input.ki.dwFlags = KEYEVENTF_SCANCODE;
		Input.ki.wScan = MapVirtualKey(VK_NUMPAD0, 0);

		SendInput(1, &Input, sizeof(INPUT));

		ZeroMemory(&Input, sizeof(INPUT));

		Input.type = INPUT_KEYBOARD;
		Input.ki.dwFlags = KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP;
		Input.ki.wScan = MapVirtualKey(VK_NUMPAD0, 0);

		SendInput(1, &Input, sizeof(INPUT));
	}
	return CallNextHookEx(hook, 0, wparam, lparam);
}

I only have one problem remaining, and that is that to send the keystroke globally, I need to have admin privilledge. It was easy before just to click "Run with administrative privilledges", but how do I do that with a DLL?!?

This question has already been answered. Start a new discussion instead.