Working UNDO / REDO feature workaround

Discussion and questions - donor version.
Post Reply
Message
Author
User avatar
Dreamer
Site Admin
Posts: 6115
Joined: 19.08.2007, 23:40

Working UNDO / REDO feature workaround

#1 Post by Dreamer » 17.09.2017, 17:22

Undo is probably the most wanted feature for FreeCommander, it's probably not easy to implement, so I decided to make a guide, how to use the HotkeyP to create the global keyboard shortcuts for Undo and Redo, working also in FreeCommander.

Important information! This way is working, but it's still just a workaround! Another (free) tool is needed (HotkeyP) and it works only with Windows file operations. Windows 10 Explorer's Undo and Redo options are used. Keyboard shortcuts are customizable and they work as global shortcuts, it means that they work in any program / window, so Ctrl+Z / Ctrl+Y are not recommended. Use at your own risk!

Tested using Windows 10 Home 64-bit, HotkeyP 4.8.3.

Guide:

- In FreeCommander open the Settings (F12) > File/folder operations > General > and select "Use Windows" for the operations you want to be able to undo / redo (Delete or/and Copy or/and Move).
- Alternatively, use "Use FreeCommander" and then select "Use Vista method for all drives" for "Copy/Move with Vista and higher - if "Use FreeCommander" is active:", this way Undo / Redo will be working for all operations.
- Undo / Redo always work when using the context menu and "Cut", "Copy", "Paste" items and when using keyboard shortcuts Ctrl+X / Ctrl+C / Ctrl+V.

