[SOLVED] Batch file

Dec 30, 2021
3
1
10
Hi, I'm a new member and hope I can get some help in this well-known forum if I have a problem :-|

My question is,
I would like to open Downloads in the Windows 11 Explorer, then the Focus should be on the Left Panel, then press Home so that the cursor in the Left Panel is Above.
Then I can see the Downloads in the Right Panel and I can also see all Quick access files in the Left Panel.

This is working fine
Name batch fie: Open Download.bat
(@Echo off)
cd C:\Users\Name\
start Downloads

But... now I hope it is also possible to add the other operations in this batch file?
I've read that Shift + F6 puts focus on the left panel, but I don't know how to place the commands :-(


Regards,
Jamo48
 
Solution
As far as I know, you will have to use some type of scripting software to send the keystrokes. I'm not sure if Visual Basic Scripting can do it or not. If so, that may be an avenue you will want to look into.

Personally, I would use AutoHotKey. Download the current version and install it (Express install is easiest). Note: I don't currently have Win11. I'm using Win10 but I think the script will be the same for both.

Note that running AHK simply opens the help file. It needs a script to do anything. Open Notepad and copy/paste the following script into it. Save the file in Notepad as OpenFolder.AHK. Be sure you have that .AHK file extension on the end.
Code:
; Created by gardenman Dec 30, 2021 for
...
Here the File Explorer opened as I would like it to go?

43198717c8.png
 
As far as I know, you will have to use some type of scripting software to send the keystrokes. I'm not sure if Visual Basic Scripting can do it or not. If so, that may be an avenue you will want to look into.

Personally, I would use AutoHotKey. Download the current version and install it (Express install is easiest). Note: I don't currently have Win11. I'm using Win10 but I think the script will be the same for both.

Note that running AHK simply opens the help file. It needs a script to do anything. Open Notepad and copy/paste the following script into it. Save the file in Notepad as OpenFolder.AHK. Be sure you have that .AHK file extension on the end.
Code:
; Created by gardenman Dec 30, 2021 for
; https://forums.tomshardware.com/threads/batch-file.3742212/
;
; Parts of this script grabbed from various websites including:
; [url=https://www.autohotkey.com/boards/viewtopic.php?t=66133]https://www.autohotkey.com/boards/viewtopic.php?t=66133[/url]

FOLDERID_Downloads := "{374DE290-123F-4565-9164-39C4925E467B}"
RegRead, v, HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders, % FOLDERID_Downloads
VarSetCapacity(downloads, (261 + !A_IsUnicode) << !!A_IsUnicode)
DllCall("ExpandEnvironmentStrings", Str, v, Str, downloads, UInt, 260)
; MsgBox, % downloads
Run % downloads

WinWait, Downloads

Send, {Shift}+{F6}
Send, {Home}

Now you have the OpenFolder.AHK script that you can try (double click to run it).

Once you are happy with it, right click on the OpenFolder.AHK and choose Compile. Give it a second and it will create a .EXE file for you. Now you can keep the OpenFolder.exe file and even uninstall AutoHotKey if you like. The .EXE file will continue to work.
 
Solution
Dear Mr. Gardenman,
I'm very pleased with your solution, this is very helpful for me.
I installed AHK some time ago, but a little later I uninstalled AHK because I couldn't use it.
Now I have seen that AHK is very useful and I am happy with it, but now I need time to understand the process properly.
In the meantime, I have also made an executing file as you described, which is working fine.
Thank you very much. :hello:

bye,
Jamo48
 
  • Like
Reactions: gardenman