[AHK] redirecting Windows Explorer to XY

Discuss and share scripts and script files...
autocart
Posts: 825
Joined: 26 Sep 2013 15:22

[AHK] redirecting Windows Explorer to XY

Post by autocart » 19 Nov 2013 09:25

 
!! The code below is provided "AS IS". Usage is completely at your own risk. No warranties from my side. !!
(Download of the newest version from close to the bottom of this post.)

Contents

Intro
More details
Even more details
Known limitations
Regarding the available downloads below
Downloads
Credits
Release notes / Change log
Possible ideas for the future

Intro

Hi all,
here is a script written in AutoHotkey (AHK), which works in combination with XY and Windows Explorer (from now on called "WE"). Please, see the credits section further down for all the cool people who helped in one way or another so far, e.g. with testing, bug fixing, suggestions and motivation.

The script was written for the following scenarios:

(1) XY's setting "XY is default file manager" not getting respected:
Despite XY's build-in optional functionality to act as the system's default file manager (XY menu Tools/Configuration/Other/Shell Integration), sometimes there still are WE windows opening instead of XY (e.g. from within certain 3rd-party-software or for other reasons).

(2) List items not getting automatically selected in XY:
At other times XY *is* sucessfully used as the system's default file manager to open a folder (if that setting is on) but any list itmes which would normally be selected in WE do *not* get selected in XY (e.g. when clicking in Firefox in the "downloads" window on the "open containing folder" button).

For such scenarios, this script, if running in the system tray, catches any newly opening WE window, reads the path and selected items shown in that WE window, closes that WE window, opens a new tab in XY with that path *and* selects any list items in XY that where selected in WE before (and scrolling them into view), thus "redirecting" the WE window to XY.

The script will stay in the system tray until manually exited through the script's tray context menu.

Some of the scripts settings can be easily customized by the user. These settings are located in a separate config file, named "redirectWEwindowsToXY_v#.config.ahk", with "#" standing for the first two parts of the script's version number, e.g. “4.1“, which the config file is compatible to. It is part of the download.

Hint:
For the script to work also in cases of scenario No. (2), of course, the XY setting to act as the system's default file manager must be turned *off*.

More details

If one wants any WE windows to be kept as WE windows (and *not* be redirected to XY) - e.g. control panel stuff - then there are these options:

(1) Control-key-escape:
Hold the left or right control key pressed down while the WE window opens, which you want to keep. Typically, though, the control key must be held down until the WE window has actually opened. If released too early, it might not work as intended.

Example:
With the script running, pressing Win+E would open a new WE window which normally would get redirected to XY.
Pressing Control+Win+E, the new WE window would *not* get redirected to XY. (Of course the Control-key-escape option should work also if a WE window is opened by other means.)

This functionality of the control key can be activated or deactivated on its own (just in case) in the script's system tray context menu.

(2) Pre-defined keywords / paths:
The script allows for pre-defined keywords and paths, which are compared to the location being displayed in the WE window (typically the content of the WE address bar, e.g. "Computer", "Libraries", "Pictures" ... and paths without trailing backslash). These keywords and paths can be either set in the variable vWindowsExplorerPaths in the separate config file "redirectWEwindowsToXY_v#.config.ahk" - separated by the pipe character "|". Else they can also be passed to the script as command line parameters - separated by spaces (and quoted if they contain spaces). Both kinds of definition *are* allowed together at the same time.

Example for the command line parameters option:
In case of command line parameters (or parameters passed in the target line of a windows shortcut file) the command line could look like this:
"path_to_autohotkey.exe" "path_to_script.ahk" Computer Libraries Pictures "C:\some kind of folder\another folder"

Hint:
In the separate config file "redirectWEwindowsToXY_v#.config.ahk" there are some suggestions for keywords to be used on an English version of Windows.

