CEA - Custom Event Actions
CEA - Custom Event Actions
Hi Don,
I was thinking about this already for so long, now I simply ask it:
A Custom Event Action CAE_LocationChange (to take effect whenever the location in a XY pane changes) would be so much help for scripting customization IMHO.
I personally have some scripts that watch XY for location change from the outside. It would be so much better if XY could invoke a script in this case actively on its own.
So, now it is said. Hope you do not find it completely useless. This would really be one of my biggest wishes (no exaggeration).
But I do not want to stress you with this. Better the thought matures slowly than you being stressed.
Anybody else who would find this useful?
Regards, Stephan
I was thinking about this already for so long, now I simply ask it:
A Custom Event Action CAE_LocationChange (to take effect whenever the location in a XY pane changes) would be so much help for scripting customization IMHO.
I personally have some scripts that watch XY for location change from the outside. It would be so much better if XY could invoke a script in this case actively on its own.
So, now it is said. Hope you do not find it completely useless. This would really be one of my biggest wishes (no exaggeration).
But I do not want to stress you with this. Better the thought matures slowly than you being stressed.
Anybody else who would find this useful?
Regards, Stephan
[AHK] redirecting Windows Explorer to XY, [XYS] Mini Tree with open tabs (cur loc expanded, tab folders highlighted), [AHK] customInlineRenameKeys, [AHK] clipboardHelper_and_XYEscToList
-
- Posts: 2341
- Joined: 04 Jan 2010 14:27
- Location: Pasárgada (eu vou!)
Re: CAE_LocationChange, pleeeeease...
In the meantime, I'd suggest a workaround (sorry if this is redundant to you, but valid for viewers after a solution anyway):
-endless/"timeoutless" script running in background (yeah, I hate this part...);
-at each 500/"x" ms get("pane"); store the value at [$ref];
-trigger if get("pane") != $ref, else do nothing.
-endless/"timeoutless" script running in background (yeah, I hate this part...);
-at each 500/"x" ms get("pane"); store the value at [$ref];
-trigger if get("pane") != $ref, else do nothing.
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...
-
- Posts: 1416
- Joined: 04 Nov 2008 05:35
- Location: Hanoi, Vietnam
Re: CAE_LocationChange, pleeeeease...
+1
I asked this long time ago. I have to workaround using AHK:
- Push the <path> to Titlebar via ini tweak TitlebarTemplate="<path> - <app> <ver>"
- Use AHK to watch for Titlebar change:This script triggers whenever <path> change instead of checking every xx ms.
Anyway, this is still a workaround.
I asked this long time ago. I have to workaround using AHK:
- Push the <path> to Titlebar via ini tweak TitlebarTemplate="<path> - <app> <ver>"
- Use AHK to watch for Titlebar change:
Code: Select all
Settitlematchmode, 2
RenameXYplorer:
WinwaitClose, %CurrentTitle%
if(WinExist("ahk_class ThunderRT6FormDC") = 0) ;XYplorer window is Closed
{
Winwaitactive, XYplorer ahk_class ThunderRT6FormDC
WinGetTitle, CurrentTitle, XYplorer ahk_class ThunderRT6FormDC
gosub RenameXYplorer
}
Else ;XYplorer change Tab location
{
WinGetTitle, CurrentTitle, XYplorer ahk_class ThunderRT6FormDC
FunctionMessagetoXYplorer("::load Rename3")
gosub RenameXYplorer
}
Anyway, this is still a workaround.
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488
Re: CAE_LocationChange, pleeeeease...
I know, because I gave you that hint back then.binocular222 wrote:- Use AHK to watch for Titlebar change
Still, atm I am doing it as SF said (checking every 150 ms, though, or so in order to have a faster reaction time), because IF the path is too long then it gets truncated in the titlebar, making a reliable compare impossible, besides clogging up the titlebar like that is not really nice to look at.
Thinking of which, maybe it could help to use "short" DOS-paths instead of the full paths, making the truncation less likely. But would it then be 100% reliable, I wonder? Would have to do some testing. It surely also depends on what else is in the titlebar.
Regards
[AHK] redirecting Windows Explorer to XY, [XYS] Mini Tree with open tabs (cur loc expanded, tab folders highlighted), [AHK] customInlineRenameKeys, [AHK] clipboardHelper_and_XYEscToList
-
- Site Admin
- Posts: 60602
- Joined: 22 May 2004 16:48
- Location: Win8.1 @100%, Win10 @100%
- Contact:
Re: CAE_LocationChange, pleeeeease...
The next beta will offer a Custom Event Action that will call a script of your making before or after browsing to a new folder.
FAQ | XY News RSS | XY Twitter
Re: CAE_LocationChange, pleeeeease...
That sounds nifty. Would the script be able to execute different actions based on the new folder's location? Or, would the folder be a set location in XYplorer.ini file? If the latter was the case, you'd probably need multiple CEA entries in the ini.
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440
Re: CAE_LocationChange, pleeeeease...
No, you have to define on what folder the script reacts
The best way would to define a heredoc with all folders and their action(s) afterwards...
Code: Select all
if (<newpath> LikeI "C:") {
...
} elseif (<newpath> LikeI "D:\Temp") {
...
}
One of my scripts helped you out? Please donate via Paypal
Re: CAE_LocationChange, pleeeeease...
From the beta log:
v21.30.0005 - 2020-11-30 13:17 + Custom Event Actions (CEA): Now you can run or load a script at the event of browsing to a new folder. Note that there is no action when the current folder is rebrowsed, i.e. refreshed. Like all CEAs, it is currently only implemented as a tweak. Example for the tweaked INI file: ; Tweak: 0=None, 1=Before Browse, 2=After Browse, 3=Both CEA_OnBrowseScript=1 CEA_OnBrowseScript_Script=echo "Hi!" You would probably use a script that loads some script file that does some interesting things. This would load "AfterBrowse.xys" (located in the Scripts subfolder of the app data folder) after browsing a folder: CEA_OnBrowseScript=2 CEA_OnBrowseScript_Script=load "AfterBrowse" To do something useful the script should know about the new path. You can refer to it by the new variable <newpath>. It will return the full new path, without trailing backslash. For example: CEA_OnBrowseScript=1 CEA_OnBrowseScript_Script=echo "Going to <newpath>." If you want to call one script before and another script after the browse you can pass 2 scripts separated by "||": CEA_OnBrowseScript=3 CEA_OnBrowseScript_Script=echo "Going to <newpath>."||echo "Went to <newpath>."
[AHK] redirecting Windows Explorer to XY, [XYS] Mini Tree with open tabs (cur loc expanded, tab folders highlighted), [AHK] customInlineRenameKeys, [AHK] clipboardHelper_and_XYEscToList
Re: CAE_LocationChange, pleeeeease...
A bit more sophisticated / user changeable...
Code: Select all
$actions = <<<>>>
D:\Users\%USERNAME%\Bilder|#308
D:\Users\%USERNAME%\Dropbox|#309
>>>;
$actions = regexreplace($actions, "^[ \t]+");
foreach($action, $actions, <crlf>, "e") {
$path = trim(gettoken($action, 1, "|"), "\", "R");
$cmd = gettoken($action, 2, "|", "t", 2);
if (<newpath> LikeI $path) {
load $cmd, , "s";
break;
}
}
One of my scripts helped you out? Please donate via Paypal
Re: CAE_LocationChange, pleeeeease...
Sounds great! I hadn't realized Don had already issued the beta when I wrote my comment. Thanks guys and Don of course.
You could probably use a switch statement for this as well.
You could probably use a switch statement for this as well.
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440
-
- Site Admin
- Posts: 60602
- Joined: 22 May 2004 16:48
- Location: Win8.1 @100%, Win10 @100%
- Contact:
Re: CAE_LocationChange, pleeeeease...
I would recommend to resolve <newpath> before any loop. Just a habit to gain speed...
FAQ | XY News RSS | XY Twitter
Re: CAE_LocationChange, pleeeeease...
I can't see any speed improvements assigning <newpath> before the loop and do the comparison with that variable instead...
One of my scripts helped you out? Please donate via Paypal
-
- Site Admin
- Posts: 60602
- Joined: 22 May 2004 16:48
- Location: Win8.1 @100%, Win10 @100%
- Contact:
Re: CAE_LocationChange, pleeeeease...
But I can because I see the code. Resolving script variables is faster. Should be. Or did you test it?
FAQ | XY News RSS | XY Twitter
Re: CAE_LocationChange, pleeeeease...
Of course I did test it before
These values vary a bit but they're always very close together and 10 ms on 10.000 runs... Neglectable...
Code: Select all
$start = now("msecs");
while($i++ < 10000) {
if ("path_x" LikeI <curpath>) {
}
}
status "Time: " . now("msecs") - $start . " msecs";
// Result = 1828
$current = <curpath>;
$start = now("msecs");
while($i++ < 10000) {
if ("path_x" LikeI $current) {
}
}
status "Time: " . now("msecs") - $start . " msecs";
// Result = 1818
One of my scripts helped you out? Please donate via Paypal