.net - How to detect a double-click outside of vb.net form -
setup environment:
i'm using visual studio 2010 , writing code in vb.net (with .net framework 4).
my goal:
- use
shell("c:\myprogram.exe", appwinstyle.normalfocus)
open new application - with new application open active window, recognize when user double clicks
if active window vb.net form, it's simple recognize double click event so:
private sub button2_doubleclick(......) handles button2.doubleclick
end sub
this code works recognize single left click:
this form1.vb
public class form1 private withevents mousedetector mousedetector private sub form1_load(byval sender object, byval e system.eventargs) handles me.load mousedetector = new mousedetector end sub private sub mousedetector_mouseleftbuttonclick(byval sender object, byval e system.windows.forms.mouseeventargs) handles mousedetector.mouseleftbuttonclick 'left click occurred msgbox("left click") end sub end class
here's enum in mousedetector.vb
private enum mousemessages wm_leftbuttondown = 513 wm_leftbuttonup = 514 wm_leftdblclick = 515 wm_rightbuttondown = 516 wm_rightbuttonup = 517 wm_rightdblclick = 518 end enum
and here's function in mousedetector.vb recognizes single click
private function mousehookproc(byval ncode integer, byval wparam integer, byval lparam intptr) integer if ncode < 0 return callnexthookex(mousehookid, ncode, wparam, lparam) end if dim mousedata mousehookstruct = marshal.ptrtostructure(lparam, gettype(mousehookstruct)) select case wparam case mousemessages.wm_leftbuttonup raiseevent mouseleftbuttonclick(nothing, new mouseeventargs(mousebuttons.left, 1, mousedata.pt.x, mousedata.pt.y, 0)) end select return callnexthookex(mousehookid, ncode, wparam, lparam) end function
how possible recognize double click?
obviously there isn't mousebuttons.leftdoubleclick
, that's i'm after.
would willing give suggestion on how go doing this? i'd appreciate it.
if @ codeplex globalmousekeyhook project, handling mousedouble click events globally both left , right mouse buttons.
this library attaches windows global hooks, tracks keyboard , mouse clicks , movement , raises common .net events keyeventargs , mouseeventargs, can retrieve information need:
mouse coordinates
mouse buttons clicked
mouse wheel scrolls
key presses , releases
special key states
Comments
Post a Comment