 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
dr_dov Guest
|
Posted: Mon Mar 15, 2010 7:30 am Post subject: Universal RSI Hotkeys needed |
|
|
Hello, after trying to target some specific actions using multiple hotkeys (see below), I have come to the realization that what I really need are 3 hotkeys, one for each mouse button:
F1 would serve as LClick toggle
F2 would serve as MClick toggle
F3 would serve as RClick toggle
I need them to:
(1)-Press and Release once to hold said mouse button down (F1 does LClick Down for example)
(2)-The click gets released in one of two ways: you press and release the button again (F1) OR click and release the actual mouse button itself (LButton)
(3)-***THE TRICKY PART*** any modifier keys which are depressed when this hotkey is pressed would also be depressed until (2, above) happens: so Ctrl+Alt+F2 (and release all of them) would hold down Ctrl and Alt and MClick, until F2 or MButton is pressed and released.
Hitting Ctrl or Alt before F2 or MButton is pressed the second time should NOT release the modifiers, and maybe to be clear should warn the user in a toolTip (you pressed Ctrl but you are in the middle of a click action... press F2 or MButton to release the click)
Currently I am using some pretty newbie keys (like 9 of them to produce lone mouse clicks and common modifer mouse clicks I use), a la:
| Code: |
F1:: ; LClick toggle
pressed := !pressed
If pressed {
Click down
}
Else
Click up
Exit |
and
| Code: |
*F4:: ;shift + LClick toggle...
pressed := !pressed
If pressed
Send {Shift Down}{Click down}
Else
Send {Shift Up}{Click Up}
Return |
This kinda works, but it takes up a LOT of keys to capture all the possible combos, AND its easy to get tripped up, like if I hit the actual shift key after the *F5 example, I have to hit F5 twice to get it to work again...
Sorry I am a newbie but would VERY much appreciate a solution as it would greatly help my RSI issues |
|
| Back to top |
|
 |
MacroGeek
Joined: 08 Mar 2010 Posts: 4 Location: Toronto
|
Posted: Mon Mar 15, 2010 5:00 pm Post subject: |
|
|
I'm not sure what you are suggesting is a good solution for dealing with RSI, although RSI encompasses so broad a range of conditions that it's hard to know without more information. Based on what you are trying to achieve, I assume that you are having problems clicking mouse buttons. And if I am right, my questions are:
How is your workstation configured? (Be specific.)
Do you find it painful or difficult to type?
Are you a touch typist?
Where is the pain?
There are many directions this can go, depending on your answers. For example, if typing is not a problem, you are a touch typist, and you experience pain in your neck and shoulders...
I would begin by addressing the set up of your workstation, and your work habits. If I were going to use macros, I would choose activations that you can press without looking at the keyboard. (Most people need to glance at the keyboard to hit function keys.) |
|
| Back to top |
|
 |
dr_dov Guest
|
Posted: Tue Mar 16, 2010 3:18 am Post subject: |
|
|
I work in a software package (Maya) that requires constant drag and drop actions with all mouse buttons, and often requires modifiers to be held down during the drags/drops.
I have a good workstation and ergo support, take breaks, stretch etc. -- hotkeys are definitely the solution I am after.
It is the holding down of mouse buttons and modifiers for long periods that I need to get out of my workflow, which unfortunately is required in the tools I use.
What I have above is really close, just looking to do it in less keys. |
|
| Back to top |
|
 |
