I've created a hotkey (type) utility. It allows you to define Shotkeys (or keywords associated with applications / folders ) for your favorite programs / web sites / text files / folders. You may create as many Shotkeys as you want for each program. For example Internet Explorer might be 'ie' or 'iex' or 'iexplore' or all the above.
Press Backquote(`) which pops up a window on the bottm right corner of the screen and enter the Shotkey for the program you might want to launch.
It also creates a right click context menu. Thus you could right click on an icon, and define the Shotkey for the associated program.
Check it out and tell me what you think.
Download Shotkey
Homepage
Shotkey 1.0 Beta version
Started by
fundaman123
, Apr 05 2006 06:14 PM
8 replies to this topic
#1
-
Posted 05 April 2006 - 06:14 PM
Hi Ramlal Bhagat,
Congrats to your first post and app.
It is generally common to provide the AHK code and not the compiled script. Mainly because people want to know what your code does and how it is done. It is also smaller in size. People can learn form your code and apply changes to their needs. Thanks
Congrats to your first post and app.
It is generally common to provide the AHK code and not the compiled script. Mainly because people want to know what your code does and how it is done. It is also smaller in size. People can learn form your code and apply changes to their needs. Thanks
#2
-
Posted 05 April 2006 - 07:48 PM
Ciao
toralf
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.
toralf
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.
Plus it allows to change the behavior, namely the hotkeys...
These are good ideas.
I use the RunFast freeware for similar functionnality, it adds autocompletion suggestions. For example, if you have "calc" and "comp" defined as shotkeys, when typing c it adds "alc" selected for easier removing. When typing o, it just completes to "mp", still selected, because you may want to finish typing "collect", which can be the filename of an application in the PATH.
These are good ideas.
I use the RunFast freeware for similar functionnality, it adds autocompletion suggestions. For example, if you have "calc" and "comp" defined as shotkeys, when typing c it adds "alc" selected for easier removing. When typing o, it just completes to "mp", still selected, because you may want to finish typing "collect", which can be the filename of an application in the PATH.
#3
-
Posted 06 April 2006 - 09:14 AM
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Is there any need for the second exe-file?
As far as I can see reading the code it is only a dialog?
Thalon
As far as I can see reading the code it is only a dialog?
Thalon
#4
-
Posted 07 April 2006 - 08:10 AM
actually no,
there is no need of a second exe.
the same exe would serve the purpose (with behaviour depending on whether a parameter has been passed or not ( 0 > 0 ))
The second exe was created for the right click context menu.
When any icon is right clicked, and the menu item Shotkey pressed, then the setshotkey.exe is invoked for insertion into the definition file.
For this an entry is made in the registry key
The same functionality can be achieved through one exe as well, since the registry invocation passes a parameter (the path of the application), while the normal invocation would not pass any such parameter.
there is no need of a second exe.
the same exe would serve the purpose (with behaviour depending on whether a parameter has been passed or not ( 0 > 0 ))
The second exe was created for the right click context menu.
When any icon is right clicked, and the menu item Shotkey pressed, then the setshotkey.exe is invoked for insertion into the definition file.
For this an entry is made in the registry key
HKEY_CLASSES_ROOT\*\shell\ShotKeyThe path of the application is passed as the parameter to the handling exe.
The same functionality can be achieved through one exe as well, since the registry invocation passes a parameter (the path of the application), while the normal invocation would not pass any such parameter.
#5
-
Posted 07 April 2006 - 04:16 PM
Here is the code ...
I've merged the functionality of the 2 exes into 1 code.
However, this code needs the shotkey.txt, shotkey.ico, shotkey-disabled.ico and the shotkey.ini files too.
The shotkey.ini and shotkey.txt files are read from the %appdata% folder. (Usually C:\Documents and Settings\Application Data\Shotkey). This is to allow multiple user profiles.
The icon files are present in the script directory.
Also the registry entries require admin rights.
I've merged the functionality of the 2 exes into 1 code.
However, this code needs the shotkey.txt, shotkey.ico, shotkey-disabled.ico and the shotkey.ini files too.
The shotkey.ini and shotkey.txt files are read from the %appdata% folder. (Usually C:\Documents and Settings\Application Data\Shotkey). This is to allow multiple user profiles.
The icon files are present in the script directory.
Also the registry entries require admin rights.
#singleinstance force menu, tray, icon, shotkey.ico, , 1 guiwidth:=120 guiheight:=20 gosub, Readfile if 0>0 { hotcount:=0 param=%0% autotrim, on gosub, ReadINI gosub, CreateGUI } else { gosub, CheckFirstRun gosub, ReadIni gui, 2:font, Courier New gui, 3:font, Courier New menu, tray, nostandard menu, tray, add, Disable, Disable menu, tray, add menu, tray, add, Options, Options menu, tray, add, QuickHelp, Help menu, tray, add, Website, Website menu, tray, add, About, About menu, tray, add menu, tray, default, Disable menu, tray, add, Exit, Exit ; also add checks to deal with missing ; env variables - appdata - default } return ;---------------------------------------------------------------------------------------------------- CheckFirstRun: ; check if the ini and txt files exist ; if not assume first run ... writeval="%a_scriptdir%\Shotkey.exe" "`%1" RegRead, rightclickfile, HKEY_CLASSES_ROOT, *\shell\ShotKey\Command if rightclickfile<>%writeval% { if %a_IsAdmin% { RegWrite, REG_SZ, HKEY_CLASSES_ROOT, *\shell\ShotKey\Command, ,%writeval% RegWrite, REG_SZ, HKEY_CLASSES_ROOT, Directory\shell\ShotKey\Command, ,%writeval% } } ; create the ini file ifNotExist, %appdata%\shotkey\shotkey.ini { filecreatedir, %appdata%\shotkey filecopy, %a_scriptdir%\shotkey.ini, %appdata%\shotkey\shotkey.ini } ; and the txt file ifNotExist, %appdata%\shotkey\shotkey.txt filecopy, %a_scriptdir%\shotkey.txt, %appdata%\shotkey\shotkey.txt ; create a startup entry - assume that the ini file says so ; since this is the first run it does not matter ifNotExist, %a_startup%\Shotkey.lnk filecreateshortcut, %a_scriptdir%\Shotkey.exe, %a_startup%\Shotkey.lnk ; look for the context right click too .. if not try inserting (only if admin rights) return ;---------------------------------------------------------------------------------------------------- ReadIni: ; read the ini file and act accordingly iniread, ow, %appdata%\shotkey\shotkey.ini, windows, optionwindow, 3 iniread, mw, %appdata%\shotkey\shotkey.ini, windows, mainwindow, 2 iniread, aw, %appdata%\shotkey\shotkey.ini, windows, aboutwindow, 4 iniread, readstartup, %appdata%\shotkey\shotkey.ini, startup, startup, 1 iniread, readtray, %appdata%\shotkey\shotkey.ini, startup, tray, 1 iniread, readhotkey, %appdata%\shotkey\shotkey.ini, behaviour, hotkey, ` if readtray=0 { menu, tray, noicon ; since tray icon is disabled .. ; show options gosub, options } if readstartup=0 { ; remove from the startup folder ; for now .. might convert to the ; registry later } ; assign read val to hotkey hotkey, %readhotkey%, Hotkey return ;---------------------------------------------------------------------------------------------------- Hotkey: ; To prevent shotkey window from being fired ; while in insert mode. If 0>0 return ; To fix multiple instances from crashing the ; program IfWinexist, ShotKey ahk_class AutoHotkeyGUI return gosub, CreateGUI return ;---------------------------------------------------------------------------------------------------- CreateGUI: Gui, %mw%:Add, Edit, x-1 y+1 w%guiWidth% h%guiHeight% Vcode, %hk% ; Changed the size of the button to 0,0 Gui, %mw%:Add, Button, w0 h0 Default gKey, Key wingetpos,trayX,trayY,trayWidth,trayHeight,ahk_class Shell_TrayWnd ; handle all cases of the tray window ; surprisingly non-value comparisons work if (trayWidth>=A_screenwidth and trayY>=A_screenheight/2) { guiX:=A_screenWidth - guiWidth guiY:=trayY - guiHeight } else if (trayHeight>=A_screenheight and trayX>=A_screenwidth/2) { guiX:=trayX - guiWidth guiY:=A_screenheight - guiHeight } else { guiX:=A_screenwidth - guiWidth guiY:=A_screenheight - guiHeight } Gui, %mw%:Show, x%guiX% y%guiY% w%guiWidth% h0, ShotKey gui, %mw%:+alwaysontop -caption +theme winset, Alwaysontop, ON, ShotKey gui, %mw%:color, EEAA99 Winset, Transcolor, EEAA99, ShotKey sleep, 100 controlfocus, Edit1, ShotKey return ;---------------------------------------------------------------------------------------------------- Key: Gui, %mw%:submit If 0>0 { ; Creating Shotkey ; If Shotkey found in the description file ; is different from the Shotkey entered in the GUI ; then create entry in the file if hk<>%code% fileappend, %code% | %1%`n, %appdata%\Shotkey\shotkey.txt 0:=0 Reload } else { ; Entering Shotkey ; search for matching hotstring if code= { gui %mw%:destroy return } if code=quit Exitapp if code=opt { gui %mw%:destroy gosub, options return } ; reset ha ha= loop, %hotcount% { h:=hotkey%a_index% ; need to resolve variables over here if code=%h% { ha:=hotapp%a_index% Transform, ha, deref, %ha% } } ; retrieve the path as well ; some apps dont work without it stringgetpos, pathend, ha, R1 stringleft, hp, ha, %pathend% if not ha= ; app found { hp:=getpath(ha) if getext(ha)=bat batrun(ha,hp) else run, %ha%, %hp%, UseErrorLevel If Errorlevel { error=Unable to execute %ha% HandleError(error) } } else ; not yet found { gosub, Readfile ; read the file ... check for new entries loop, %hotcount% ; loop again { h:=hotkey%a_index% h:=h if code=%h% ; if found this time then run { ha:=hotapp%a_index% Transform, ha, deref, %ha% } } if ha= ; else play sound and quit soundplay, %a_scriptdir%\disable.wav else { hp:=getpath(ha) if getext(ha)=bat batrun(ha,%hp%) else run, %ha%, %hp%, UseErrorLevel If Errorlevel { error=Unable to execute %ha% HandleError(error) } } } } Gui %mw%:destroy return ;---------------------------------------------------------------------------------------------------- ; shifted the read file routine to a sub Readfile: hotcount:=0 loop, read, %appdata%\shotkey\shotkey.txt { hotcount:=hotcount+1 stringsplit,arr, a_loopreadline, | hotkey%hotcount%=%arr1% hotapp%hotcount%=%arr2% } loop, %hotcount% { ha:=hotapp%a_index% ; No blank lines allowed as app path ; Could create trouble If ha= continue if 1=%ha% { hk:=hotkey%a_index% } } return ;---------------------------------------------------------------------------------------------------- ; transfer control here in case of bat file ; needs to be tested ... BatRun(app, apppath) { run, cmd /c %app%, %apppath%, UseErrorLevel If Errorlevel { error=Unable to run the batch command %app% HandleError(error) } } ;---------------------------------------------------------------------------------------------------- GetPath(app) { stringgetpos, pathend, app, \, R1 stringleft, path, app, %pathend% return path } ;---------------------------------------------------------------------------------------------------- GetExt(app) { stringright, ext, app, 3 ; just get 3 chars .. don't care if a . gets picked up ; since bat is the only test to be carried out ... return ext } ;---------------------------------------------------------------------------------------------------- HandleError(msg) { Msgbox, 4112, Error - ShotKey 1.0, %msg% } ;---------------------------------------------------------------------------------------------------- Options: Gui %ow%:destroy ; destroy any existing GUI if readstartup Gui, %ow%:Add, Checkbox, x16 y17 w170 h20 vStartup Checked, Load at Windows Startup else Gui, %ow%:Add, Checkbox, x16 y17 w170 h20 vStartup, Load at Windows Startup if readtray Gui, %ow%:Add, Checkbox, x16 y47 w170 h20 vTray Checked, Tray Icon else Gui, %ow%:Add, Checkbox, x16 y47 w170 h20 vTray, Tray Icon Gui, %ow%:Add, Hotkey, x16 y77 w100 h20 vHotkey, %readhotkey% Gui, %ow%:Add, Text, x126 y77 w60 h20, Hotkey Gui, %ow%:Add, Button, x16 y117 w80 h20 gOKOpt, OK Gui, %ow%:Add, Button, x106 y117 w80 h20 gCancelOpt, Cancel Gui, %ow%:Show, Center h153 w205, Shotkey Options Gui, %ow%:-sysmenu sleep, 100 winactivate, Shotkey Options return ;---------------------------------------------------------------------------------------------------- ; Destroy all windows from 1-10 ; This has been provided to avoid ; the same window being used for ; different purposes (options / main window) ; and hence creating problems. GUIEscape: WindowClose(1) return 1GUIEscape: WindowClose(1) return 2GUIEscape: WindowClose(2) return 4GUIEscape: WindowClose(4) return 5GUIEscape: WindowClose(5) return 6GUIEscape: WindowClose(6) return 7GUIEscape: WindowClose(7) return 8GUIEscape: WindowClose(8) return 9GUIEscape: WindowClose(9) return 10GUIEscape: WindowClose(10) return ;---------------------------------------------------------------------------------------------------- GUIClose: WindowClose(1) return 1GUIClose: WindowClose(1) return 2GUIClose: WindowClose(2) return 3GUIClose: WindowClose(3) return 4GUIClose: WindowClose(4) return 5GUIClose: WindowClose(5) return 6GUIClose: WindowClose(6) return 7GUIClose: WindowClose(7) return 8GUIClose: WindowClose(8) return 9GUIClose: WindowClose(9) return 10GUIClose: WindowClose(10) return ;---------------------------------------------------------------------------------------------------- ; Handle either the Escape key press or manual closing ; For insert mode, reset parameters and reload ; For execute mode, just destroy the window WindowClose(i) { ; define param as global global 0 If 0=0 Gui %i%:destroy else { param:=0 Reload } } ;---------------------------------------------------------------------------------------------------- CancelOpt: gui %ow%:destroy return ;---------------------------------------------------------------------------------------------------- OKOpt: gui %ow%:submit iniwrite, %startup%, %appdata%\shotkey\shotkey.ini, startup, startup iniwrite, %tray%, %appdata%\shotkey\shotkey.ini, startup, tray iniwrite, %hotkey%, %appdata%\shotkey\shotkey.ini, behaviour, hotkey ; no need to restart ; do the necessary ops here if tray=0 menu, tray, noicon else menu, tray, icon hotkey, %hotkey%, Hotkey gui %ow%:destroy return ;---------------------------------------------------------------------------------------------------- Disable: suspend, toggle menu,tray, togglecheck, Disable if A_issuspended menu, tray, icon, shotkey-disabled.ico,,1 else menu, tray, icon, shotkey.ico,,1 return ;---------------------------------------------------------------------------------------------------- Exit: ExitApp return
#7
-
Posted 08 April 2006 - 01:28 AM
i think it is a well done software.
autocomplete support would be useful.
you could also provide drag-drop support (while creating)
autocomplete support would be useful.
you could also provide drag-drop support (while creating)
#8
-
Posted 12 April 2006 - 03:06 PM
hi i recently tried shotkey and i couldnt seem to completely uninstall it. the shotkey always show up on the menu whenever i right click on a folder. Installing and unstalling it doesn't work either. Please somebody help me.
#9
-
Posted 15 March 2007 - 12:21 PM