How to give an action to a key but also keep the key's own action?

Get help with using AutoHotkey and its commands and hotkeys
Javirolus333
Posts: 3
Joined: 07 Jun 2019, 16:29

How to give an action to a key but also keep the key's own action?

07 Jun 2019, 16:44

Hi, I want my script to write "e" when I left click the mouse. So I wrote this code:

LButton::
Send e
return

But I also want to be able to click. I want it so when I press the left click, the computer writes "e" but also keeps the mouse's action. I tried doing this:

LButton::
Send LButton
Send e
return

But it doesn't work properly. Please help!
gregster
Posts: 2503
Joined: 30 Sep 2013, 06:48

Re: How to give an action to a key but also keep the key's own action?

07 Jun 2019, 17:21

Try this:

Code: Select all

Lbutton::
Send {LButton}
Send e
return
Or

Code: Select all

~Lbutton up::
Send e
return
gregster
Posts: 2503
Joined: 30 Sep 2013, 06:48

Re: How to give an action to a key but also keep the key's own action?

07 Jun 2019, 18:14

Xtra wrote:
07 Jun 2019, 18:08
or

Code: Select all

~LButton::e
Oh yeah, it works (mostly). I actually had tested it, but thought it wouldn't work, because it didn't work in geekdude's CodeQuicktester editor window... same with ~LButton::Send e. The other two work there :think: Good to know!
Javirolus333
Posts: 3
Joined: 07 Jun 2019, 16:29

Re: How to give an action to a key but also keep the key's own action?

08 Jun 2019, 03:34

Well, those options work, but a little weird. For example, I can't open a file by double clicking it. I also select the "e" that I write and write another ones so they dissapear
gregster
Posts: 2503
Joined: 30 Sep 2013, 06:48

Re: How to give an action to a key but also keep the key's own action?

08 Jun 2019, 20:41

Javirolus333 wrote:
08 Jun 2019, 03:34
Well, those options work, but a little weird. For example, I can't open a file by double clicking it.
I see nothing weird. If you want to open files with this, why would you send an e after every click? If you type letters in file explorer, it will try to focus the next file/folder that starts with this letter... this seems to happen here, too, although not reliably (probably a timing issue, because left click and e are pressed very (too?) fast after each other so that file explorer won't necessarily process it correctly).
But if I double-click fast while a remap is active like ~LButton::e, I still can open files and folders here.
I also select the "e" that I write and write another ones so they dissapear
I would also expect this behaviour: Double-clicking on text selects/highlights it and if you press a key (in this case "e"), the selection will be replaced with it. Again, there might be a timing issue with the processing of consecutive clicks and e key presses and the time allowed for a double-click (depending on the program you use this in - my tests indicate that not all programs will react in the same way to this remap).

Perhaps you try to explain what this is for to get better suited answers.
Javirolus333
Posts: 3
Joined: 07 Jun 2019, 16:29

Re: How to give an action to a key but also keep the key's own action?

09 Jun 2019, 02:44

Ok, you are right. In game it works well so I'm satisfied with the results. (I wanted it to play Reventure and be able to interact with objets with the mouse). Thank you for helping me!

Return to “Ask For Help”

Who is online

Users browsing this forum: aifritz, bennybroseph, Google [Bot], kronos90, maleko48, Micahs, momo007, Mushie, tmplinshi and 229 guests