Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[SOLVED] Rebind some Mous Keys.
#1
Hello, I try to rebind some keys and loop the command but I don't know how to make that.

Macro Macro
Code:
Copy      Help
int w=win("Window Name" "Class Name")
int hwnd=val(_command)

\Hold the Left Mouse Button to click fast (X) times until I release the Mouse Button
if RealGetKeyState(VK_LBUTTON)=0
;;;rep(14)lef
;;;key r
;;;ret

\Set Windows Mouse Button 4 as On/Off Switch for the Loop
???

\Set Windows Mouse Button 5 Media Player Play/Resume
???

Hope someone can help me a bit with this because I am new to QM.

... and yes I know many new Mouses or Keyboards can make this (Razer Series, Cooler Master Series etc.) but I don't have this stuff.
Windows 8.1 x64 | Quick Macros v2.4.x.x
#2
I don't recommend using macros that change mouse button behavior.

You'll need 1 function and 1 macro. Don't need a trigger for the macro. Use any trigger for the function.

Function mouse_left_macro_on_off
Trigger #X1 0x8     Help - how to add the trigger to the macro
Code:
Copy      Help
;\
function nCode wParam MSLLHOOKSTRUCT&h

;This function runs when you press X1 (4-th) mouse button.
;It toggles mouse left button behavior - run or don't run macro "multi_click".
;When macro can run, shows tray icon.
;Macro will not run with Ctrl etc. Also if QM or macro disabled. To disable/enable QM, press Ctrl+Alt+Shift+D.
;Macro will stop when mouse left button released.


if getopt(nargs)=0 ;;if this function runs not as a hook function
,if getopt(nthreads)>1 ;;if thread running, end it and exit
,,shutdown -6 0 "mouse_left_macro_on_off"
,,ret
,
,;run thread: add tray icon, set mouse hook, and wait
,AddTrayIcon "$qm$\mouse.ico" "Macro ''multi_click'' will run on mouse left button down.[]To disable it, click mouse X1 button or Ctrl_click this icon."
,int hh=SetWindowsHookEx(WH_MOUSE_LL &mouse_left_macro_on_off _hinst 0)
,MessageLoop
,UnhookWindowsHookEx hh
,ret

;---- this code runs on each mouse event while the thread is running -----

if(h.flags&LLMHF_INJECTED) goto nNH ;;ignore macro-generated mouse events

int+ g_multi_click ;;global variable used to stop macro "multi_click"
sel wParam
,case WM_LBUTTONDOWN
,if(dis&2 or dis("multi_click") or GetMod) goto nNH ;;don't run macro if QM or macro is disabled, or if Ctrl etc
,
,;Here you can add code to run this macro only in certain conditions, for example if certain window is active. Example:
,;int w=win; if(!w or !wintest(w "Name" "Class")) goto nNH
,
,g_multi_click=1
,mac "multi_click" ;;run macro
,ret 1 ;;eat this event
,
,case WM_LBUTTONUP
,if g_multi_click
,,g_multi_click=0 ;;stop macro
,,ret 1 ;;eat this event

;nNH
ret CallNextHookEx(0 nCode wParam &h)

Macro multi_click
Code:
Copy      Help
spe 20 ;;set speed, ie number of ms to wait after lef
rep
,int+ g_multi_click; if(!g_multi_click) break ;;this will stop the macro on left button up. Don't remove.
,;out "click" ;;debug
,lef

;note: this macro must be named "multi_click". If want to rename, also change macro name in "mouse_left_macro_on_off".

_____________________________

For the 5-th button macro use mouse X2 button trigger.
#3
Thanks for the replay and the help.

I have one more questions how does the loop work for letting the mouse click until I release the Mouse Button.

I don't understand this line:
Code:
Copy      Help
ifk-((1)) break ;;end loop if left button released. However this does not work if this macro clicks.
Windows 8.1 x64 | Quick Macros v2.4.x.x
#4
In that code would be difficult to know when user releases mouse button. I replaced the code. Now don't need a filter function. Just 1 function and 1 macro.
#5
Thanks Gintaras your Macro helped me allot. Big Grin
Windows 8.1 x64 | Quick Macros v2.4.x.x


Forum Jump:


Users browsing this thread: 1 Guest(s)