The variable vKeepOrRedirect_matchingWEPaths in the separate config file "redirectWEwindowsToXY_v#.config.ahk" determines what will happen in case of a match (when comparing the WE window's location with the keywords/paths definitions). It must be set to either "Keep" or "Redirect". If vKeepOrRedirect_matchingWEPaths is set to "Keep", then the matching WE windows are kept as WE windows (and the others are redirected to XY). If vKeepOrRedirect_matchingWEPaths is set to "Redirect" then the matching WE windows are redirected to XY (and the others are kept as WE windows).

The method for comparing the WE window's location with the keywords/paths definitions, can either be set to use Regular Expressions (RegEx), which is recommended due to its ability to formulate general patterns. To do so, the variable vUseRegExForPathCompare in the separate config file "redirectWEwindowsToXY_v#.config.ahk" must be set to 1. Else, if vUseRegExForPathCompare is set to 0, then - to be a match - a keyword or path and the WE window's location must be identical.

Hint:
Of course, if RegEx is used as a compare method, then also the keywords and paths must be specified using RegEx syntax.
Here are some helpful sites for learning RegEx (PCRE flavor):
https://www.regular-expressions.info/quickstart.html
https://regex101.com/

If RegEx is used as a compare method, then any additional keywords/paths specified in the extra variable vExceptionPathsInCaseOfRegEx in the separate config file "redirectWEwindowsToXY_v#.config.ahk" act as a subset of exceptions to the main keywords/paths definitions specified in vWindowsExplorerPaths. Therefore, the main definitions in vWindowsExplorerPaths can contain a more general pattern and the extra variable vExceptionPathsInCaseOfRegEx can contain exceptions from that general pattern. (This is *only* available for the compare method RegEx.)

Even more details

WE windows, which show the content of a zip file, are automatically kept as WE windows if the "identical" compare method is used. This is, because XY does not support this kind of view and the "identical" compare method is not capable of defining zip files as a pattern. However, if RegEx is used as compare method, then the user must specify it manually in the RegEx pattern if he/she wants a zip file-content-view to be kept in WE (e.g. with \.zip$ either as part of a Keep-pattern or as part of a exeptionPaths-when-Redirect-pattern).

If XY is not running it will be started automatically if the path to XYplorer.exe is specified correctly. The path can be specified in the variable vPathToXYplorerForAutostart in the separate config file "redirectWEwindowsToXY_v#.config.ahk". A tooltip close to the mouse cursor will indicate the starting process of XY. If the XY autostart should not work for some reason (e.g. if the wrong or no path is specified) the script will display a message box and wait for the user to start XY manually.

If the user wishes for the script to apply auto-redirection also to all WE windows already existing at the moment of the script's start (not just to newly created ones while it is running) then this can be activated in the variable vApplyRulesToExistingWEwindowsAtScriptStart in the separate config file "redirectWEwindowsToXY_v#.config.ahk". Setting the variable to 1 will activate that behaviour. Setting it to 0 will deactivate it.

In order to manually redirect a given WE window to XY by force (regardless of the rules for automatic redirection), the user can specify a hotkey in the variable vHotkeyInWEwindowsToTriggerRedirectionToXY in the separate config file "redirectWEwindowsToXY_v#.config.ahk". (A hotkey refers to pressing a combination of keys on the keyboard, namely a character key together with one or more modifier keys. Modifier keys are Control, Alt, Shift and the Windows key.) The WE window will be redirected if the hotkey is pressed while the WE window is active. More details on how to specify the hotkey are given right next to the variable itself.
This hotkey can be activated or deactivated on its own (just in case) in the script's system tray context menu. If no such hotkey is specified, then the system tray context menu item will not exist.

The whole script with all its functionality can be suspended in the script's system tray context menu or with a global hotkey, which can be specified in the variable vHotkeyGlobalToSuspendUnsuspendTheWholeScript in the separate config file "redirectWEwindowsToXY_v#.config.ahk".

Known limitations

-) Whenever a WE window is "redirected" to XY, it will still open for a short moment in a normal way and immediately be closed again. For this script to work, I do not know of any way how to avoid that.
-) In case of multiple XY windows being open at the same time, the most recently active XY window will be used for redirection.
-) This script has not been tested with WE add-ons, which add tabs to WE.

Regarding the available downloads below

I removed the compiled exe version of the script from the available downloads again, which I had attached in a previous version.
I really don't want to promote downloading and running executables from some stranger on any forum (including me right here). This can be dangerous and such exe files should never be trusted. Besides, if there is something going wrong on the computer at the users end, then I want the user to be able to check and see (and me to be able to easily proof - protecting myself) that there was no malicious code in my script, which would not be possible, if I offered an already compiled exe.

