Advertisement
Guest User

Zolomon

a guest
Jan 15th, 2010
590
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. '********************************************************
  2. '* WARNING!!!
  3. '* PLEASE DO NOT STOP THIS APPLICATION FROM THE VB IDE
  4. '* CLICK THE FORM'S CROSS ICON IF YOU INTEND TO CLOSE
  5. '********************************************************
  6.  
  7. Option Explicit
  8.  
  9. '* Decraling the mouse tracer object using WithEvents so that the events
  10. '* can be traced
  11. Private WithEvents MyMouseHunter As MouseHunter.Tracer
  12. Attribute MyMouseHunter.VB_VarHelpID = -1
  13.  
  14. Private Sub Form_Load()
  15.     '* EventStealingInfo will help to steal any particular mouse event you want.
  16.    '* This will help you to grab the event just within your application
  17.    '* And will not pass the event to the system
  18.    Dim EventStealingInfo As EventThief
  19.    
  20.     lblWindowTitle.Caption = ""
  21.     lblEvents.Caption = ""
  22.    
  23.     Set MyMouseHunter = New MouseHunter.Tracer
  24.    
  25.     '* Selecting the particular mouse events that you want to steal
  26.    '* from the system
  27.    '* Here, you'll steal the Mouse's Right Button's UP & Down events
  28.    '* From the System, so you'll see your right button of the Mouse
  29.    '* Is not working in anywhere in the System, But your application
  30.    '* is still tracing the events!!
  31.    With EventStealingInfo
  32.         .RIGHT_DOWN = True
  33.         .RIGHT_UP = True
  34.     End With
  35.    
  36.     '* Passing the EventStealingInfo to the tracer class
  37.    MyMouseHunter.StealMouseEvents = EventStealingInfo
  38.     '* Start tracing the system wide mouse events
  39.    MyMouseHunter.StartMouseTracing Me.hWnd
  40.    
  41. End Sub
  42.  
  43. Private Sub Form_Unload(Cancel As Integer)
  44.     '* make sure the system wide mouse tracing is stopped after the application
  45.    '* is closed
  46.    MyMouseHunter.StopMouseTracing
  47. End Sub
  48.  
  49. '* Tracking the system wide mouse events
  50. Private Sub MyMouseHunter_OnSystemMouseMove()
  51.     '* Choose anything you want to trace when your mouse moves
  52.    '* You can trace the X and Y coordinate of your mouse position in the window
  53.    '* Or the Window handle (hWnd) of the window under your mouse
  54.    '* Or the Window title (Caption) under your mouse.
  55.    
  56.     'lblWindowTitle.Caption = MyMouseHunter.CoordinateX & "," & MyMouseHunter.CoordinateY
  57.    'lblWindowTitle.Caption = MyMouseHunter.WindowHandleUnderMouse
  58.    lblWindowTitle.Caption = MyMouseHunter.WindowTextUnderMouse
  59.    
  60.     lblEvents.Caption = "Moving..."
  61. End Sub
  62.  
  63. Private Sub MyMouseHunter_OnSystemMouseLeftDown()
  64.     lblEvents.Caption = "Left Down"
  65. End Sub
  66.  
  67. Private Sub MyMouseHunter_OnSystemMouseLeftUp()
  68.     lblEvents.Caption = "Left Up"
  69. End Sub
  70.  
  71. Private Sub MyMouseHunter_OnSystemMouseRightDown()
  72.     lblEvents.Caption = "Right Down"
  73. End Sub
  74.  
  75. Private Sub MyMouseHunter_OnSystemMouseRightUp()
  76.     lblEvents.Caption = "Right Up"
  77. End Sub
  78.  
  79. Private Sub MyMouseHunter_OnSystemMouseMiddleDown()
  80.     lblEvents.Caption = "Middle Down"
  81. End Sub
  82.  
  83. Private Sub MyMouseHunter_OnSystemMouseMiddleUp()
  84.     lblEvents.Caption = "Middle Up"
  85. End Sub
  86.  
  87. Private Sub MyMouseHunter_OnSystemMouseWheel()
  88.     lblEvents.Caption = "Wheel..."
  89. End Sub
  90.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement