Tijmen 09:53, 15 October 2009

One of my machines refused to install updates to the .NET Framework 3.5 sp1, both through auto-update and when installing manually. I finally fixed it by using Aaron Stebner's .NET framework cleanup tool and re-installing .NET. This tool radically removes all versions of the .NET framework, including IIS artefacts, registry entries, the works. I found this tool through a post on raymond.cc.

Note that this tool should probably not be the first thing to try; uninstalling and re-installing the .NET framework versions would probably a safer bet to try first.

Tijmen 01:06, 4 September 2009

launch_or_activateOne feature of the new Windows 7 SuperBar that I particularly like is the ability to pin applications. This creates a single button that can be used to both launch the application (when it isn't already running) or to activate it if the app was already active. What I like about this concept, is that it expresses the user's wish much better in this way: a button to run Word can now be used to just "give me Word, I don't care if it's already running".

Since I usually work more keyboard- than mouse-centric, I came up with a way to mimic this behavior in AutoHotkey. I wrote a script that offers the following functionality:

  • either start or activate a particular application (based on a shortcut key obviously, this being an AutoHotkey post)
  • if the application is already running, cycle through the active windows (useful for Firefox or Explorer windows)
  • make it easy to "force-launch": force a new instance/window, regardless of whether it was already up and running.
  • give visual feedback on the launched-or-activated application

It took me a little time to work out the AutoHotkey script syntax, especially for dealing with arrays. In the script you set up an array of shortcut information, which serves as a settings registry. It contains the following parts:

  • display label: text that is shown in the visual feedback
  • a (unique) name: this is used to bind that particular command to a hotkey
  • a groupname: if a groupname is given, the script tries to loop through all the windows that match the window ID that is assigned to this entry
  • windowId: set this to the "ahk_class" of the window. You can use Window Spy (right click on any running AutoHotKey script tray icon) to find out this value for each command you want to add to the registry. It will probably work with Windows titles as well, but I never tried this since that method is a lot less reliable.
  • runcommand: the actual command you want the shortcut to point to if it needs to launch the application (for instance, "c:\windows\system32\calc.exe")

Adding a entry goes like this:

;--1. SETUP
;     enter label, name, groupname, windowId, runcommand
AddShortcut("Windows Explorer", "Explorer", "ExplorerGroup", "ahk_class CabinetWClass", "C:\windows\explorer.exe /select,d:" )

The next step involves hooking up the shortcut keys. This is standard AutoHotkey suff, so please refer to the AHK manual for doing this. An example for Explorer and Firefox:

#E::MyNewActivate("Explorer")
+#E::MyRun("Explorer")
F19::MyNewActivate("FF")
+F19::MyRun("FF")

So, Windows key + E does the launch-or-activate trick, whereas Shift + Win + E forces a new Explorer window.

The rest of the script adds some visual eye candy that is in no way functionally necessary, but it gives a nice, semi-transparent window that fades quickly. The three possible windows are shown at the top of this post.

The entire script is listed below; click expand source to view or copy.

#InstallKeybdHook

;--AUTOEXEC SECTION

GroupArrayCount := 0
SetTitleMatchMode 2

;--DISPLAY SETTINGS
;
INITIAL_TRANSPARENCY := 150
DELTA_TRANSPARENCY := 25
INITIAL_DELAY := 400
DELTA_DELAY := 50

;--1. SETUP
;     enter label, name, groupname, windowId, runcommand
;
AddShortcut("Windows Explorer", "Explorer",   "ExplorerGroup", "ahk_class CabinetWClass", "C:\windows\explorer.exe /select,d:" )
AddShortcut("Outlook", "Outlook", "OutlookGroup", "ahk_class rctrl_renwnd32", "C:\Program Files (x86)\Microsoft Office\Office12\outlook.exe")
AddShortcut("Firefox", "FF", "FireFoxGroup", "ahk_class MozillaUIWindowClass", "C:\Program Files (x86)\Mozilla Firefox\firefox.exe" )
AddShortcut("Calculator", "Calculator", "", "ahk_class CalcFrame", "c:\windows\system32\calc.exe")

;--2. ASSIGN KEYS
; win + E does a "run or activate", shift + win + E forces a new window
#E::MyNewActivate("Explorer")
+#E::MyRun("Explorer")

F14::MyNewActivate("Outlook")
F19::MyNewActivate("FF")
+F19::MyRun("FF")

;--Ctrl + Shift + Esc starts Process Explorer (task manager on steroids)
+^Escape::MyNewActivate("PE")
#C::MyNewActivate("Calculator")
;
;--/AUTOEXEC SECTION


; FUNCTION SECTION
GlobalTrans := INITIAL_TRANSPARENCY

;--CloseWin has to be an AHK subroutine, SetTimer doesn't work with functions
;  also note: subroutines do not require the "global" keyword
;             to manipulate global vars
CloseWin:
  If (GlobalTrans <= 0)
  {
    Gui, Destroy  
  }
  else
  {
    WinSet Transparent, %GlobalTrans%, ahk_class AutoHotkeyGUI
    GlobalTrans := GlobalTrans - DELTA_TRANSPARENCY
    ; negative time means run only once
    SetTimer, CloseWin, -%DELTA_DELAY%
  }
return


ShowText(text, textColor)
{
  global
  GlobalTrans := INITIAL_TRANSPARENCY

  Gui, Destroy
  SetTimer, CloseWin, Off
  Gui +LastFound +AlwaysOnTop -Caption +ToolWindow
  Gui, Color, 404040
  Gui, Font, s32
  Gui, Add, Text, c%textColor%, %text%
  SetTimer, CloseWin, -%INITIAL_DELAY%
  Gui, Show, Center NoActivate
  WinSet Transparent, %GlobalTrans%, ahk_class AutoHotkeyGUI
}

AddShortcut(label, key, groupName, windowId, runCommand)
{
  global
  GroupArrayCount += 1
  Labels%GroupArrayCount% := label
  Keys%GroupArrayCount% := key
  if (groupName != "")
  {
    Groups%GroupArrayCount% := groupName
  }
  Ids%GroupArrayCount% := windowId
  Commands%GroupArrayCount% := runCommand
  if (groupName != "")
  {
    GroupAdd %groupName%,%windowId%
  }
}

MyNewActivate(key)
{
  global
  Loop %GroupArrayCount%
  {
    if (key == Keys%A_Index%)
    {
      local thisId := Ids%A_Index%
      local label := Labels%A_Index%
      if WinExist(thisId)
      {
        ShowText("switching to " . label, "Lime")
        local thisGroup := Groups%A_Index%
        if (thisGroup == "")
        {
          WinActivate %thisId%
        }
        else
        {
          GroupActivate %thisGroup%,r
        }
      }
      else
      {
        ShowText("launching " . label, "FF8800")
        local thisCommand := Commands%A_Index%
        run, %thisCommand%
      }
      break ; terminate the lookup
    }
  }
}

MyRun(key)
{
  global
  Loop %GroupArrayCount%
  {
    if (key == Keys%A_Index%)
    {
      local label := Labels%A_Index%
      ShowText("force new " . label, "FF3300")
      local thisCommand := Commands%A_Index%
      run, %thisCommand%
      break ; terminate the lookup
    }
  }
}

Note that line 46 should read If (GlobalTrans <= 0), but the AHK brush for SyntaxHighlighter gets a bit confused here (since the semicolon ";" is also the AHK comment character). I found this brush here.

Tijmen 08:50, 17 August 2009
I am sure I ran into this before, but it took me some time to figure out yet again. Something like that always shouts "blog it" to me, so here goes. I installed a ClickOnce application, that neatly installed itself and placed an appropriate shortcut in my start menu. I then fired up Launchy, rebuilt the catalog and started looking for the new app... which didn't show up.
Searching through the start menu using standard Windows functionality of win-key + start typing (which admittedly got a lot better and snappier in Windows 7, though nowhere near powerful enough for us pro-keystrokers) resulted in the correct shortcut, though.
Long story short: the ClickOnce shortcuts have an extension *.appref-ms. By adding that file type to the various directories that Launchy indexes (right click, options, catalog tab) and rebuilding the catalog, the shortcuts show up in Launchy as well. By the way, on my Windows 7 machine, the start menu shortcuts are in the following folders (I am not sure if Launchy sets those correctly from the start):
  • c:\ProgramData\Microsoft\Windows\Start Menu
  • c:\users\<username>\AppData\Roaming\Microsoft\Windows\Start Menu
Tijmen 09:18, 16 June 2009

I intend to dedicate several (short) posts on the various tools I use to increase my productivity. At some point I will post a complete list of my must-have tools, but for now I want to focus on a new find (for me): the Everything search engine, by voidtools. Everything is a very silly name for a tool and its functionality is not ground-breaking: it searches for files on your local machine, based on their filename. This is obviously not rocket science, but it has a few distinctive characteristics. The first is performance: it indexes an average system in seconds. Literally. Searching is very snappy as well. Another big advantage is its low footprint. it uses up very little memory and disk space, and since its indexing process is very fast, there is no noticeable background disk churning like you get with default Windows search or other third party tools.

So, after this intro there are a few things worth mentioning: using Everything together with Launchy, and setting up Everything on a fileserver.

 

Everything on a (personal) fileserver

Everything can only index local disks. It does not index network shares or other remote locations (so NAS users are out of luck I suppose). However, you can run Everything as a service on a file server and have your local Everything client connect to this server. As an alternative, you could just run Everything on the desktop at the server, but that requires staying logged in all the time. In any case, you need to install Everything on the server and make it start an ETP server.

To install everything as a service, you need to follow these steps:

  1. Install Everything on the server
  2. Disable "run on system start". Go to the tools menu, click options. On the general tab, uncheck "Start everything on system start up", and click OK
  3. Open up a command prompt, CD into the folder where Everything was installed, and enter everything.exe -install_service
  4. This installs the server, but it does not set the command line option correctly: it only runs Everything as a service for the local computer (i.e., the server), but we want Everything to run as an ETP server. To do this, type the following at the command prompt: sc config everything binPath= "c:\program files (x86)\everything\everything.exe -svc -host" (replacing the path with your install path of choice, obviously).
  5. Stop and start the service (either through control panel or the geeky way, by issuing net stop everything (sounds kind of cool), followed by net start everything).

After this, configuration is done. Fire up Everything on another computer connected to the file server and use the option "Connect to ETP server" on the tools menu. I've had to use the IP number of my server since it did not do a name lookup, but I am not running any local DNS or hosts file, so YMMV.

Side note: Everything defaults to opening networked files on shares named after the local drive letters, so it opens the folder documents on the E-disk of the server as \\server\E\documents\. Not a huge problem, but something to be aware of. I have not found a setting in the INI file (old skool!) to change this.

 

Using Everything from Launchy

This next bit is directly from Lifehacker. Simply add a shortcut in a location that is indexed by Launchy, and use "C:\Program Files (x86)\Everything\Everything.exe" -search as the target. Name it appropriately (for example, "find") and re-index Launchy. Now you can type "find", TAB, and enter your search text. In order to do a search on your fileserver, make another shortcut, but add -connect 192.168.1.1 before the -search  option. I've named this shortcut "dfind", since my servername starts with a D.

 

I first read about Everything on the top 10 tiny & awesome Windows utilities at Lifehacker.