<get "shift"|"Trigger"> on submenus?

Features wanted...
Filehero
Posts: 2645
Joined: 27 Feb 2012 18:50
Location: Windows 10 Pro x64

<get "shift"|"Trigger"> on submenus?

Post by Filehero »

Hi Don,

would be possible to return thise values also upon clicking on submenu entries? For example, with popupnested() a lot of "left/right" decisions can be handled on the submenu levels of a CTB.

Thanks,
Filehero

klownboy
Posts: 4141
Joined: 28 Feb 2012 19:27

Re: <get "shift"|"Trigger"> on submenus?

Post by klownboy »

I like that idea not only for popupnested but normal menus as well. You could then properly build menus which utilize XYplorer button actions for left and right click of the button and for your own menu items, a different action for left and right click. :tup:
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440

admin
Site Admin
Posts: 60602
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: <get "shift"|"Trigger"> on submenus?

Post by admin »

Got a sample code showing at what exact point you which information?

klownboy
Posts: 4141
Joined: 28 Feb 2012 19:27

Re: <get "shift"|"Trigger"> on submenus?

Post by klownboy »

Filehero should be answering this especially for SC popupnested, but my input would be for any menu system where you could have a separate action assigned for the normal left click or the right click. So for example, if you had a menu and and one item was one of XYplorer's built in buttons like Touchscreen mode, then the standard left click would give you touchscreen and the right would yield the associated right click actions. But it wouldn't be limited to that simplified use. One could also assign both the left and right click to anything, like loading a script or running a small script. A current example using get("shift") to detect mod keys.

Code: Select all

