Jump to content

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

Right click + Left click action



  • Please log in to reply
9 replies to this topic
th4drummer
  • Members
  • 28 posts
  • Last active: Jun 04 2015 09:36 PM
  • Joined: 02 Feb 2013

I tried to figure out how to bind a specific action to right click + left click to no avail.

 

What I want is something in the lines of:

Rbutton & Lbutton

Send a

Mouseclick, left

Return

 

So, if I press rbutton and lbutton together, it would send "a" and a left mouseclick. The thing is that I also want right click to work normally, so it wouldn't be just a modifier.

 

I went through different options but haven't found one that works.

 

Thanks in advance



robert_ilbrink
  • Members
  • 561 posts
  • Last active: Mar 10 2015 08:36 PM
  • Joined: 05 May 2012

Once you use combination keys, the first key used looses its original function unless you restore it afterwards.

 

RButton & LButton::

Send, a

Mouseclick,, left

Return

 

RButton::RButton ; restore the original RButton function



th4drummer
  • Members
  • 28 posts
  • Last active: Jun 04 2015 09:36 PM
  • Joined: 02 Feb 2013

I know. That's why I couldn't make it work.

 

Also, I tried your suggestion but something still seems to be wrong.

 

I appreciate your input, though.



robert_ilbrink
  • Members
  • 561 posts
  • Last active: Mar 10 2015 08:36 PM
  • Joined: 05 May 2012

I saw one little mistake with the click, so i reduced to to just Click, whic is the default for left click anyway. This works on my (Windows 7x64) machine...

RButton & LButton::
  Send, a
  Click
Return
 
RButton::RButton ; restore the original RButton function


th4drummer
  • Members
  • 28 posts
  • Last active: Jun 04 2015 09:36 PM
  • Joined: 02 Feb 2013

OK, so, at first I tried it exactly like that and the script seemed to work until I tried right clicking, which didn't work.

 

I also tried including Rbutton::Rbutton before Return and it only got worse.

 

Also, to get the full picture, I tested this in a separate script, but my goal is to integrate this piece into my rather complex script file that contains all the scripts I use, and I wouldn't want this to cause any issues.

 

As a detail, I use Win XP x86, but that shouldn't be a problem.

 

After further tests, I figure out that I got the best result with this:

~RButton & LButton::
  Send, a
  Click
Return

With some research, this works for allowing normal use of the Rbutton, as well as the combination R+L, but it can only send the "a" key and not the click afterwards (tried various methods, mouseclick, send lbutton, etc.).

 

It also right clicks at the beginning, but for my purposes that's a bit of an annoyance that I can live with if the rest of the script works as planned.



robert_ilbrink
  • Members
  • 561 posts
  • Last active: Mar 10 2015 08:36 PM
  • Joined: 05 May 2012

What kind of AutoHotKey version do you use? These anomalies are weird. XP Should be no problem, ran this on XP a long time ago.



th4drummer
  • Members
  • 28 posts
  • Last active: Jun 04 2015 09:36 PM
  • Joined: 02 Feb 2013

At the moment, 1.1.09.02.

 

edit: I just updated to the latest version, but looking at the changelogs it shouldn't make a difference.

 

After testing it, it still behaves the same.

RButton & LButton::
Send, a
Click
Return

Works perfectly, but right click just doesn't work. I put RButton::RButton at the bottom, after the Return, exactly like you did, I tried putting it before return, and as I previously said, then the first part doesn't work either. If I put a ~ before, it right clicks at the beginning of the script, presses "a" and doesn't left click at the end.

 

So, basically, now all I need is a way to make right click work if I just click it in addition to the first part of the script and it's exactly what I need.


Edited by th4drummer, 18 June 2013 - 04:02 PM.


robert_ilbrink
  • Members
  • 561 posts
  • Last active: Mar 10 2015 08:36 PM
  • Joined: 05 May 2012

That is pretty recent. Can't explain why my script is giving you so much trouble. It runs fine on Windows 7x64 with ahk v1.1.10.01. Do you have multiple scripts running? (one might use the same hotkeys and in that case the last (re)started script will win that hotkey). That doe NOT explain why Send, a is executed and Click is NOT. Have you tried adding a SoundBeep, 500, 500 under the click command. This way you can see if the script fails or not. One other thing with regard to Click. In some applications/situations (Chrome e.g.) click did work one day and not the other it drove me nuts. I played around with sendInput, {Click} v.s. Send, {Click}, but also with longer clicks like:

Click, {Left Down}

Sleep, 100

Click, {Left Up}

 

And even with:

 

Send, {vk01sc000 Down}
Sleep, 500
Send, {vk01sc000 Up}
 
VKxxSCxxx are the left mouse key scan codes on my system (use the keypress viewer in ahk)


th4drummer
  • Members
  • 28 posts
  • Last active: Jun 04 2015 09:36 PM
  • Joined: 02 Feb 2013

I added SoundPlay, %A_WinDir%\Media\ding.wav after click. SoundBeep doesn't work for me seeing as I "unplugged" the PC speaker.

 

Also, I don't have other scripts using the same hotkey. I have one big ahk file where all the little scripts are, but 90%+ are specific to certain applications. I tried this particular script in a separate file, even with the main one closed, just to make sure though.

 

So, to make things clear. Using the normal script (the one I quoted earlier) works exactly like it needs to. The problem is that right click is retained as a modifier and won't work normally. Adding Rbutton::Rubbon at the end doesn't work.

 

That's the part that is malfunctioning, not the click within the script. The click within the script doesn't work only when I add ~ at the beginning of the hotkey string, so it would look like ~RButton & LButton::. Then, it ignores the fact that Rbutton is a modifier, clicking normally at the beginning of the script, upon me pressing just right click, before also left-clicking, and it ends up also ignoring the click within the script (I could hear the ding though).

 

 

Just a thought, what about an if command of some sort? I know it's more complicated, but as long as it works...

 

Something in the lines of Rubutton down:: if Lbutton is pressed, then press a and left click, else, Rbutton up and click normally. I don't exactly know how this would work, but it sorta makes sense in my mind.



th4drummer
  • Members
  • 28 posts
  • Last active: Jun 04 2015 09:36 PM
  • Joined: 02 Feb 2013
✓  Best Answer

While waiting I decided to also try the Gaming section, since this actually pertains to a certain game action I wanted and HotKeyIt gave me a solution.

Basically, it works like:

$RButton::
  KeyWait,LButton,DT0.1
  If !ErrorLevel {
    KeyWait,RButton
    Send a{Click}
    return
  }
  Send {RButton Down}
  KeyWait,RButton
  Send {RButton Up}
Return

DT can be set to a slower time, but I preferred it to 0.1.

 

Thanks HotKeyIt.

 

Link to the other topic where this solution was presented - http://www.autohotke...ey/#entry596054