Osman Vielma
Osman Vielma

Reputation: 61

ahk click down mouse button while holding down a key on keyboard

I want to move the mouse with one hand while with the other making the button clicks with the keyboard.

The difficult part was to instruct AutoHotKey to hold down the mouse button while holding down the key on the keyboard. So you be able to click and drag.

It makes the clicks with the 1, 2 and 3 keys at the keyboard, in inverse order (left click with the 3, as preserving left click with the index finger but of the other hand, trying to mirror the workings inside the brains hemisphere, or something)

This script is activated while ScrollLock is ON (finally some good use for that beautiful and neglected key, activating all sorts of keyboard shortcuts for AutoHotKey)

Upvotes: 0

Views: 1996

Answers (1)

Osman Vielma
Osman Vielma

Reputation: 61

#NoTrayIcon

if (GetKeyState("ScrollLock", "T")) ; check state for icon
 {
 Menu, Tray, Icon
 return
 }
 else
 {
 Menu, Tray, NoIcon
 return
 }

ScrollLock:: ; From state 0 to state 1 (Activated)
 Send, {ScrollLock}
 Menu, Tray, Icon
 SoundBeep, 261.43, 150 ; low tone
 SoundBeep, 329.63, 150 ; hight tone
return

#If GetKeyState("ScrollLock", "T") ; State 1 (Activated)

 3::
 While GetKeyState("3", "P")
 {
 Click, Left, Down
 KeyWait 3
 Click, Left, Up
 }
 Return

 2::
 While GetKeyState("2", "P")
 {
 Click, Middle, Down
 KeyWait 2
 Click, Middle, Up
 }
 Return

 1::
 While GetKeyState("1", "P")
 {
 Click, Right, Down
 KeyWait 1
 Click, Right, Up
 }
 Return

 ScrollLock:: ; From State 1 to State 0 (Deactivated)
  Send, {ScrollLock}
  Menu, Tray, NoIcon
  SoundBeep, 329.63, 150 ; hight tone
  SoundBeep, 261.43, 150 ; low tone
 return

 ^SPACE:: ; Always on Top Functionality 
  Winset, Alwaysontop, , A
 return

#If

Script: Keyboard-Clicks.ahk

It gets activated with the ScrollLock key.

It shows the a tray icon when activated. It hides the icon when is deactivate it with ScrollLock key again.

Key combination Ctrl+Space for AlwaysOnTop the currently active window.

It makes a distinctive sound beep for activated and de-activated state.

Compiled with an icon from Font Awesome of a hand.

Font-Awesome-left-hand-paper Icon PNG with Transparency https://i.sstatic.net/wYuUj.png

Upvotes: 1

Related Questions