How to detect that button was right clicked in a script

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
Horst
Posts: 1419
Joined: 24 Jan 2021 12:27
Location: Germany

How to detect that button was right clicked in a script

Post by Horst »

The subject says it all.
I have assigned the same script to the left and right click of a button.
In the script I want to check if there was a right click ?
Windows 11 Home, Version 26H2 (OS Build 26300.10075)
Portable x64 XYplorer (Actual version, including betas)
Display settings 1920 x 1080 Scale 100%
Everything 1.5.0.1424b (x64), Everything Toolbar 3.5, Listary Pro 7.1.0.47 beta

highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: How to detect that button was right clicked in a script

Post by highend »

<get trigger mousebtn>...
One of my scripts helped you out? Please donate via Paypal

klownboy
Posts: 4481
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.8737 at 100% 2560x1440

Re: How to detect that button was right clicked in a script

Post by klownboy »

highend beat me to it, but a bit more on it...

Code: Select all

// determine if the action was initiated via CTB (or not like a User Defined Command) if you want the same script to be used for UDC you can make a distinction
// you can also use the newer Get('Trigger', 'context') to determine how the script was invoked see Help - Scripting Commands Reference - "get"
	$inCTB = Get('Trigger', 'CTBIndex') > 0;
// determine if a modifier key is held down while clicking in case you want a different action if a modifier is held down
	$mod = get("shift");
	if ($inCTB) {
  //determine if the click is right "2" or left "1" - see Help - Scripting Commands Reference - "get"
	$trigger = get("trigger", "mousebtn");
	}
	else {
		$trigger = "0";
	}
   if ($trigger == "2") {
     state your Right click actions here;
   }
   if ($trigger == "1") {
     state your left click actions here;
   }
Last edited by klownboy on 14 Mar 2021 16:44, edited 1 time in total.

Horst
Posts: 1419
Joined: 24 Jan 2021 12:27
Location: Germany

Re: How to detect that button was right clicked in a script

Post by Horst »

highend wrote: ↑14 Mar 2021 15:43 <get trigger mousebtn>...
Thanks again for your always helpfull tips.
I made a script which uses the new Everything content search function.
The normal Everything search on left click and the content search on right click of a button.
Windows 11 Home, Version 26H2 (OS Build 26300.10075)
Portable x64 XYplorer (Actual version, including betas)
Display settings 1920 x 1080 Scale 100%
Everything 1.5.0.1424b (x64), Everything Toolbar 3.5, Listary Pro 7.1.0.47 beta

Post Reply