Global Hotkey support

In addition to defining a menu entry hotkey by using a .txt file or a .mnu file, you can define global hotkeys in the MyE2B.cfg file which will act on all menus.

As soon as the user presses a hotkey (e.g. presses the F4 key) in any menu, the command assigned to the hotkey will immediately run.

Some examples can be found in the \_ISO\Sample_MyE2B.cfg files.

Avoid using SHIFT+ P, C, E or B for hotkeys as these are used by grub4dos for password entry and editing, etc. 

Note: Ctrl+M will work correctly if a hotkey has been defined for it, but if no hotkey has been defined it for it then it will generate the same keyboard scan code as the [ENTER] key.

Also, for global hotkeys, it is also best to avoid using the  CTRL key if it causes an OS to boot (e.g. don’t use Ctrl+F4 to run a linux ISO from a hotkey because the Ctrl key may modify the behaviour of the ISO when it runs – e.g. some linux ISOs).

Note: Not all key combinations can be used as the keyboard/BIOS does not generate a scan code for certain combinations (e.g. Ctrl+3). See here for a list of valid hotkey combinations.

Tip: It is best to avoid using alt+ hotkeys because some non-USA keyboards use alt+(letter) or alt+(number) and these may be remapped (e.g. alt+v may be remapped to @ on a Hungarian keyboard which means that alt+v would not work as a hotkey.

E2B v1.A8+ has a global hotkey for Ctrl+F8 already defined (Ctrl+F8 reloads grub4dos and E2B).

Run any .iso or payload file from a hotkey

For instance, set up the F11 hotkey to always run a the Ubuntu Live ISO (or any ISO file) from any menu, by adding the line below to your \_ISO\MyE2B.cfg file:

(bd)/%grub%/hotkey [F11] "(bd)/%grub%/qrun.g4b force.isodefault  (bd)/_ISO/MyUbuntu.iso ;; boot" > nul

Note that using F11 and F12 as hotkeys may not always work on some notebooks because the keyboard scan codes may vary! Using F1-F10 should be OK.

Global hotkeys do not use a menu entry and so are invisible to the user. If you want the user to know what global hotkeys are available, add text to the HELPTEXT variable in the MyE2B.cfg file or to your background bitmap. The hotkeys that you define will be active for all the menus. See \_ISO\docs\Templates\TextMinimal\MyE2B.cfg for an example.

Another example – press SHIFT+F2 to boot to Hirens:

(bd)/%grub%/hotkey [Shift+F2] "(bd)/%grub%/qrun.g4b (bd)/_ISO/Hirens.isowinvh ;; boot" > nul

When a hotkey is pressed, the commands will be executed. If you don’t want  any grub4dos messages to be displayed, precede the command list with @ – e.g.

(bd)/%grub%/hotkey [Shift+F2] "@(bd)/%grub%/qrun.g4b (bd)/_ISO/Hirens.isowinvh ;; boot" > nul

Run a .mnu file from a hotkey

If you want to set up a .mnu file to run from a hotkey (e.g. you run a linux Mint ISO with persistence using the linuxmint-17-mate-32bit-v2.mnu menu file) it is a little more tricky! 

Suppose you already have a working iso and .mnu file in the \_ISO\LINUX\Linux folder 

\_ISO\LINUX\Linux\linuxmint-17-mate-32bit-v2.mnu
\_ISO\LINUX\Linux\linuxmint-17-mate-32bit-v2.iso 

and you want to set up the F4 key to run the .mnu file so you can run Mint with persistence just by pressing F4 in any E2B menu: 

1. Make a copy of the .mnu file in the \_ISO folder (any file name will do), e.g. \_ISO\F4_Hotkey.mnu 
2. Edit the new file as follows:
    a. Delete the line beginning with title or iftitle (e.g. comment it out with #)   
b. Change any occurrences of $HOME$ to the path of the ISO file   
c. Change any occurrences of $NAME$ to the name of the ISO file 

Example: The lines in red below have been edited (note # on first line has been added):

iftitle [if exist $HOME$/linuxmint-17-mate-32bit-v2.iso] Mint\n Boot using .mnu file with persistence
set ISO=linuxmint-17-mate-32bit-v2.iso
set PER=/mint-rw
 
if exist CD echo WARNING: Cannot use partnew command! && pause && configfile (bd)/menu.lst
if "%E2BDEV%"=="" set E2BDEV=hd0 && pause E2BDEV forced to hd0!
#enable parttype output
debug 1
# make empty table entry in 3rd position in ptn table
parttype (%E2BDEV%,2) | set check=
debug off
set check=%check:~-5,4%
if "%check%"=="0x00" partnew (%E2BDEV%,2) 0 0 0
if not "%check%"=="0x00" echo WARNING: PTN TABLE 3 IS ALREADY IN USE - PERSISTENCE MAY NOT WORK! && pause
debug 1
if not exist %PER% echo WARNING: %PER% persistence file not found! && pause
errorcheck off
if "%check%"=="0x00" partnew (%E2BDEV%,2) 0x0 %PER%
errorcheck on
#map ptn 4 to ISO
partnew (%E2BDEV%,3) 0x0 /_ISO/LINUX/Linux/%ISO%
map /_ISO/LINUX/Linux/%ISO% (0xff)
map --hook
root (0xff)
errorcheck on
kernel /casper/vmlinuz file=/cdrom/preseed/linuxmint.seed boot=casper persistent
# quiet splash --
initrd /casper/initrd.lz
boot

3. Add the hotkey entry to the \_ISO\MyE2B.cfg file: 

(bd)/%grub%/hotkey [F4] "configfile (bd)/_ISO/F4.mnu" > nul 

You can now press F4 in any menu (or whilst E2B is booting) and it will immediately run your .mnu file. 

Disable a hotkey

#Disable Ctrl+F8 hotkey
(bd)/%grub%/hotkey [Ctrl+F8] 

The command above will disable the Ctrl+F8 hotkey which may already be pre-set in E2B (v1.A8+).

Actually, hotkey [Ctrl+F8] will also work in E2B.

Tip: If you type hotkey in the grub4dos console command line, it will list all current registered global hotkeys. Type ‘debug 2’ first if no hotkeys are listed as the debug value needs to be >1 for some versions.

# Set Ctrl+F8 hotkey to Reload E2B (if E2B menu not working correctly)
(bd)/%grub%/hotkey [Ctrl+F8] "@map --unhook ;; map --unmap=0:0xff ;; root (bd) ;; chainloader /grldr ;; boot" > nul

Note for Advanced tweakers only!

Any global hotkey that is set, will exist for ALL menus and sub-menus and you cannot change or remove a hotkey command unless you add a .mnu file that is loaded first (e.g. starts with $$$ so it is added before other payload and .mnu files)

For example: If you want F11 to automatically run Ubuntu, but only when you are in the LINUX menu, and do not want the menu entry to be visible in the menu… 

1. Create a \_ISO\LINUX\$$$HotkeyUbuntu.mnu file containing this single line of text:

(bd)/%grub%/hotkey [F11] "(bd)/%grub%/qrun.g4b force.isodefault  /_ISO/MyUbuntu.iso ;; boot" > nul

2. Add your MyUbuntu.iso file to the \_ISO folder.

Note that once the Linux menu is loaded, the F11 hotkey will now work in every menu unless you redfine the hotkey or clear it. For instance, if you added  (bd)/%grub%/hotkey [F11] > nul 
to a new ClearF11.mnu file in the \_ISO\MAINMENU\!!CONFIG folder, then when the Main menu was loaded, the F11 hotkey would be cleared.

Note: F11 and F12 may not be available or may not work on all systems – use only F1-F9 if possible (with Alt or Ctrl if needed). 

Tip: You can define a global hotkey in the \_ISO\MyE2B.cfg file so that it will work in all menus and sub-menus.

New! Ventoy for Easy2Boot v1.0.97 now released!

 

eBooks available (in PDF format)

Easy-to-read eBooks are available in PDF format (each eBook is over 100 pages) – rated 4.5/5 stars.
Learn the secrets of Legacy and UEFI USB booting and then make your perfect multiboot USB drive.
E2B eBook #1 includes instructions on how to remove the E2B 5-second start-up delay blue screen.

E2B is unique in that it uses partition images which allows you to directly boot from Secure Boot images (no need to disable Secure Boot or run MOK manager or modify your UEFI BIOS).

Most eBooks are over 100 pages long, contain original content and step-by-step exercises which are suitable for both the beginner or the more experienced user.
Customer reviews are located at bottom of each eBook product page and multi-buy discounts are available when you buy more than one eBook. Please also visit RMPrepUSB.com and the E2B Forum.
Subscribe to my blog for the latest news, tips, USB boot articles and free eBook updates.