Page 1 of 1
Make user designated UDC key assignments unassignable
Posted: 02 Feb 2021 15:22
by klownboy
I have a question and also possibly a request. The question concerns the assignment of a UDC action key assignment and key assignment with modifier. Let's say I have a assignment for Numpad 5 to accomplish something in a script and I also want to accomplish another action in the same script using Control Numpad 5. Essentially the action of Numpad 5 would be equivalent to what I have in a CTB left click assignment (i.e., assigned the exact same script file). I wanted the Control Numpad 5 to be the same as my right click of the same CTB. I know how to accomplish that and make that distinction in the script with something along the lines of:
Code: Select all
$mod = get("trigger","callshift");
$context = get("trigger","context");
if(($trigger == "1") OR ($context == "4" AND $mod != "2")) {
The problem is obviously that Numpad 5 and Control Numpad 5 are both assignable - both can have Keyboard Assignment in Manage User Defined commands. There isn't any way around this. In other words, I can't have the script make the distinction of Control being held down when Numpad 5 is pressed since there is a separate keyboard allowance for that in Manage UDC.
What I'm wondering if it would make sense on these keyboard assignments to make a keyboard assignment like in this case, Control Numpad 5 un-assignable or void in some way (like the space key) such that we can direct the actions through the script instead of having to separately assign the key with a modifier as in the above case, Control Numpad 5. I think it would be a cleaner way to make distinctions of a separate (with modifier) action in the script itself along with eliminate having to assign a UDC separately to the key with a modifier held down. Possibly a user list of unassignable keys (like in the above case Control Numpad 5 would be flagged as unassignable). Yet, you would still be able to make that Control Numpad 5 work in a script via the use of get("trigger", "callshift"). Does that make sense?
Re: Make user designated UDC key assignments unassignable
Posted: 02 Feb 2021 20:24
by admin
Just a quick answer to the headline (if it's not what you meant let me know and I will read the text): Choose "None".
Re: Make user designated UDC key assignments unassignable
Posted: 03 Feb 2021 01:45
by RalphM
I read your explanation but am sorry to say that I don't get it!
Maybe others read better between the lines.
Re: Make user designated UDC key assignments unassignable
Posted: 03 Feb 2021 13:13
by klownboy
I do realize what "none" is and does. What I'm talking about is making a key combo like control numpad 5 "not available" for use as a UDC at all. The result would be similar to how the "space" key is not available for use as a UDC (i.e.., it's not on the listing of available keys to assign as a UDC). That's actually what I'm after. This would allow us to assign an action of a key with modifier like control numpad 5 with in the script itself and not have to use a separate UDC assignment for control numpad 5.
To hopefully further explain...I have a UDC key assignment for numpad 5 in a script. I want to be able to, within the same script, detect if a modifier key was held down to perform a different action. I can't do that because there is a available key assignment for control numpad 5. I'm forced instead to use a separate UDC assignment for Control numpad 5 to direct that action.
Re: Make user designated UDC key assignments unassignable
Posted: 03 Feb 2021 13:49
by highend
To make it short: You want to be able to temporarily (as long as a script is running) unbind existing keyboard shortcuts so that you can reuse them in your script?
Re: Make user designated UDC key assignments unassignable
Posted: 03 Feb 2021 15:24
by klownboy
highend wrote: ↑03 Feb 2021 13:49
to make it short: You want to be able to temporarily (as long as a script is running) unbind existing keyboard shortcuts so that you can reuse them in your script?
I don't want a key to be assignable at all. Yes, I suppose it could be temporary. If I have a UDC key assignment for Numpad 5 to load a script file, I want to be able to detect, in the same script, if a control modifier is held down such that I wouldn't need to assign the "control" numpad 5 action as in a separate UDC. Instead, the action would be accomplished by detecting the modifier key is being held down while pressing Numpad 5 in the script itself. In order to do that, the UDC keyboard assignment for "control numpad 5" can not be available at all. Similar to how some keys, like the "space" key is not available for a UDC key assignment.
These un-assignable keys could be a user-defined list in XYplorer.ini or udc.dat, or as you said highend, be able to temporarily void the key as an assignable key while that script is running. So in affect for this example, I would void the "control numpad 5" use as an assignable UDC key at the beginning of the script. I can then detect the control modifier held within the script to accomplish a different action than what is to be accomplished for numpad 5 key itself.
Sorry, it's not such an easy thing to explain. You are close in my thinking highend, but I wouldn't have anything assigned to "Control numpad 5 " at all, only "Numpad 5". So "Control Numad 5" really doesn't have to be unbound, it's simply not available to be assigned.
Re: Make user designated UDC key assignments unassignable
Posted: 03 Feb 2021 17:28
by PeterH
What if you define the same script to Num5 AND to ctrl-Num5?
Then the script can be called by both variants, and, as much as I remember, the script can test for active modifier keys (i.e. ctrl), isn't it so?
Re: Make user designated UDC key assignments unassignable
Posted: 03 Feb 2021 18:18
by klownboy
PeterH wrote: ↑03 Feb 2021 17:28
What if you define the same script to Num5 AND to ctrl-Num5?
Hi PeterH, actually that's similar to what I've been doing since I can't do what I propose. In the script I have an action done by the press of Numpad 5 (or left click of CTB) and in the same script I distinguish if it's Control Numpad 5 (or right click of CTB). I used a global to distinguish the actions, but i could have and should have simply used the fact that the control key was held down. This way both actions would be simply load script without that global assignment below.
Code: Select all
- Numpad 5 in a UDC I have Load script:
load "D:\Tools\XYplorer\Scripts\ToolbarCycle.xys";
- Control numpad 5 assigned in UDC - Run script:
global $tb="right";load "D:\Tools\XYplorer\Scripts\ToolbarCycle.xys";
In the script I make the distinction for actions via:
if(($trigger == "1") OR ($context == "4" AND $tb != "right"))
//if(($trigger == "1") OR ($context == "4" AND $mod != "2")) { //this works as well simply using the $mod and not a global {
This script is run from a CTB as well. Normal left click of the CTB cycles toolbars and right click brings up a menu. The numpad 5 will do the same as the CTB left click and Control Numpad 5 does the same as a right click of the CTB.
This all works fine (The script is posted here
viewtopic.php?f=7&t=22666). What I was hoping for was a way to not have to assign an action to Control Numpad 5 at all. Essentially have that key disabled for use as a UDC and handle the control mod in the script alone (i.e., only Numpad 5 would require a UDC and Control Numpad 5 would not - it would be disabled). Maybe it's just not worth it.

Re: Make user designated UDC key assignments unassignable
Posted: 04 Feb 2021 01:21
by klownboy
Well, in the end it's probably not worth Don's time and effort to make user specified UDCs with a modifier inoperable and unassignable for the purpose of being able to doing essentially the same thing solely in a script. The only tangible benefit (if any) was the action via UDC referenced script is only called and associated with the main unmodified key (e.g., Numpad 5) and no assignment in UDCs would be necessary for same key with the modifier held down (e.g., Control Numpad 5). So let it die and sorry to have brought it up.
Re: Make user designated UDC key assignments unassignable
Posted: 04 Feb 2021 10:25
by admin