Jump to content

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

Make a long mouse-click register as a separate key


  • Please log in to reply
30 replies to this topic
ZIGS
  • Members
  • 24 posts
  • Last active: Jun 01 2016 07:11 PM
  • Joined: 26 Aug 2012
What I need is a way to make 1 mouse click to act as a key and a long mouse-click (same button) act as another key. For example:

left-click = r
long left-click = f

Basically I want to be able to set 2 separate keys to the same mouse button. Is there a way to do this? Thanks

Alpha Bravo
  • Members
  • 1687 posts
  • Last active: Nov 07 2015 03:06 PM
  • Joined: 01 Sep 2011
Hello ZIGS, welcome to the forum
~LButton::
KeyWait, Lbutton
Send, % A_TimeSinceThisHotkey > 500 ? "f":"r" ; change 500 to suit your needs
return


ZIGS
  • Members
  • 24 posts
  • Last active: Jun 01 2016 07:11 PM
  • Joined: 26 Aug 2012
Ok thanks, that's almost what I need. Is there a way to make it so it triggers while I still have the mouse button pressed instead of having to release it to register the key?

Alpha Bravo
  • Members
  • 1687 posts
  • Last active: Nov 07 2015 03:06 PM
  • Joined: 01 Sep 2011
~LButton::

SetTimer, check, -200

return



check:

if GetKeyState("Lbutton", "P")

{

	Send,f

	return

}

Send, r

return


ZIGS
  • Members
  • 24 posts
  • Last active: Jun 01 2016 07:11 PM
  • Joined: 26 Aug 2012
Humm, it doesn't seem to be working (the long click I mean). In fact, forget about the normal click, I can just use LButton::r. I just need a scrip for the long button. Maybe if I tell you what I need it for it might be easier to understand.
It's to use with a game. You have 2 attacks, light and heavy and I want to be able to use them both with just one mouse button. So say I have (in the game options) the light attack mapped to r and the heavy attack to f. I use LButton::r so clicking the left button results in a light attack and then I need a script so if I long-click the same mouse button, it results in a heavy attack. Sorry if this sounds confusing and for being a pain in the ass :)

bettyj
  • Members
  • 40 posts
  • Last active: Apr 03 2016 12:42 PM
  • Joined: 22 Aug 2012
That script worked for me redo your copy pasta and try again. There was one issue though the mouse click was still sent along with the hotkey that may be your problem if it isn't working with the game. test it out in notepad before you launch the game.

Buckaroo
  • Members
  • 29 posts
  • Last active: Aug 25 2012 03:57 PM
  • Joined: 25 Aug 2012
~LButton::

KeyWait,LButton,T0.5

Send % ErrorLevel ? "f":"r"

return



bettyj
  • Members
  • 40 posts
  • Last active: Apr 03 2016 12:42 PM
  • Joined: 22 Aug 2012
If you take off the ~ at the begining of the script it may work better with the game, but there is the issue with not being able to click anymore so you may want to do this.
LButton::
{
SetTimer, check, -200
return

check:
KeyWait, Lbutton,)
{
   if ErrorLevel
	Send,f
   else
	Send, r
return
}
}
Numpad0::
click

that way you can still use the 0 on the number pad to click the mouse.

ZIGS
  • Members
  • 24 posts
  • Last active: Jun 01 2016 07:11 PM
  • Joined: 26 Aug 2012
None of those work. In fact, I just realized it's impossible because when I click the button, that click registers immediately and the scrip can't possibly know I don't want it to register, I want to only register after the button is held down a while. So yeah, good idea in theory but it can't be done. The only way this would work is if the game itself was programmed to do it. Thanks anyway guys

EDIT: ok, I've been thinking and what about this: what if you guys made the normal click (light attack, key R) register not when the button clicks, but when the button "unclicks"? That way you could set the heavy attack (key R) the same way but make it register with a small delay, although this one(the long click) would have to register with the mouse button still pressed, like I pointed out earlier. Is this doable at all?

Buckaroo
  • Members
  • 29 posts
  • Last active: Aug 25 2012 03:57 PM
  • Joined: 25 Aug 2012
LButton::

KeyWait,LButton,T0.5

Send % ErrorLevel ? "f":"r"

return



; with bettyj's idea

NumpadIns::LButton

Numpad0::LButton



ZIGS
  • Members
  • 24 posts
  • Last active: Jun 01 2016 07:11 PM
  • Joined: 26 Aug 2012
Buckaroo, that one works in notepad but doesn't work in the game. I think it's due to the reason I pointed out in my previous post's edit. But if it works in notepad, shouldn't it also work in the game? I mean it's the same thing right? Now I'm confused :(

Buckaroo
  • Members
  • 29 posts
  • Last active: Aug 25 2012 03:57 PM
  • Joined: 25 Aug 2012

Buckaroo, that one works in notepad but doesn't work in the game. I think it's due to the reason I pointed out in my previous post's edit. But if it works in notepad, shouldn't it also work in the game? I mean it's the same thing right? Now I'm confused :(

Try each of these at the top of your script after any # commands/directives such as #InstallKeybdHook

; Uncomment them first, Input is your best bet.
SendMode Input
;SendMode Play
;SendMode Event
;SendMode InputThenPlay

OR use SendInput or SendPlay in place of Send in the code that works in notepad, may then perhaps work in the game.

Oh, and, run the script as an administrator if the need be...

ZIGS
  • Members
  • 24 posts
  • Last active: Jun 01 2016 07:11 PM
  • Joined: 26 Aug 2012
I'm running it as administrator. Tried all of those. SendMode ImputThenPlay at the top and replacing Send with SentImput gave some sort of error and didn't let me save the scrip. None of the other options worked. Though I'm not sure I've done it right because I have no idea what # commands/directives and #InstallKeybdHook is :(

Buckaroo
  • Members
  • 29 posts
  • Last active: Aug 25 2012 03:57 PM
  • Joined: 25 Aug 2012
Sorry, I'm confusing you there. What game is it? I'll get it working. Pm me if you want to keep the title private.

SendInput not SendImput by the way.

LButton::
KeyWait,LButton,T0.5
SendInput % ErrorLevel ? "f":"r"
return

NumpadIns::LButton
Numpad0::LButton


ZIGS
  • Members
  • 24 posts
  • Last active: Jun 01 2016 07:11 PM
  • Joined: 26 Aug 2012
Tried that one, didn't work in the game. The game is Dark Souls (and now cue everyone and their mother telling me to play with a controller:))