Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Simple keyboard -> Mouse click script.


  • Please log in to reply
1 reply to this topic
deletemeafteraweek
  • Members
  • 1 posts
  • Last active: Jun 11 2013 04:14 PM
  • Joined: 08 Jun 2013
I could not find my answer anywhere and after a few hours of reading through lots and lots of obscure documentation, trying while() and if() loops I have created this simplest of scripts. Too bad it's not documented nowhere obvious that you can do keypress macros and keyrelease macros by simply putting "Key::Function" and "Key up::Function"
 
Here's my script. It maps F1 to left mouse button and F2 to right mouse button. Hold the key to drag stuff. Press it to click. Great for people like me who got a comfortable logitech mouse with a broken key and are too cheap to buy a new replacement.
; Recommended for performance
#NoEnv

; Better and more reliable
SendMode Input

; Press the right mouse button unless it's already pressed.
F2::
 if ( not GetKeyState("RButton" , "P") )
  Click down right
return

; Release the mouse button when the key is released.
F2 Up::Click up right

F1::
 if ( not GetKeyState("LButton" , "P") )
  Click down
return

F1 Up::Click up


CorrnDog
  • Members
  • 1 posts
  • Last active: Oct 19 2013 02:40 PM
  • Joined: 04 Jul 2013

WOW. That's excellent, deletemeafteraweek (you still with us?). I've been using AutoIT for about five years and have written (and been using for a long time) a keypress macro program...but it was more complex and didn't have the functionality of holding the key down equals holding the mouse button down. Now, I'm sure AutoIT could do it elegantly enough (my programming skills aren't all that great), but yours is a *really* simple program and it works *really* well. I'm inclined to learn AHK now. 

 

Thanks for sharing that script.