Access your config files rapidly (Win32 only)
Posted on 12/2/07 by Felix Geisendörfer
For the past 2 days I've been setting up my new desktop pc. If you are like me and you run 9999 different apps, all of them with custom configurations and also need to setup php4+php5 and mysql4+mysql5 to run parallel you can probably feel my pain ; ). Anyway while setting up my WAMP stack, I had to tweak my configuration files all the time. At some point I got tired of looking for them after having previously closed them thinking I was done and decided to automate things. I knew AutoHotkey was capable of scripting custom GUI's for a while, but never got around to use it, so I thought I should give it a try. The result is a neat little script that opens a window where I can pick my configuration file and have it opened for me in notepad (which is Notepad++ in my case):
If this sounds like something you could need as well, here comes the source for it:
[text]#c::
Gosub, ConfigWindow.Show
return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Class ConfigWindow
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ConfigWindow.Show:
Gui, +LabelConfigWindow.Gui. -MinimizeBox
Gui, Add, DropDownList, Choose1 vConfigFile x6 y7 w150, hosts|httpd.conf|httpd-vhosts.conf|php.ini (php4)|php.ini (php5)
Gui, Add, Button, Default gConfigWindow.Buttons.OpenFile.click x166 y7 w90 h20 , Open File
Gui, Show, Center h35 w269, Select Configuration File
return
ConfigWindow.Buttons.OpenFile.click:
Gui, Submit
if (ConfigFile = "hosts")
{
Run notepad C:\WINDOWS\system32\drivers\etc\%ConfigFile%
}
else if (ConfigFile = "httpd.conf")
{
Run notepad %A_ProgramFiles%\Apache\Apache2.2\conf\%ConfigFile%
}
else if (ConfigFile = "httpd-vhosts.conf")
{
Run notepad %A_ProgramFiles%\Apache\Apache2.2\conf\extra\%ConfigFile%
}
else if(ConfigFile = "php.ini (php4)")
{
Run notepad C:\windows\php.ini
}
else if(ConfigFile = "php.ini (php5)")
{
Run notepad C:\php\php5\php.ini
}
ConfigWindow.Close:
ConfigWindow.Gui.Close:
Gui Destroy
return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;[/text]
All it does is to bind the hotkey [Windows-key]+[C] to a function that will generate the little GUI where you can select a configuration file and then load this file via notepad if the ok button is pressed. The source looks a little messy and this is probably partly due to the fact that I just started to get into Autohotkey scripting today (not to speak of my pathetic OOP attempts ^^), but I think the language itself isn't quite elegant to begin with either. Anyway, I certainly got the job done in less than 30 minutes and I'm very pleased with the results. So let me know what you think of little development helpers like this and how your favorite shortcut-hacks look like ; ).
-- Felix Geisendörfer aka the_undefined
You can skip to the end and add a comment.
This post is too old. We do not allow comments here anymore in order to fight spam. If you have real feedback or questions for the post, please contact us.
[...] Alright, I hope some of you find this post useful. One last thing I got in line is that I want to point out yet another very useful tool for windows, called Taskix. It allows me to do one of the things that I've wanted to be able to do forever: to re-arrange my windows in the taskbar. You simply download it, start it, and from that point on you can simply drag and drop your opened windows to any position in the taskbar. Big thanks to Adrian Schlesinger who wrote it! [...]