Jump to content

Set Mouse as Hotkey


Recommended Posts

Hi guys.

I used to have a driver before for my GIGABYTE mouse, which could set which button does what.

Now I changed to a new mouse, new brand, a noname ACME mouse.

This has no driver, no utility, nothing.

I'd like to write such a thing for myself, however I'm facing troubles. For redefining the meaning of any of the buttons, I have to block the real signal and send a custom one or something similar.

Basically the same as what HotkeySet does.

Simple _IsPressed won't do it's job, since it will only detect if it's currently pressed. At the moment I can't see any ways to do this task. Has anyone an idea how should I start, what to do?

Link to comment
Share on other sites

Well,basically I want to assign different events to some of the mouse buttons. Let me show an example. Here is the driver I had:

screen_basic.jpg

I don't care about DPI and further settings, I just want to for example press left mouse click when I'm pressing the side (4th or 5th) buttons.

I hope you can understand now :)

Link to comment
Share on other sites

#include <MouseTrapEvent.au3>
Global $hLastHotKeyPressed = ""
Global $hLastHotKeyType = ""

_HotKeySet("{RDCLICK}", "_ModifyLeft")
_HotKeySet("^e", "_Exit")
While 1
 Sleep(10)
WEnd

Func _ModifyLeft() ; user defined function for hot key
 UpDateHotKeys()
 If StringInStr(StringUpper($hLastHotKeyPressed), "RDCLICK") Then
  ;do some magic here
  ConsoleWrite("Last Hotkey pressed: " & $hLastHotKeyPressed & @LF)
 EndIf
EndFunc   ;==>_ModifyLeft

Func _HotKeySet($hotkey, $function, $block = 1)
 If $function = "" Or IsString($function) = False Then Return SetError(1)
 If StringInStr(StringUpper($hotkey), "CLICK") Then
  Dim $mouseHotKey ; local
  $mouseHotKey = $hotkey
  $mouseHotKey = StringReplace($mouseHotKey, "{", "")
  $mouseHotKey = StringReplace($mouseHotKey, "}", "")
  If $function = "" Then
   _MouseTrapEvent($mouseHotKey)
  Else
   _MouseTrapEvent($mouseHotKey, $function, $block)
  EndIf
 Else
  HotKeySet($hotkey, $function)
 EndIf
EndFunc   ;==>_HotKeySet
 
Func UpDateHotKeys() ;
 Dim $hLastMouseEventPressed
 $hLastMouseEventPressed = __MouseTrapEvent_getLastMouseEventPressed()
 If $hLastMouseEventPressed <> "" Then
  $hLastHotKeyPressed = "{" & $hLastMouseEventPressed & "}"
  $hLastHotKeyType = "Mouse"
 Else
  $hLastHotKeyPressed = @HotKeyPressed
  $hLastHotKeyType = "Keyboard"
 EndIf
EndFunc   ;==>UpDateHotKeys
Func _Exit()
 Exit
EndFunc   ;==>_Exit

For the interface of that pic you will have to deal with it by yourself ;)

MouseTrapEvent.au3

Edited by AutID
Link to comment
Share on other sites

Another way is using MrCreatoR's MouseOnEvent UDF. This however is a bit different but it has more features.

#include "..\MouseOnEvent.au3"
Global $iPrimary_DblClk_Event = 0
Global $iSecondary_DblClk_Event = 0
HotKeySet("{ESC}", "_Quit")
_MouseSetOnEvent($MOUSE_SECONDARYDBLCLK_EVENT, '_DblClk_Event')
While 1
 _ModifyDoubleRightToLeft()
 Sleep(10)
WEnd
Func _DblClk_Event($iEvent)
 Switch $iEvent
  Case $MOUSE_PRIMARYDBLCLK_EVENT
   $iPrimary_DblClk_Event = 1
  Case $MOUSE_SECONDARYDBLCLK_EVENT
   $iSecondary_DblClk_Event = 1
 EndSwitch
EndFunc
Func _Quit()
 Exit
EndFunc
Func _ModifyDoubleRightToLeft()
 If $iSecondary_DblClk_Event Then
  $iSecondary_DblClk_Event = 0
  ConsoleWrite("Left clicked!" & @LF)
  MouseClick("left")
 EndIf
EndFunc

 

Link to original post: '?do=embed' frameborder='0' data-embedContent>>

MouseOnEvent.au3

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...