Instead, I want to encourage everyone to download the AutoHotkey base program from here: https://www.autohotkey.com/download/ and run my ahk file (which is inside the zip attached to this post - see below) with that AutoHotkey program. The AutoHotkey program can either be installed the traditional way and set to run ahk files on double click (which is the default). Else, just unzip the zip downloaded from the AutoHotkey website and create a Windows shortcut to the included AutoHotkey.exe with the path to the ahk file downloaded from here as command line parameter in the shortcut.

Alternatively you can compile the ahk-script yourself. It is really simple. Just download and install the AutoHotkey base program. Then right-click on the ahk-file, which you downloaded and extracted from the zip here, and choose "Compile Script" from the right-click menu. This will create a compiled exe of the ahk-script in the same location. That's it. It is that simple.

(And if you want to include the icon in the compiled exe, then - after installing the AutoHotkey base program -, instead of right-clicking on the ahk script file, go to the start menu, choose the AutoHotkey folder and start the little helper app "Convert .ahk to .exe". In the dialog of that app, state the "Source (script file)", where to save the "Destination (.exe file)" and which "Custom Icon (.ico file)" to use. Click "> Convert <". Done.)

P.S.: Most of the code was written years ago. Looking at the code now, it does not look pretty at all. I feel a need to rewrite it from scratch but don't have the time nor the motivation for it all at the moment. For now, I just started a little bit and mostly changed the things, which seemed to me most important. In a later version I might rewrite the code - or not.

Downloads

vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
 
Here is the newest version for download ("AS IS", usage at own risk):
The download includes all the description as comments at the beginning of the code.
For all versions: copyright by autocart (user name at the ahk and XYplorer forums) unless otherwise noted in the code

redirectWEwindowsToXY_v4.1_200512.zip
(25.49 KiB) Downloaded 27 times
Change log below.
 
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
Here are older versions:
redirectWEwindowsToXY_v4.0_200501.zip
(24.58 KiB) Downloaded 23 times
redirectWEwindowsToXY_v3.4.1_200430.zip
(22.14 KiB) Downloaded 12 times
redirectWEwindowsToXY_v3.3_200428.zip
(21.11 KiB) Downloaded 20 times
redirectWEwindowsToXY_v3.2_200425.zip
(19.09 KiB) Downloaded 16 times
redirectWEwindowsToXY_v3.1_200424.zip
(13.91 KiB) Downloaded 9 times
redirectWEwindowsToXY_v3.0_200423.zip
(13.04 KiB) Downloaded 10 times

Credits

First of all, not all AHK code used in the script was writting by me. I am specifically pointing out in the code itself, where I got it from if it was from someone else. Other than that, all the following cool people helped so far (as of 2020-05-05) with e.g. testing, bug fixing, suggestions and motivation, as can also be seen in the thread below:

binocular222
kiwichick
yusef88
Dustydog (Special thanks to Dustydog for motivating me to pick this baby back up after a couple of years! This also shows that posting to a year's old thread is not bad at all but can be very good.)
yuyu
1024mb
Keagel
kotlmg

Release notes / Change log

Changes in version 4.1:

-) Added the variable vHotkeyInXYtabsToTriggerRedirectionToWE to the config file to specify a hotkey to manually redirect a tab in XY to WE (which is the opposite direction than usually). This hotkey only works in XY.
It can be set to the same hotkey as vHotkeyInWEwindowsToTriggerRedirectionToXY is set to, which only works in WE, so that the hotkey serves as kind of a toggle-hotkey between XY and WE. (As suggested by Dustydog, see viewtopic.php?f=7&t=10671&p=178249#p178248)
In case that a view in XY does not have a real path (e.g. "My Computer" or XY paper folders), WE for now always opens with the "My Computer" view.
-) Added the variable vCloseXYtabIfRedirectedToWE to the config file to specify whether or not the XY tab should be closed if it is redirected to WE.
In case that the view in XY does not have a real path, the XY tab is not closed, regardless of this variable.
-) Internal change: Changed the function name ShellMessage_forCtrlWinE to ShellMessage_keepTheNextWEwindow.

Changes in older versions:

Code: Select all

Changes in version 4.0 - 200501:

-) Moved the user customize section out into a separate .config.ahk file. (As suggested 
   by 1024mb, see https://www.xyplorer.com/xyfc/viewtopic.php?f=7&t=10671&start=45#p177998)
   This helps the user to not have to update the user customizeation part of 
   the script each time a new version is released. Plus, it is easier to keep the 
   overview in a much shorter file without the distraction of the intro or the 
   main code below. The new .config.ahk file carries the first two digits of the 
   version number of the script version, which it belongs to, in its name, e.g. 
   “4.1“. The main version and/or the first sub-version number of the script 
   (and thus the name of the .config.ahk file) will from now on be incremented 
   only, if the compatibility of the .config.ahk file changes. When the script is 
   updated but the compatibility with the config file stays the same, only the 3rd 
   part of the script's version number will be incremented, e.g. “4.1.2“. (At first 
   I was about to increment only the script's main version number each time the 
   config file would change, but realized that there might still be a considerable 
   amount of new user settings to come?, so the chances that the main version 
   number would go up fast seemed to risky to me.)
-) Added a check for the script file's encoding and the encoding of the new config.ahk
   file. If they are not saved in the UTF-8 format with BOM, then the script will pop 
   a message box and refuse to run.
-) Added a global hotkey, specified in the variable 
   vHotkeyGlobalToSuspendUnsuspendTheWholeScript in the .config.ahk file, which will 
   suspend or unsuspend the script. (As suggested by Dustydog, see 
   https://www.xyplorer.com/xyfc/viewtopic.php?f=7&t=10671&start=30#p177771)
-) Added a tray menu item which toggles the use of Ctrl to manually keep a WE 
   window (just in case).
-) Renamed the tray menu items a bit.

Changes in version 3.4.1 - 200430:

-) Fixed a bug with none-ascii characters.
   Saved the script file as with UTF-8 *with* BOM. Before it was saved as UTF-8 
   without BOM, which caused none-ascii characters to be processed incorrectly.

Changes in version 3.4 - 200429: (only bug fixes)

-) Maybe fixed that XY sometimes crashed when being autostarted. When XY was 
   autostarted it sometimges crashed, as it seems, without the line "WinWait, 
   XYplorer ahk_class ThunderRT6FormDC", which is strange to me because the 
   code before that line should have aleady made sure that the XY window exists. 
   However, it did not always crash. Re-added that line in for now, nevertheless. 
   So far, it never crashed on autostart with that line.
-) Fixed / Changed (hopefully improved) the way how paths, which are being 
   redirected to XY, are passed to XY. There could have been problems with how 
   paths were compared to the existing tabs. Especially if the redirected path was 
   a sub path of an existing tab, it would have not opened a new tab but changed 
   the current tab to the new path.
-) Fixed a bug by which the script would send XY into a scripting error, if the 
   redirected path contained single quote characters.
-) Fixed a bug that if a path was redirected to XY and the list in XY did *not* have 
   focus, then any selected items in WE would be selected in XY but not be scrolled 
   into view. Now they are (respectively the first selected item is).
-) Fixed a bug preventing to manually force redirect zip content views to XY.
-) Fixed / Changed the way how paths, that are really files (e.g zip files), are 
   handled when passed to XY. There was an inconsistency in the code how such 
   paths were handled, which could have led to XY displaying nothing in a new tab. 
   This was highly unlikely to surface to the user, but might have after the fix 
   above. Now, if the path is really a file, then the path to the parent directory of 
   that file is always taken as the redirected path and the file as selection.
   
Changes in version 3.3 - 200428:

-) Fixed some wrong logic in the processing of events. Previously, if XY was not 
   already running, it would be automatically started also if the WE window was to 
   be kept as WE window. In that scenario also, if no correct path to XYplorer.exe 
   was specified, then the script would still pop the corresponding message box and 
   wait for XY to be started manually. This made not even any sense, since the WE 
   window would anyway not be redirected to XY. This is changed now. The script 
   will only check for the open XY window and react accordingly if the WE window 
   is to be redirected.
-) Fixed a logical bug with RegEx compare: If hard coded keywords/paths were used 
   AND command line parameters AND RegEx was used as compare method, then 
   there was a logical bug which could have led to everything being a match (besides 
   the RegEx-exeptions)
-) Changed the order of the help text a bit. Adjusted the order of the variables in 
   the "USER CUSTOMIZE SECTION" of the code accordingly.