"Ccleaner|<xyicons>\ccleaner02.ico" open "D:\Tools\Ccleaner\Ccleaner.exe"; 
"CFA[none] or CTB[ctrl] or CKS[shift]|:cks" $mod = get("shift");
	if ($mod == "1") {#602;}
	elseif($mod == "2") {#603;}
	else {#604;}
So similar to the CFA[n]... example above you could instead have something like...

Code: Select all

"CKS|:cks" $trig = get("shift"|"Trigger"); //detect whether a left or right click was accomplished on the menu item
	if ($trig == "1") {#602;}     // standard left click accomplished on menu item
	else {button "cks", 2}        // $trig would be '2' right click was done so the right click of the CKS button is performed
A more elaborate example would be for use in a script like Vertical Toolbar here viewtopic.php?f=7&t=13494&hilit=vertica ... ar#p119162 You can make a truly powerful script menu being able to accomplish all the separate left and right click actions on the menu regardless if they are built-in XYplorer buttons or your own CTBs. But, of course it wouldn't be limited to these examples. Thanks.
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440

Filehero
Posts: 2645
Joined: 27 Feb 2012 18:50
Location: Windows 10 Pro x64

Re: <get "shift"|"Trigger"> on submenus?

Post by Filehero »

Hi Don,

for me the wish encompasses all situations where Script generated menus are involved.

Context: I have implemented a configurable menu system (atomic actions/commands which can be freely combined in a config file or at script runtime) which can be used everywhere scripts can be applied. Besides getting rid of the need to update different scripts everything a menu setup is going to be changed I want to streamline my custom actions into one or two CTBs at max. Each CTB will have a left and right click root menu.
But now I realised once the CTB Has been opened the left/right click event fetchable via get is already consumed and I cannot assign a left/right logic to the menu/submenu entries any more.

In my simple view on things I thought it would be simply a matter of „recording“ all mouse clicks during a script scope. This way I would always retrieve the correct mouse down event. Hmmm, better: the first click after popupnested has been called?

Example: the first RMB runs the menu script assigned to RMB, then with popupnested the very next mouse down event on the menu is either the left or right click on the menu entry (or, third, ending the script scope by clicking somewhere outside the menu). With access to that information I could assign each menu entry two logic paths as well.

I hope my description isn‘t too confusing.

admin
Site Admin
Posts: 60602
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: <get "shift"|"Trigger"> on submenus?

Post by admin »

OK, check next beta.

klownboy
Posts: 4141
Joined: 28 Feb 2012 19:27

Re: <get "shift"|"Trigger"> on submenus?

Post by klownboy »

I think maybe between the posts above we might have confused what we were really looking for in a <get "shift"|"trigger"> change. We wanted to be able to detect whether left or right click of the mouse was accomplished on the menu item. So the syntax would be something like:

Syntax: <get trigger [mode=Left_Right_Trigger]>

Sorry for the confusion. We could already determine if a 'shift' key was held down in a menu $mod = get("shift"); and take different actions depending on which mod key was held down, but your change would allow it to live on in the session which is great.
Thanks Don.
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440

Filehero
Posts: 2645
Joined: 27 Feb 2012 18:50
Location: Windows 10 Pro x64

Re: <get "shift"|"Trigger"> on submenus?

Post by Filehero »

Hi Ken,
klownboy wrote:We could already determine if a 'shift' key was held down in a menu $mod = get("shift"); and take different actions depending on which mod key was held down, but your change would allow it to live on in the session which is great.
not over here. I could do this on the CTB but not any submenu. Now I can, thanks Don. :D
klownboy wrote:Syntax: <get trigger [mode=Left_Right_Trigger]>
Under certain conditions I prefer to use modifiers, but I do see why others want to stick with the LMB/RMB pattern.

admin
Site Admin
Posts: 60602
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: <get "shift"|"Trigger"> on submenus?

Post by admin »

klownboy wrote:I think maybe between the posts above we might have confused what we were really looking for in a <get "shift"|"trigger"> change. We wanted to be able to detect whether left or right click of the mouse was accomplished on the menu item...
AFAIK you cannot trigger a menu command by right-click in menus made by SC popupmenu() or in multi-script menus.

klownboy
Posts: 4141
Joined: 28 Feb 2012 19:27

Re: <get "shift"|"Trigger"> on submenus?

Post by klownboy »

Bummer! Oh it may not be possible. Too bad. It would have been really super to develop multi-script menus or use SC popupmenu() which can distinguish between a left and right click on a menu item. I thought it might be possible since highend in his UMC script senses long presses with both the left and right mouse click using AHK though maybe not within a menu. :cry: :)
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440

klownboy
Posts: 4141
Joined: 28 Feb 2012 19:27

Re: <get "shift"|"Trigger"> on submenus?

Post by klownboy »

HI again Don, in doing a bit of searching I found a possible solution in the AHK forum. It's uses in AHK, however, the solution uses a Windows API which you could also use. From the AHK forum thread https://autohotkey.com/board/topic/2385 ... ntry154396
"The windows api function GetGUIThreadInfo can be used to get information about a window and its thread. If no window is specified, the foreground window is used. The GuiThreadInfo struct contains a variable flags. In this flag bit 4 is set if the thread is showing a menu."

So based on that information another member modified the function slightly to come up with the following to detect a right-click on a menu. https://autohotkey.com/board/topic/8606 ... in-a-menu/ It works great. The "Hi..." message comes up when I right click on a menu item in a XYplorer multi-script.

Code: Select all

#If (DetectContextMenu() = 1)
RButton::
	MsgBox Hi, you just right-clicked in a menu
Return
#If

DetectContextMenu() ; based on closeContextMenu() by Stefaan - http://www.autohotkey.com/community/viewtopic.php?p=163183#p163183
{
	   
	GuiThreadInfoSize = 48
	VarSetCapacity(GuiThreadInfo, 48)
	NumPut(GuiThreadInfoSize, GuiThreadInfo, 0)
	if not DllCall("GetGUIThreadInfo", uint, 0, str, GuiThreadInfo)
	{
		MsgBox GetGUIThreadInfo() indicated a failure.
		Return
	}
	; GuiThreadInfo contains a DWORD flags at byte 4
	; Bit 4 of this flag is set if the thread is in menu mode. GUI_INMENUMODE = 0x4
	If (NumGet(GuiThreadInfo, 4) & 0x4)
		Return 1 ; we've found a context menu
	Else
		Return 0
}
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440

admin
Site Admin
Posts: 60602
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: <get "shift"|"Trigger"> on submenus?

Post by admin »

Sorry, no further plans here.

I can make menus react on right-button, but this has some internal disadvantages and it's only on button-up anyway, so I would have to detect which button was upped on the menu, which require subclassing etc etc. Big box of trouble.

EDIT: replaced "key" by "button" ... :biggrin:

klownboy
Posts: 4141
Joined: 28 Feb 2012 19:27

Re: <get "shift"|"Trigger"> on submenus?

Post by klownboy »

Hi Don, no problem. I may ask highend (our resident XYplorer AND AHK expert) for some help in getting that AHK function to work along side of an XYplorer script. I've been able to load the function in my start-up AHK script and it works (i.e., I get the message when right clicking an XY menu item), but I'm not sure how to incorporate the right click detection (i.e., AHK detects the right click so a Right-click action is performed instead of the left click action). Maybe setting a variable and directing it to XYplorer via SendFunction(MessagetoXYplorer) that we've used before.

Hi, highend are you around?
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440

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

Re: <get "shift"|"Trigger"> on submenus?

Post by highend »

Hi Ken,

While you could monitor right clicked menu items through the posted function you would still need to feed the necessary
information what to display afterwards by sending a new script to XY. You would need to capture which menu item
was clicked to do that. I don't think there is a generic way to interact in this case, most of the menu's functionality
would need to be replicated by the ahk script...
One of my scripts helped you out? Please donate via Paypal

klownboy
Posts: 4141
Joined: 28 Feb 2012 19:27

Re: <get "shift"|"Trigger"> on submenus?

Post by klownboy »

Hey highend, yeah I don't think it's as simple as I was hoping. What I had started with was simply setting a variable when the right click function was detected (see code below). In stepping through the script I could see that the variable is being created and is seen/set in XYplorer, but I can't get the actions of the submenu to be performed based on the variable being created or not. My menu script jumps to the end at that point instead of performing the code. So it looks like there no way to force it to continue with the XY script execution after the AHK right click detection? Too bad though. As you pointed out, it looks like I'd have to feed the XY script information back to AHK. I could use caller("caption"), but it seems like a ton of work. Of course I have to unset the variable after each use also. Thanks.

Code: Select all

#SingleInstance force
If ( HWND := WinExist("ahk_class ThunderRT6FormDC") )
{

#If (DetectContextMenu() = 1)
RButton::
MessagetoXYplorer = ::perm $RightClickDetect=1
SendFunction(MessagetoXYplorer)
Return
#If

SendFunction(MessagetoXYplorer)
{
	HWND := WinExist("ahk_class ThunderRT6FormDC")
	Size := StrLen(MessagetoXYplorer)
	If !(A_IsUnicode) {
		VarSetCapacity(Data, Size * 2, 0)
		StrPut(MessagetoXYplorer, &Data, "UTF-16")
		} Else {
		Data := MessagetoXYplorer
	}
	VarSetCapacity(COPYDATA, A_PtrSize * 3, 0)
	NumPut(4194305, COPYDATA, 0, "Ptr")
	NumPut(Size * 2, COPYDATA, A_PtrSize, "UInt")
	NumPut(&Data, COPYDATA, A_PtrSize * 2, "Ptr")
	Result := DllCall("User32.dll\SendMessageW", "Ptr", HWND, "UInt", 74, "Ptr", 0, "Ptr", &COPYDATA, "Ptr")
}

DetectContextMenu() ; based on closeContextMenu() by Stefaan - http://www.autohotkey.com/community/viewtopic.php?p=163183#p163183
{
	   
	GuiThreadInfoSize = 48
	VarSetCapacity(GuiThreadInfo, 48)
	NumPut(GuiThreadInfoSize, GuiThreadInfo, 0)
	if not DllCall("GetGUIThreadInfo", uint, 0, str, GuiThreadInfo)
	{
		MsgBox GetGUIThreadInfo() indicated a failure.
		Return
	}
	; GuiThreadInfo contains a DWORD flags at byte 4
	; Bit 4 of this flag is set if the thread is in menu mode. GUI_INMENUMODE = 0x4
	If (NumGet(GuiThreadInfo, 4) & 0x4)
		Return 1 ; we've found a context menu
	Else
		Return 0
}

}
It would have been cool if it worked. :) Well the code works, I can't get to work with XY as desired.
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440

Post Reply