[Mono-list] Low level mouse hook via SetWindowsHookEx
cstockton
chrisstocktonaz at gmail.com
Sat Jul 4 16:40:15 EDT 2009
Hello,
I am porting a app I want to distribute for free in Linux. It clicks for
users with RSI (Repetitive Stress Syndrome).
Part of the application is monitoring the movement of the mouse and sending
global clicks, this is window independent. I achieved this in C# under
windows using :
[code]
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError =
true)]
private static extern IntPtr SetWindowsHookEx(int idHook,
LowLevelProc lpfn, IntPtr hMod, uint dwThreadId);
... (more imports)
[DllImport("user32.dll")]
static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint
dwData, int dwExtraInfo);
// later I
SetWindowsHookEx(WH_MOUSE_LL, proc,
GetModuleHandle(curModule.ModuleName), 0);
[/code]
The app is complete and runs great in windows, it builds okay in MonoDevelop
but I get a exception when running :
Unhandled Exception: System.EntryPointNotFoundException: GetModuleHandle
at (wrapper managed-to-native) Clicker.Form1:GetModuleHandle (string)
at Clicker.Form1.SetMouseHook (Clicker.LowLevelProc proc) [0x00014] in ..
Form1.cs:173
at Clicker.Form1..ctor () [0x004d2] in .. Form1.cs:510
at (wrapper remoting-invoke-with-check) Clicker.Form1:.ctor ()
at Clicker.Program.Main () [0x00015] in .. Program.cs:18
I am assuming I am missing some key steps in those unmanaged invokes, but am
unsure (after much much much googling) how to achieve this. If I need to
scrap the hooking into the user32/kernel32 and do the alternative in X11
libraries of some sort I am okay with that.
-Chris
--
View this message in context: http://www.nabble.com/Low-level-mouse-hook-via-SetWindowsHookEx-tp24337660p24337660.html
Sent from the Mono - General mailing list archive at Nabble.com.
More information about the Mono-list
mailing list