-) Added the variable vApplyRulesToExistingWEwindowsAtScriptStart to optionally 
   apply the specified rules also to existing WE windows at script start.
-) Added the variable vHotkeyInWEwindowsToTriggerRedirectionToXY to be able to 
   specify a hotkey to redirect WE windows to XY manually, if pressed while the 
   targeted WE window is active.
-) Simplified the system tray context menu to three items:
	(1) Toggle menu item to use/activate the specified hotkey for redirecting WE 
	    windows manually (or deactivate it).
	(2) Toggle menu item to Pause / Suspend Script which both pauses the script 
	    and suspends the hotkeys.
	(3) Fully exit the script.

Changes in version 3.2 - 200425:

-) Added code for an optional custom tray icon and supplied a simple icon with it.
-) Renamed the variables; especially the variable with all the keywords and paths is 
   now called vWindowsExplorerPaths.
-) Added the options/variables vKeepOrRedirect_matchingWEPaths, 
   vUseRegExForPathCompare and vExceptionPathsInCaseOfRegEx.
-) Added some visual marking of the user customize section in the code below
-) In case the variable vKeepOrRedirect_matchingWEPaths has an incorrect value, a 
   message box will pop.
-) Changed the hard coded behaviour of *not* redirecting the display of the content 
   of zip files to XY: 
   Now it is only hard coded for the case if RegEx is *not* used as compare method. If 
   RegEx is used, then the behaviour for zip files can be specified in the RegEx pattern.

Changes in version 3.1 - 200424:

-) Fixed the problem that the script would crash if XY was not active.
-) The path to XY can now be specified in the variable $pathToXYplorer at the beginning 
   of the code.
-) In case of a XY autostart process, a tooltip will be diplayed close to the mouse cursor.
-) In case the XY autostart process could not be started, a message box will pop.

Changes in version 3.0 - 200423:

-) Improved reliability:
   Before, the script sometimes missed WE windows or seemingly could not retrieve its 
   path and then did not react as expected.
-) Improved behaviour when paused:
   Now the script is respecting the script's paused state (see the script's system tray 
   context menu) in that it stops redirecting when the script paused. (As suggested by 
   Dustydog, see https://www.xyplorer.com/xyfc/viewtopic.php?f=7&t=10671&start=30#p177771)
   Before it ignored the state of being paused and redirected anyway.
-) Changed the behaviour of the script regarding already existing WE windows:
   In previous versions, when the title bar of already existing WE windows (which existed 
   prior to the scripts start) changed (e.g. when changing a folder in such a window or 
   when refreshing by hitting F5), then the script also used to redirect such WE windows 
   to XY. Not anymore. Now, if a WE window already exist at the scripts start, the script 
   leaves it untouched.
-) Added a Control-key-escape option:
   If the left or right Control key is pressed while a WE window opens, then this 
   particular WE window will *not* get redirected to XY.
Possible ideas for the future

-) make a separate help/readme file
-) maybe handle also other message scenarios - not just "window created"
-) maybe re-introduce automatic redirection of existing WE windows while browsing the file system in that WE window. I think, this has pros and cons. The pros are that if I specifially browse to a path which I want to open in XY it will be done automatically. The cons are that if I browse to a path which gets redirected to XY, I might have forgotten to think of it and might not want that at this very moment. I think for now, the new hotkey feature with which it is possible to manually force-redirect the current path/view in an WE window to XY, might be the best solution. But I am open for suggestions.
-) improve the MsgBox popping when the WE path could not be determined (maybe with debug-information that a user could then post in the forum for my knowledge) and make it easier for the end user to disable that MsgBox if he/she would want to not see it
-) add a compatibility check for the found config file; in case it is not there or it is an old version, offer the user to create a new config file with default values.
-) add a setting which allows the user to have the WE windows be redirected to an XY throw-away-clone instead of the main XY window
-) adding to the throw away clone idea: somehow let the user optionally specify a layout to be used with the throw away clone
-) adding to the throw away clone idea: implement a functionality to move the throw away clone window tab to a main XY window tab. and vice versa.
-) adding to the throw away clone idea: allow the user to specify, which WE windows get redirected to a throw away clone window in XY and which get redirected to the main XY window
-) ... to be continued ...

