Assign Right-Click for Left Double-Click

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
AHKJeff
Posts: 91
Joined: 07 Apr 2016, 11:54

Assign Right-Click for Left Double-Click

Post by AHKJeff » 25 Jan 2022, 18:51

The app I am working with is Stickies v10.1a.

I would like to assign a Right-Click of the mouse to take the place of
a mouse Left Double-Click.

This would occur when I placed the cursor over the header of a stickie.

The stickies are all in different locations on the screen.
The only constants that I could see for each header using WindowSpy
were:

ahk_class ZhornStickyNote
ahk_exe stickies.exe
ahk_pid 6540
ClassNN: RICHEDIT50W1

A little complication with the assignment is that currently I have
a right-click menu system set up with AHK.
Any time I right-click my mouse a menu pops up with various selections.

So this new assignment would have to override the right-click that I have set up.

Thanks!

User avatar
mikeyww
Posts: 26601
Joined: 09 Sep 2014, 18:38

Re: Assign Right-Click for Left Double-Click

Post by mikeyww » 25 Jan 2022, 19:12

Code: Select all

#If over("ZhornStickyNote")
RButton::Click, 2
#If

over(class, control := "") {
 MouseGetPos,,, hWnd, overControl
 WinGetClass, overClass, ahk_id %hWnd%
 Return overClass = class && overControl = control
}

AHKJeff
Posts: 91
Joined: 07 Apr 2016, 11:54

Re: Assign Right-Click for Left Double-Click

Post by AHKJeff » 25 Jan 2022, 21:45

mikeyww wrote:
25 Jan 2022, 19:12

Code: Select all

#If over("ZhornStickyNote")
RButton::Click, 2
#If

over(class, control := "") {
 MouseGetPos,,, hWnd, overControl
 WinGetClass, overClass, ahk_id %hWnd%
 Return overClass = class && overControl = control
}
Thanks very much mikey for your help!

We're almost there but not quite.

Here's what happened.
Bear in mind I have two main AHK files:

AHK.ahk and Menu.ahk
For a long time I used to run both at startup.
Then a few months ago I learned that was not the efficient way to go.

So basically AHK.ahk (which has a lot of code)
calls Menu.ahk.

You didn't specify where to place your code so first I tried it
inside AHK.ahk

This is what happened.
A right-click had the desired effect inside Stickies (yes!)
BUT a split second later it also triggered the Menu from Menu.ahk.

So I thought maybe I had put the code in the wrong .ahk file.
I went back and moved the code to my Menu.ahk file.

Now when I right-click anywhere (inside Stickies or in any app)
I get this error:

Error in #include file ".....Menu.ahk":
Menu does not exist

Specifically: MyMenu

%A_ThisMenu%
366 Return
--> 384 Menu,MyMenu,Show
384: Return
393: Suspend, Toggle

So it seems like I need to tweak one thing to get it to work properly.
I put your code at the top of each .ahk file (trying one at a time).

User avatar
mikeyww
Posts: 26601
Joined: 09 Sep 2014, 18:38

Re: Assign Right-Click for Left Double-Click

Post by mikeyww » 25 Jan 2022, 22:33

Before incorporating into your script(s), close your other scripts, and run this one by itself. See if it works. That tells you if you are starting with a working script.

If you use #Include, I don't think you will want to replicate this script inside both of the others, because it would lead to duplicated code.

AHKJeff
Posts: 91
Joined: 07 Apr 2016, 11:54

Re: Assign Right-Click for Left Double-Click

Post by AHKJeff » 25 Jan 2022, 23:01

mikeyww wrote:
25 Jan 2022, 22:33
Before incorporating into your script(s), close your other scripts, and run this one by itself. See if it works. That tells you if you are starting with a working script.

If you use #Include, I don't think you will want to replicate this script inside both of the others, because it would lead to duplicated code.
Thanks mikey.

OK I did as advised. Closed both of my other scripts and ran your code.
It works perfectly!

So now, given what I said in my earlier post, where do you think I should put your code exactly,
so that my Menu.ahk code will work and not interfere with the right-click in your code.

Recall that my Menu.ahk code starts when I normally right-click.

This is the code near the top of my AHK.ahk script that calls Menu.ahk:

Code: Select all

;----- Common settings -----          
#SingleInstance force          
StringCaseSense On          
AutoTrim OFF          
Process Priority,,High          
SetWinDelay 0          
SetKeyDelay -1          
SetBatchLines -1          

;----- Included scripts -----          
GoSub MenuSetup          

MenuSetup:          
#Include d:\Computer\Software\AHK\Menu.ahk   

User avatar
mikeyww
Posts: 26601
Joined: 09 Sep 2014, 18:38

Re: Assign Right-Click for Left Double-Click

Post by mikeyww » 25 Jan 2022, 23:05

Without seeing the script, one can only guess. You could try putting it at the bottom.

AHKJeff
Posts: 91
Joined: 07 Apr 2016, 11:54

Re: Assign Right-Click for Left Double-Click

Post by AHKJeff » 26 Jan 2022, 00:40

mikeyww wrote:
25 Jan 2022, 23:05
Without seeing the script, one can only guess. You could try putting it at the bottom.
Thanks mikey.

I just tried putting the code at the very end of AHK.ahk (my main .ahk script)
and I have the same problem as when I put it right near the top.

Your code works, but a split second later my Menu comes up.

Does your code have an over-ride for my regular right-click?
Do you think I should be putting your code in my
AHK.ahk file or my Menu.ahk file?

I could post the scripts if necessary.
AHK.ahk is a big file and Menu.ahk a bit smaller.

AHKJeff
Posts: 91
Joined: 07 Apr 2016, 11:54

Re: Assign Right-Click for Left Double-Click

Post by AHKJeff » 27 Jan 2022, 00:02

I copped out.

I kept trying to get it to work but couldn't solve the problem.

So I have assigned ^MButton to fire the Menu.ahk.

Post Reply

Return to “Ask for Help (v1)”