Convert any file with AutoHotkey and Filestar
AutoHotkey is a popular automation tool for Windows and combined with the Filestar CLI you can convert files with a simple keystroke.
The following example shows how to setup a hotkey for converting any (applicable) file to the PNG-format by selected with file and then pressing CTRL+ENTER.
- Install AutoHotkey and Filestar.
- Create a .ahk (i.e. myhotkeys.ahk) file with the code listed below.
- Double click on the .ahk file. The shortcut is now active.
- Place a file (for example a .jpg file) on your desktop and single click it so it’s selected.
- Not press CTRL+ENTER.
- Filestar will now convert the file to a PNG and store it in the same folder.
^Enter:: Backup := ClipboardAll Clipboard = Send, ^c ClipWait, 1 If FileExist(Clipboard) { Command := "C:\Program Files (x86)\Filestar\filestarcli.exe -i """ . Clipboard . """ -c ""convert to png""" Run, %Command%,,Min } Clipboard := Backup return
How it works
^Enter::...return
specifies the hotkey, where ^ is Ctrl and Enter is Enter. Change if you want some other hotkey.Backup := ClipboardAll
backs up all data stored in the clipboard.Clipboard =
clears the clipboard.Send, ^c
simulates pressing the keys CTRL+C to copy the selected file to the clipboard.ClipWait, 1
waits for up to one second for the clipboard to contain any data.If Type = FileExist(Clipboard)
check if the clipboard's content points to an actual file.Command := "C:\\\\Program Files (x86)\\\\Filestar\\\\filestarcli.exe -i """ . Clipboard . """ -c ""convert to png"""
is the filestarcli command line that is to be executed. Change the -c parameter for other commands. Also make sure the path to filestarcli.exe is where you have installed Filestar.Run, %Command%,,Min
runs the command line stored in the variable%Command%
.Min
means run minimized. Change this toHide
if you don't want to see the Filestar window at all.Clipboard := Backup
restores the inital clipboard data.