The list above are just brainstorming results and not a real roadmap, just saying. For any suggestions of improvement I am grateful (whether they are aleady included in the list above or not), because I want this script to be of help to many users. Many thanks in advance!
Last edited by autocart on 13 May 2020 11:33, edited 97 times in total.

binocular222
Posts: 1414
Joined: 04 Nov 2008 05:35
Location: Hanoi, Vietnam

Re: Redirecting win explorer windows to XYp [with AHK]

Post by binocular222 » 19 Nov 2013 10:33

Do not use While 1.
Your script will execute constantly and stress the CPU.
Use ShellHook instead:

Code: Select all

DllCall( "RegisterShellHookWindow", UInt,WinExist() )
MsgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" )
OnMessage( MsgNum, "ShellMessage" )
ShellMessage( wParam,lParam )
{
  If ( wParam = 1 AND WinActive("ahk_class CabinetWClass")) ;  1 means HSHELL_WINDOWCREATED
{
      Msgbox, Do something here
}
}
Return
Your script will be in dormant state and only fire whenever a new window is created. If it's Windows Explorer (ahk_class CabinetWClass), then do something.
<Note: SheelHook does not detect creation of child windows
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488

autocart
Posts: 825
Joined: 26 Sep 2013 15:22

Re: Redirecting win explorer windows to XY [with AHK]

Post by autocart » 19 Nov 2013 21:45

Thx, binocular222
I will try this out some time later, though.
So far it does not consume much CPU on my PC anyway.
But always good to know about alternatives. Thank you. :)

Edited the 1st post.
Last edited by autocart on 05 Apr 2020 00:13, edited 1 time in total.

kiwichick
Posts: 277
Joined: 08 Aug 2012 04:14

Re: [AHK] redirecting win explorer windows to XYp

Post by kiwichick » 03 May 2014 02:02

Oh what a godsend this is!!! Unfortunately it doesn't work for me. I'm using the latest version of XYplorer on Windows 7 Home Premium 64-bit system. When I run the script I get this error:

Image

Is this fixable? Cheers.

autocart
Posts: 825
Joined: 26 Sep 2013 15:22

Re: [AHK] redirecting win explorer windows to XY

Post by autocart » 03 May 2014 15:18

Did you use the whole code exactly as I pasted it or did you change something?
If u changed something can u post the whole code, please.
I admit that the code is far less then perfect. For anyone using it would not hurt to understand a little bit of autohotkey.
Last edited by autocart on 05 Apr 2020 00:13, edited 1 time in total.

yusef88
Posts: 950
Joined: 28 Jan 2013 03:50
Location: Windows 8.1 32-bit

Re: [AHK] redirecting win explorer windows to XYp

Post by yusef88 » 03 May 2014 21:20

would you compile the script to exe ,please?

autocart
Posts: 825
Joined: 26 Sep 2013 15:22

Re: [AHK] redirecting win explorer windows to XY

Post by autocart » 03 May 2014 21:56

yusef88 wrote:would you compile the script to exe ,please?
yusef, in order for this to make any sense, I would have to improve the code soo much. Right now you have to adapt it manually (as you can read in the comments of the code). If I make an exe then this is not possible anymore. Maybe I will invest the time to improve the code later but not now. If you install autohotkey, though, you can save the code as *.ahk file and run it this way.

But it is nice to see that there are people interested in my script. This makes is more likely that I will improve the script. It gives me more motivation. Let's see...
Last edited by autocart on 05 Apr 2020 00:14, edited 1 time in total.

kiwichick
Posts: 277
Joined: 08 Aug 2012 04:14

Re: [AHK] redirecting win explorer windows to XYp

Post by kiwichick » 04 May 2014 00:22

autocart wrote:Did you use the whole code exactly as I pasted it or did you change something?
If u changed something can u post the whole code, please.
I admit that the code is far less then perfect. For anyone using it would not hurt to understand a little bit of autohotkey.
Thanks autocart, I changed "Adresse" to "Address" as you recommended but apart from that I used the code exactly as pasted. When it threw the error I changed the $XYpExe path because my XYplorer is portable but the same error. That is the only change I made. Is there a particular location I should place the script file (eg: XYplorer folder)? Is the script looking for XYplorer files somewhere other than the $XYpExe path?
Last edited by kiwichick on 04 May 2014 00:33, edited 1 time in total.

kiwichick
Posts: 277
Joined: 08 Aug 2012 04:14

