batch-script for finding shortcut-keys
Posted: 26 Nov 2013 08:07
This thread made me think about a way to use a pure batch-script for finding and displaying all shortcut keys.
The program will create a file where all .lnk / .pif / .url files will be listed (%tmp%\shortcutlist.txt).
Then it will search every file listed for every possible shortcut-key combination
and lists them in a seperate file (%tmp%\shortcutkeys.txt).
That will take quite a while and there will be "false positives".
But those can be tested by pressing the shown key combinations.
Update:
The program searches now for letter-, number-, numpad- and function-keys.
It will do so very slowly. If anyone has an idea how to speed up the search, please let me know.
the output will be similar to this:
edit: posted new code, added information in comments, added example output, renamed output files, corrected output sample, corrected small mistake
The program will create a file where all .lnk / .pif / .url files will be listed (%tmp%\shortcutlist.txt).
Then it will search every file listed for every possible shortcut-key combination
and lists them in a seperate file (%tmp%\shortcutkeys.txt).
That will take quite a while and there will be "false positives".
But those can be tested by pressing the shown key combinations.
Update:
The program searches now for letter-, number-, numpad- and function-keys.
It will do so very slowly. If anyone has an idea how to speed up the search, please let me know.
Code: Select all
::
:: batch script for scanning for shortcut keys
::
:: the more shortcuts (.lnk, .pif, .url) there are
:: the longer this program will take to complete
:: the scan. as of now punctuation keys are excluded
::
@echo off
SETLOCAL ENABLEDELAYEDEXPANSION
:: creating shortcut list
echo: creating shortcut list...
pushd "%UserProfile%\AppData\Roaming\Microsoft\Windows\Start Menu"
dir *.lnk *.url *.pif /b /s /a-d >%tmp%\shortcutlist.txt
popd
pushd "%UserProfile%\Desktop"
dir *.lnk *.url *.pif /b /s /a-d >>%tmp%\shortcutlist.txt
popd
pushd "%AllUsersProfile%\Microsoft\Windows\Start Menu\"
dir *.lnk *.url *.pif /b /s /a-d >>%tmp%\shortcutlist.txt
popd
echo: scanning for assigned keys... this WILL take a while!
echo: begin of list>%tmp%\shortcuts.txt
:: checking every listed file in %tmp%\shortcutlist.txt
for /f "tokens=*" %%a in (%tmp%\shortcutlist.txt) do (
for %%x in ( ♠ ♣ ♥ • ) do (
for %%z in ( A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 p q r s t u v w x y z { ` a b c d e f g h i j k m n o ) do (
if "%%x"=="♠" set "comb=ctrl + alt + "
if "%%x"=="♣" set "comb=shift + alt + "
if "%%x"=="♥" set "comb=ctrl + shift + "
if "%%x"=="•" set "comb=ctrl + alt + shift + "
set "key=%%z"
if "%%z"=="p" set "key=F1"
if "%%z"=="q" set "key=F2"
if "%%z"=="r" set "key=F3"
if "%%z"=="s" set "key=F4"
if "%%z"=="t" set "key=F5"
if "%%z"=="u" set "key=F6"
if "%%z"=="v" set "key=F7"
if "%%z"=="w" set "key=F8"
if "%%z"=="x" set "key=F9"
if "%%z"=="y" set "key=F10"
if "%%z"=="z" set "key=F11"
if "%%z"=="{" set "key=F12"
if "%%z"=="`" set "key=Numpad 0"
if "%%z"=="a" set "key=Numpad 1"
if "%%z"=="b" set "key=Numpad 2"
if "%%z"=="c" set "key=Numpad 3"
if "%%z"=="d" set "key=Numpad 4"
if "%%z"=="e" set "key=Numpad 5"
if "%%z"=="f" set "key=Numpad 6"
if "%%z"=="g" set "key=Numpad 7"
if "%%z"=="h" set "key=Numpad 8"
if "%%z"=="i" set "key=Numpad 9"
if "%%z"=="j" set "key=Numpad *"
if "%%z"=="k" set "key=Numpad +"
if "%%z"=="m" set "key=Numpad -"
if "%%z"=="n" set "key=Numpad ,"
if "%%z"=="o" set "key=Numpad /"
findstr /M %%z%%x %%a 2>nul && echo: %%a - !comb! !key!>>%tmp%\shortcutkeys.txt
)
)
)
echo: scan complete
echo: end of list>>%tmp%\shortcutkeys.txt
start %tmp%\shortcutkeys.txt
goto :eof
the output will be similar to this:
Code: Select all
D:\cap.lnk - ctrl + alt + P
D:\casp.url - ctrl + alt + shift + P
D:\ca1.pif - ctrl + alt + 1
D:\caf1.lnk - ctrl + alt + F1
D:\canp1.lnk - ctrl + alt + Numpad 1
edit: posted new code, added information in comments, added example output, renamed output files, corrected output sample, corrected small mistake