- Now download and unpack the program HotkeyP.
- Run HotkeyP.exe (Windows or Antivir programs may block this program, so you may need to unblock it, it's safe to use).
- Set the path for hotkeys (Ctrl+S), use any name and save it.
- Now you need to create multiple items, use menu > Hotkey > Insert new (or Insert key) to open dialog.
- For each line / hotkey use the Hotkey / Command / Parameters below (Hotkey is needed only for two items).

Code: Select all

# | Hotkey  | Command                                       | Parameters
--+---------+-----------------------------------------------+--------------------
1 | Win+Z   | Multi command                                 | 2 3 4 5 6
2 |         | C:\Windows\System32\explorer.exe              |
3 |         | Hide application                              | explorer.exe
4 |         | Macro                                         | \sleep1
5 |         | Macro to active window                        | \ctrl.z explorer.exe
6 |         | Close window                                  | explorer.exe
7 | Win+Y   | Multi command                                 | 2 3 4 8 6
8 |         | Macro to active window                        | \ctrl.y explorer.exe
Notes:
- You need to type the parameters for # 1 and # 7 when you create the other items.
- To type the hotkey, click within the hotkey field next to "Win" type Z and then mark the "Win" checkpoint ( [v] Win ).
- Win+Z / Win+Y for Undo / Redo are recommended keyboard shortcuts, you can use any, but these shortcuts are global, so Ctrl+C / Ctrl+Y are NOT recommended!
- If your computer is slow, you might need to increase the number next to \sleep .
- Windows Explorer window always blinks, when using this feature, it's normal, it can't be hidden completely now.
- HotkeyP includes the Help in English and few other languages.

Now it should be working, Win+Z to Undo and Win+Y to Redo, even for multiple actions, e.g. if you delete two files one by one, when you use Win+Z and then Win+Z again, both files will be restored.

Please test it and report any issues.

User avatar
BGM
Posts: 594
Joined: 14.10.2008, 23:42
Location: Kansas City, Missouri, USA
Contact:

Re: Working UNDO / REDO feature workaround

#2 Post by BGM » 17.09.2017, 17:58

Dreamer,

You say to set the Copy/Move/Delete settings all to "Use FreeCommander".
But then you are sending hotkey commands to Windows Explorer.

I don't understand how Explorer can undo an action performed in FC.


Okay, I did test a little bit.
In FC I have the settings all set to "Use FreeCommander".
So in a folder open in FC, I delete a file.
Now if I open that folder in Explorer and push ctrl+z, it does undelete it!

Next, I used keyboard commands to cut and paste a file from one FC folder to another.
Then, in explorer, I was able to ctrl+z to undo it.

Now, in the splitter toolbar, I have a button called "Move: Move ; Moves the selected items. The command executor is depending on the settings" and a corresponding button for "copy".
Explorer could not undo commands performed with these buttons.
If I understand correctly, the "command executor depending on the settings" is however it is set in Settings > File/folder operations > General; in which case mine are set to "Use FreeCommander", and at the bottom, the dropdown is set to "Use FreeCommander Method".
With these settings, Explorer could not undo changes.
However, if, in that last dropdown I change it to "Use Vista method for all drives" - THEN Explorer can undo changes!

Dreamer's approach with HotkeyP simply opens Windows Explorer to the folder set in FC's active panel and then sends Explorer hotkeys to Explorer.
If the settings are correct in FC, then Windows can recognize the file operations performed by FC.

Attached is a screenshot of the proper settings.
Attachments
screenshot_FreeCommander_024.png
screenshot_FreeCommander_024.png (33.52 KiB) Viewed 20191 times
(Windows 10-1909 Professional 64bit)

User avatar
Dreamer
Site Admin
Posts: 6115
Joined: 19.08.2007, 23:40

Re: Working UNDO / REDO feature workaround

#3 Post by Dreamer » 17.09.2017, 18:43

BGM wrote: 17.09.2017, 17:58You say to set the Copy/Move/Delete settings all to "Use FreeCommander".

However, if, in that last dropdown I change it to "Use Vista method for all drives" - THEN Explorer can undo changes!
Of course, it should be vice versa, sorry, fixed. :oops:

When using "Use Windows" Undo will work, when using "Use FreeCommander" and last drop-down option "Use FreeCommander method", it will NOT work, but when using "Use FreeCommander" and the last drop-down is "Use Vista method for all drives", it will work.
BGM wrote: 17.09.2017, 17:58Dreamer's approach with HotkeyP simply opens Windows Explorer to the folder set in FC's active panel and then sends Explorer hotkeys to Explorer.
If the settings are correct in FC, then Windows can recognize the file operations performed by FC.
Actually it just opens Explorer window, path change as in FC is not needed.

With a known workaround, you can open Explorer window, right click the empty space and select "Undo", or press Ctrl+Z, then close Explorer. With this workaround you just press Win+Z and everything is done automatically.

If you don't want to use HotkeyP, there's another workaround, you need to use Explorer by default, Win+E should be set to open explorer, then you can press Win+E, Ctrl+Z, Alt+F4. Of course, only when using Windows operations in FC.

User avatar
BGM
Posts: 594
Joined: 14.10.2008, 23:42
Location: Kansas City, Missouri, USA
Contact:

Re: Working UNDO / REDO feature workaround

#4 Post by BGM » 18.09.2017, 15:40

Haha! Here's an easier way!

Just put this code in an autohotkey script (courtesy of the ahk forum):

Code: Select all

PostMessage, 0x111, 28699, 0, SHELLDLL_DefView1, % "ahk_id " hWnd ;WM_COMMAND := 0x111 ;Undo last action

Code: Select all

PostMessage, 0x111, 28704, 0, SHELLDLL_DefView1, ahk_class Progman	;send redo last action command to desktop
Then make each script into a button in FreeCommander.
The commans send a SM_COMMAND message to Windows desktop to perform the Explorer action.
It works for me in Windows 7.

I can undo and redo file deletions, move and copy operations (if the settings are set right in FC - they are necessary so that Windows Explorer knows when things have been accomplished).
(Windows 10-1909 Professional 64bit)

JanHekkerman
Posts: 2
Joined: 10.04.2019, 15:59

Re: Working UNDO / REDO feature workaround

#5 Post by JanHekkerman » 10.04.2019, 16:07

BGM wrote: 18.09.2017, 15:40 Then make each script into a button in FreeCommander.
Hi, thanks for sharing this workaround. I'm trying to implement this handy feature. I've installed AutoHotKey and created the 2 .ahk files. But how can I add this scripts to a toolbar button? I have no idea which option I need to choose from the Customize Toolbar menu? There's no option such a "Create New Button"...

stephen147
Posts: 370
Joined: 18.10.2015, 16:44

yes, there is...

#6 Post by stephen147 » 17.05.2019, 15:49

JanHekkerman wrote: 10.04.2019, 16:07 There's no option such a "Create New Button"...
http://www.forum.freecommander.com/view ... ons#p21994
Sceenshots made easy with ShareX.

JanHekkerman
Posts: 2
Joined: 10.04.2019, 15:59

Re: Working UNDO / REDO feature workaround

#7 Post by JanHekkerman » 17.05.2019, 16:07

Thanks buddy ;)

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 37 guests