Re: [AHK] redirecting win explorer windows to XYp

Post by kiwichick » 04 May 2014 00:27

In case it matters I'm running:
Windows 7 Home Premium 64-bit
AutoHotkey v1.1.14.04
XYplorer v14.00.0100 (portable)

autocart
Posts: 825
Joined: 26 Sep 2013 15:22

Re: [AHK] redirecting win explorer windows to XY

Post by autocart » 04 May 2014 01:31

updated the code in the first post
please tell me if it works
BTW: the $XYpExe varibable was not necessary, I deleted it
Last edited by autocart on 05 Apr 2020 00:14, edited 1 time in total.

kiwichick
Posts: 277
Joined: 08 Aug 2012 04:14

Re: [AHK] redirecting win explorer windows to XYp

Post by kiwichick » 04 May 2014 02:15

autocart wrote:updated the code in the first post
please tell me if it works
BTW: the $XYpExe varibable was not necessary, I deleted it
Thanks again autocart. Well the error has gone and partial success:
I've copied and run the script exactly as your post (apart from changing Adresse).
1. run script
2. click whatever is supposed to open WE
3. WE opens and closes
4. XY doesn't open and nothing else happens

But only on the first click. Any subsequent click results in normal behaviour (WE opens and nothing else happens).

autocart
Posts: 825
Joined: 26 Sep 2013 15:22

Re: [AHK] redirecting win explorer windows to XYp

Post by autocart » 04 May 2014 02:31

please, let me quote myself:
autocart wrote:I admit that the code is far less then perfect. For anyone using it would not hurt to understand a little bit of autohotkey.
you should be able and willing to experiment a little. For example XY needs to be running already. Also the script does not "move" all paths from WE to XY -> it is up to you to review/change the "filter" of what is being "moved" in the code on your own. also other behaviour of the script may not always be as wished in all details. so feel free to improve your ahk skills and to change the code to your liking. :)

kiwichick
Posts: 277
Joined: 08 Aug 2012 04:14

Re: [AHK] redirecting win explorer windows to XYp

Post by kiwichick » 04 May 2014 04:14

Thanks autocart, I totally appreciate what you're saying. I don't understand most of what the script does so it's probably a bit beyond my abilities.

I did, however, manage to create a little script of my own that does it quite well (at the moment anyway). It opens in the current tab (which is XY default behaviour) but I'm hoping I can utilise your bit of code for the new tab.

Code: Select all

#SingleInstance force
#Persistent

xypath = C:\PortableApps\XYplorer\XYplorer.exe

While 1
{
winwait, ahk_class CabinetWClass
controlgettext, textvar, ToolbarWindow322
stringtrimleft, address, textvar, 9
winclose

run %xypath% "%address%"
}
Feel free to have a play with it yourself if you wish :-)


UPDATE: Actually didn't need any code for a new tab. Just used XY's "Open command line start path in new tab" in Configuration/Startup & Exit.

autocart
Posts: 825
Joined: 26 Sep 2013 15:22

Re: [AHK] redirecting win explorer windows to XY

Post by autocart » 05 May 2014 14:27

Hi all,
ok, I "rewrote" my script, code above got updated.

I also made an exe for those who trust it (downloadable from the 1st post). Command line params: "paths/keywords" to be excluded from getting redirected (like "Computer" "Libraries" "Pictures" ... or real whole paths)

XY needs to be running/started manually though. Also I did not take care of multiple Explorer or XY scenarios.

Hint:
If in XY under Tools/Configuration/Other/Shell Integration I check "XYplorer is default file manager" then Firefox-Download-Open-Containing-Folder will also open XY but not mark/highlight the file. If I uncheck "XYplorer is default file manager" and use my tool instead then it will also mark/highlight the file.

@binocular222:
I used your idea now - thank you for that.
However, the way you posted it, it does not work.
as an extra 1st line it needs:
Gui +LastFound

Regards, Stephan
Last edited by autocart on 05 Apr 2020 00:15, edited 1 time in total.

binocular222
Posts: 1414
Joined: 04 Nov 2008 05:35
Location: Hanoi, Vietnam

Re: [AHK] redirecting win explorer windows to XYp

Post by binocular222 » 05 May 2014 18:20

Shellhook method only works with new parent window (not work with child window)
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488

Post Reply