Jump to content
Catalyst78

Better Gaming Mouse Binds/Hotkeys G502

Recommended Posts

Catalyst78

I want to be able to press one of the many extra buttons on my mouse to execute an autoit script function. To do this I have bound weird key combinations to to each button that would otherwise never be pressed, like shift+alt+ctrl+/ (see linked image and the following code.)

Unfortunately this has a few annoying side effects, such as interfering with whatever I'm doing or one of the modifier keys occasionally getting 'stuck' down.

I have been compling each version of this script directly into my startup folder(win7) and have been using it for years. But surely there is a better way of doing this, thanks for help in advance.

http://prnt.sc/dquyar

;^ Ctrl    ! Alt    + Shift    # Win
HotKeySet("!{/}",  "Back_Btn")  ; spamclickoff
HotKeySet("+!^{.}", "Forw_Btn") ; ___/Speakers/HeadPhones
HotkeySet("+!^{,}", "Midd_Btn") ;MouseLock/InputStuff

HotkeySet("+!^{\}", "Gs_Back_Btn") ;ScreenBrightness 100/60/20
HotkeySet("+!^{=}", "Gs_Forw_Btn") ;Vlc/CloseVlc Recent/Touhou
HotkeySet("+!^{-}", "Gs_Midd_Btn") ;ScreenSwaper ToMain/ToSecond

HotkeySet("+!^{]}", "Gs_M3")      ;VlcTogglePlay
HotkeySet("+!^{[}", "Gs_MW_Left") ;F11/!Enter

 

Share this post


Link to post
Share on other sites
InunoTaishou

The G502 (I have it) has other buttons you can bind those keys to so you wouldn't have to use modifiers. Play/Pause, Stop, Next Track, Previous Track, Volume Up, Volume Down, and Mute would probably be better.

I haven't tested it but maybe a low level keyboard hook, instead of hotkey, might get rid of the side effects. Just check in the help file _WinAPI_SetWindowsHookEx to get you started, if you wanted to go this route (much more difficult and will use more system resources).

Share this post


Link to post
Share on other sites
Catalyst78

 

20 minutes ago, InunoTaishou said:

The G502 (I have it) has other buttons you can bind those keys to so you wouldn't have to use modifiers. Play/Pause, Stop, Next Track, Previous Track, Volume Up, Volume Down, and Mute would probably be better.

I already use most of these (for their intended purpose) on the non G-shift side.

 

20 minutes ago, InunoTaishou said:

I haven't tested it but maybe a low level keyboard hook, instead of hotkey, might get rid of the side effects. Just check in the help file _WinAPI_SetWindowsHookEx to get you started, if you wanted to go this route (much more difficult and will use more system resources).

I have G9 bound to start a script that locks mouse movement. I wrote it quite some time ago as part of my mouse script. Here it is if you were wondering:

#include <WinAPI.au3>

Opt("TrayIconHide", 1)

Global $locked = 1
Global $pStub_MouseProc = DllCallbackRegister ("_Mouse_Handler", "int", "int;ptr;ptr")
Global $hHookMouse = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, DllCallbackGetPtr($pStub_MouseProc), _WinAPI_GetModuleHandle(0), 0)

while $locked
   sleep(100)
WEnd

DllCallbackFree($pStub_MouseProc)
_WinAPI_UnhookWindowsHookEx($hHookMouse)
Exit

Func _Mouse_Handler($nCode, $wParam, $lParam)
   local $info
   If $nCode < 0 Or $locked = 0 Then Return _WinAPI_CallNextHookEx($hHookMouse, $nCode, $wParam, $lParam)
   If $wParam = 0x00000200 Then Return 1

   $locked = 0
EndFunc

 

But yeah, I'm pretty sure buttons getting stuck down is the fault of the mouse. Some of the functions in my script do different things when a button is held down or pressed multiple times. Using these is where it happens most often.

Edited by Catalyst78
typo & mistakes in code, also didn't actually finish writing post <.< hurr durr

Share this post


Link to post
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

  • Similar Content

    • guinness
      By guinness
      Right now the script will exit immediately if I don't pause it somehow (obvious of course).
      I was  curious on people's opinions of how they do it or what option they prefer below? Thanks
      Option 1 (I prefer)
      #include <MsgBoxConstants.au3> HotKeySet('^!p', SomeFunc) ProcessWaitClose(@AutoItPID) Func SomeFunc() MsgBox($MB_SYSTEMMODAL, "Title", "This message box will timeout after 10 seconds or select the OK button.", 10) EndFunc Option 2 (in the help file)
      #include <MsgBoxConstants.au3> HotKeySet('^!p', SomeFunc) While Sleep(100) WEnd Func SomeFunc() MsgBox($MB_SYSTEMMODAL, "Title", "This message box will timeout after 10 seconds or select the OK button.", 10) EndFunc Option 3
      #include <MsgBoxConstants.au3> HotKeySet('^!p', SomeFunc) While 1 GUIGetMsg() ; Use the internal sleep WEnd Func SomeFunc() MsgBox($MB_SYSTEMMODAL, "Title", "This message box will timeout after 10 seconds or select the OK button.", 10) EndFunc  
    • leomoon
      By leomoon
      Hello,
      I'm trying to write a hotkey program and I know exactly how to do it but it will be hard coded and the user won't be able to edit it.
      HotKeySet("{ESC}", "HotKeyPressed") HotKeySet("^!d", "HotKeyPressed") HotKeySet("^+x", "HotKeyPressed") While 1 Sleep(500) WEnd Func HotKeyPressed() Switch @HotKeyPressed Case "{ESC}" Exit Case "^!d" ShellExecute("D:\Docs") Case "^+x" ShellExecute("D:\Docs\My Portables\Burner\AnyBurn\AnyBurn.exe") EndSwitch EndFunc I want the program to read a file that has hotkeys on odd lines and paths on even lines but I don't see how the program will load into itself.
      Is it even possible?
      Thanks.
    • AndreyS
      By AndreyS
      Dear developers and creators of the language, please explain to me why when pressing the combination Crtl + Shift + C from the 5th or the 10th time "sticks / sinks" Ctrl or Shift? And then you need to press Ctrl or Shift again to reset their triggering. I only need to use hot keys like in the example!
      The code is a small example. Its essence is that when a user in the editor selects any number and presses a combination, then it increases by 1. 
      Dim $x HotKeySet("+^c","Calc") While 1 Sleep(10000) WEnd Func Calc() Send("^c") Sleep(50) $x=ClipGet()+1 ClipPut($x) Send("^v") EndFunc I thought that in my program some kind of glitch was searching for a reason for a long time. And it turned out that apparently somehow the work of some functions used in the example is not compatible. 
      Tell me, please, what is the problem?
    • kokoilie
      By kokoilie
      I'm making a program that has a combo control in a gui and back in win7 when the window was focused the scroll wheel could be used to scroll through it's contents, now i'm using win10 and i have to put the mouse on that control to scroll up and down.
      Since now the scroll wheel works depending on where the mouse is, is there a way to make it no matter where on the gui the pointer is?
      Also if the only way to do it is some complex hotkey functions will it work with pressing space to toggle a checkbox?
      If you need to see what i have so far let me know and i'll copy it here.
    • StudioMaker
      By StudioMaker
      Hey anyone knows how i can have a inputbox that is connected to an HotKeySet? Like if u put in like "a" in the inputbox it sets the hotkey to "a"?
       
×