[VxE]
Joined: 07 Oct 2006 Posts: 3254 Location: Simi Valley, CA
|
Posted: Tue Mar 16, 2010 6:10 am Post subject: |
|
|
This is as far as I got. As commented, I couldn't get the modifier hotkeys to block the key releases from the system, so the code doesn't work for the modifiers, though it works for the mouse buttons.
| Code: | #UseHook
SendMode, Input
Modifiers = Ctrl|Alt|Shift
; Set up OSD
Gui, +ToolWindow -Caption +AlwaysOnTop
Gui, Margin, 0, 0
Gui, Font, S10 C002040, Arial
Gui, Add, Progress, BackgroundFFFFFF w87 h25 vbk1
Gui, Add, Progress, x+0 y0 BackgroundFFFFFF w87 h25 vbk2
Gui, Add, Progress, x+0 y0 BackgroundFFFFFF w87 h25 vbk3
Gui, Add, Text, x2 y2 w85 h21 center vtm1 BackgroundTrans, F1
Gui, Add, Text, x+2 y2 w85 h21 center vtm2 BackgroundTrans, F2
Gui, Add, Text, x+2 y2 w85 h21 center vtm3 BackgroundTrans, F3
Gui, Show, y0 NoActivate, [VxE]'s inactive mouse/modifier assistant.
OnMessage( WM_LBUTTONDOWN := 0x201, "WM_LBUTTONDOWN" )
Return
GuiEscape:
Exitapp
#IfWinExist, [VxE]'s inactive mouse/modifier assistant.
; These hotkeys are only active if the script is in 'inactive' mode
*F1:: ; press F1 to hold down the left mouse button
*F2:: ; press F2 to hold down the middle button
*F3:: ; press F3 to hold down the right button
KeyWait, % SubStr( A_ThisHotkey, 2 )
Btn := SubStr( A_ThisHotkey, 0 ) ; either 1, 2, or 3
GuiControl, +BackGroundFCBA2C, bk%Btn%
%Btn%State := 1
Click, % SubStr( "LMR", Btn, 1 ) . " Down"
Prompt := ""
Loop, Parse, Modifiers, |
If GetKeyState( A_LoopField )
Prompt .= "+" A_LoopField
StringTrimLeft, Prompt, Prompt, 1
Prompt := StrLen( Prompt ) ? Prompt : "_ _ _"
GuiControl,, tm%Btn%, %Prompt%
Gui, Show, NoActivate, [VxE]'s active mouse/modifier assistant.
Return
#IfWinExist, [VxE]'s active mouse/modifier assistant.
; All these hotkeys are context sensitive based on the gui window's title
*F1:: ; press F1 again to release the left button
*F2:: ; when the script is no longer holding a button,
*F3:: ; normal mouse function is restored
KeyWait, % SubStr( A_ThisHotkey, 2 )
Btn := SubStr( A_ThisHotkey, 0 ) ; either 1, 2, or 3
%Btn%State := !%Btn%State
Click, % SubStr( "LMR", Btn, 1 ) . ( %Btn%State ? " Down" : " Up" )
GuiControl,, tm%btn%, % ( %Btn%State ? Prompt : "F" Btn )
GuiControl, % "+BackGround" . ( %Btn%State ? "FCBA2C" : "FFFFFF" ), bk%Btn%
If ( 3 = !1State + !2State + !3State )
{
Loop, 3
GuiControl,, tm%A_Index%, F%A_Index%
Gui, Show, NoActivate, [VxE]'s inactive mouse/modifier assistant.
}
Return
; Block normal mouse clicks, these work just fine
*LButton::
*MButton::
*RButton::
*LButton Up::
*MButton Up::
*RButton Up::
; These SHOULD block the modifier key PRESSES AND RELEASES
; but I couldn't get it to work in my tests.
*LCtrl::
*LAlt::
*LShift::
*LCtrl Up::
*LAlt Up::
*LShift Up::
*RCtrl::
*RAlt::
*RShift::
*RCtrl Up::
*RAlt Up::
*RShift Up::
Return
#IfWinActive
#esc::Exitapp
WM_LBUTTONDOWN( wparam, lparam, msg, hwnd ) {
Gui, %A_Gui%:+LastFound
PostMessage, 0xA1, 2
} |
_________________ Ternary (a ? b : c) guide TSV Table Manipulation Library
Post code inside [code][/code] tags! |
|
| Back to top |
|
 |
nick
Joined: 24 Aug 2005 Posts: 549 Location: Berlin / Germany
|
Posted: Tue Mar 16, 2010 9:54 am Post subject: |
|
|
| Code: | #NoEnv
SetTitleMatchMode, 2
WinTitle := "PSPad" ; "Maya window's title"
GroupAdd, Maya, %WinTitle%
Action := False
F_LButton := "F1"
F_MButton := "F2"
F_RButton := "F3"
Btn_F1 := "LButton"
Btn_F2 := "MButton"
Btn_F3 := "RButton"
Key_F1 := False
Key_F2 := False
Key_F3 := False
Key_Alt := False
Key_Ctrl := False
Key_Shift := False
SetMouseHotkeys("Off")
SetTimer, KeyState, 500
Return
; ------------------------------------------------------------------------------
KeyState:
TT := ""
If WinActive("ahk_group Maya") && (Action = True) {
TT .= GetKeyState("Alt") ? "Alt`n" : ""
TT .= GetKeyState("Ctrl") ? "Ctrl`n" : ""
TT .= GetKeyState("Shift") ? "Shift`n" : ""
TT .= GetKeyState("LButton") ? "LButton`n" : ""
TT .= GetKeyState("MButton") ? "MButton`n" : ""
TT .= GetKeyState("RButton") ? "RButton`n" : ""
}
ToolTip, %TT%
Return
; ------------------------------------------------------------------------------
SetMouseHotkeys(State) {
Global
Hotkey, IfWinActive, ahk_group Maya
Loop, 3 {
Hotkey, % "*" . Btn_F%A_Index%, %State%
Hotkey, % "*" . Btn_F%A_index% . " Up", %State%
}
Hotkey, IfWinActive
}
#IfWinActive ahk_group Maya
; ------------------------------------------------------------------------------
*F1::
*F2::
*F3::
HK := SubStr(A_ThisHotkey, 2)
SI := ""
If (Key_%HK%) {
SI .= Key_Alt ? "{Alt Up}" : ""
SI .= Key_Ctrl ? "{Ctrl Up}" : ""
SI .= Key_Shift ? "{Shift Up}" : ""
SI .= "{" . Btn_%HK% . " Up}"
SendInput %SI%
Key_Alt := Key_Ctrl := Key_Shift := Key_%HK% := Action := False
SetMouseHotkeys("Off")
; MsgBox, %SI%
}
Else {
Key_Alt := GetKeyState("Alt")
Key_Ctrl := GetKeyState("Ctrl")
Key_Shift := GetKeyState("Shift")
KeyWait, %HK%
KeyWait, Alt
KeyWait, Ctrl
KeyWait, Shift
SI .= Key_Alt ? "{Alt Down}" : ""
SI .= Key_Ctrl ? "{Ctrl Down}" : ""
SI .= Key_Shift ? "{Shift Down}" : ""
SI .= "{" . Btn_%HK% . " Down}"
SendInput %SI%
Key_%HK% := Action := True
SetMouseHotkeys("On")
; MsgBox, %SI%
}
Return
; ------------------------------------------------------------------------------
*LButton::
*MButton::
*RButton::
Return
; ------------------------------------------------------------------------------
*LButton Up::
*MButton Up::
*RButton Up::
HK := SubStr(A_ThisHotkey, 2, 7)
FK := F_%HK%
SI := ""
If (FK) {
SI .= Key_Alt ? "{Alt Up}" : ""
SI .= Key_Ctrl ? "{Ctrl Up}" : ""
SI .= Key_Shift ? "{Shift Up}" : ""
SI .= "{" . HK . " Up}"
SendInput %SI%
Key_Alt := Key_Ctrl := Key_Shift := Key_%FK% := Action := False
SetMouseHotkeys("Off")
; MsgBox, %SI%
}
Return
#IfWinActive | * Maybe? _________________ nick  |
|
| Back to top |
|
 |
dr_dov Guest
|
Posted: Wed Mar 17, 2010 6:13 am Post subject: Thank you Nick! |
|
|
This is great thank you for putting time into it
I am having trouble though, which is if I do a Shift+LMB click normally (without the script) -- it makes a selection and keeps it when I release the Shift and Click.
With the script, it makes the selection just fine, but when I click the F1 key the second time it somehow releases (ditches the selection)
I wonder if there is an extra key down or key up action which does not allow the selection to be maintained |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|