Wish: AutoComplete add-in for Word that suggests words from current document

June 20, 2007 by splintor

UltraEdit has a nice feature in which when you press Ctrl-Space, an auto-complete list is opened, suggesting you to complete the word you just started to type. The nice thing is that its suggestions come not only from the list of keywords of the edited file’s language, but also from the actual words in the file (actually, the words above you current location).

This is great as you often use the same words several times in a file, and it can be handy for your editing tool to use that and suggest options from your current work, which probably knows the words in the domain more then any general keywords dictionary file.

I really wish someone would have written an add-in to Microsoft Word that does it. I might get to it some time when I have time (as if… ha).

Javascript: Function.prototype.toString returns an optimized version of the function

June 17, 2007 by splintor

I was working an a user script for Gmail (I’ll link to it when it’s done), and could not understand what some code didn’t run on a specific page.

One of my tricks of seeing a Javascript function body when the function is dynamically added is to call the function toString() (e.g. in Firebug console). Regretfully, Firebug doesn’t tab-complete functions’ methods, so I have to manually type “toString()”.

However, in the code I wrote, I accidentally wrote something like:


var count = getCount();
if(count == 0)
    count == 1;

Note the bug in the last line, where the comparison operator (==) is used instead of the assignment operator (=). Surely, my mistake. However, when I look at the text that was returned from the call to Function.prototype.toString() for that function, I saw it is:


var count = getCount();
if (count == 0) {
} 

So the Javascript engine noticed that nothing really useful is going on in the body of that if, and simply removed it, and that is reflected in what Function.prototype.toString returns. I didn’t knew that.

PS

Naturally tools like JSLint warn about this problem:

Expected an assignment or function call and instead saw an expression.

count == 1;

But this is a minor user script, and I never considered passing such scripts through JSLint. I might consider starting doing it for my scripts…

A solution to quickly moving mail items from Outlook inbox

June 12, 2007 by splintor

My usual way of handling e-mails is reading them in the inbox which collects both work-related e-mails from the Exchange server and private e-mails from my Gmail inbox using SMTP and POP3., and then dragging them to the the appropriate folder in one of the PST I have.

I know that since I index my mails and it is lightning fast to find any e-mail filing each e-mail in a specific related folder is less important, but kind of used to it, and I still find it useful to be able to go to a folder and see all the mails that I decided that belong to that folder, and not all the files that match some search. This has prove itself useful mainly in customer related data, where searching the customer name would have bring way too many mails, but looking at the customer folder quickly revealed the old case I was looking for. By the way, these is one of the reason I prefer Outlook to Gmail. Outlook can easily help me categorize my mails in hundreds of hierarchical folders, where Gmail provides a flat list of labels, which might not be useful for more than a few dozens.

My problem was that whenever I wanted to move a mail to a folder, I would have to find the folder in the folders tree, in order to drag the mail into it. This might be annoying for commonly used  folders like the folder that keeps mails from CodeProject (I’m subscribed to it although I rarely develop in Microsoft technologies. I enjoy skimming through it looking at what’s new in that area. Occasionally I even find an interesting article).

When a mail is opened in Outlook editor, which has the new ribbon, the ribbon has a clever Move to Folder item which opens a list of recently used folders. However, if I don’t want to open the mail, and only want to move it to a folder from the index, I have to find the folder in the tree and drag it to it.

One solution is to use the Favorite Folders to put shortcut to commonly used folders in a fixed place, and then drag mails to that folder shortcut, and not to its location in the tree. This has two drawbacks:

  1. The list tends to grow all the time, and I end up with a big list of “Favorite Folders” which I rarely ever navigate to - I only use them as drag targets.
  2. Sometimes Outlook crashes and the list of Favorites folder is reset, and I have to start building it from scratch.

Today I came up with a new solution - use macros.

I wrote the following VBA procedure:

Private Sub MoveItemsToFolder(folderID As String)
    Dim item As MailItem
    Dim targetFolder As Folder
    ' Folder ID can be obtained by selecting the folder
    ' in Outlook and then typing in the immediate window:
    '   ?ActiveExplorer.CurrentFolder.EntryID
    Set targetFolder = GetNamespace("MAPI").GetFolderFromID(folderID)
    If ActiveExplorer.CurrentFolder = targetFolder Then
        MsgBox "You are already in '" & targetFolder.Name & "'.", vbCritical
        Exit Sub
    End If

    For Each item In ActiveExplorer.Selection
        item.Move targetFolder
    Next item
End Sub

and then I wrote small procedures like the following:

Sub MoveToPrivate()
    MoveItemsToFolder "0000000045DC3C0FFF1EA54CBAD9147BB26AF269A2800000"
End Sub

Sub MoveToCodeProject()
    MoveItemsToFolder "00000000A7E4D138E838B7489BA3F839949B055122860000"
End Sub

Then I created a new menu in Outlook toolbar, and added these procedures as items to this toolbar menu. So now, when I want to move a mail to a folder, I simply select it and click the appropriate button.

As the comment says, if a new folder is needed, I select it and open the VBA editor, and type

ActiveExplorer.CurrentFolder.EntryID

in the immediate window. I didn’t have an Outlook crash yet, so I don’t yet know if crashes that reset the favorite folders also reset toolbar customization, but at least the first problem is solved - my favorite folders only contains folder I navigate to regularly, and not all the folder I periodically get mails that should be filed under them.

Macro keyboard shortcuts in Excel 2007

June 10, 2007 by splintor

I’ve just written a new macro in Excel, and wanted to assign Ctrl-Shift-F to it, as it does some advanced finding. However, the Shortcut key field that appears in the Record Macro dialog and also in the Options… dialog opened from the Macros dialog, it seems to only be possible to assign Ctrl-<something> to a macro, and not Ctrl-Shift-<something>.

Disappointed, I choose Ctrl-E instead. Cursing Microsoft again for not putting a decent keyboard customization feature in Excel 2007 (and also in Outlook Editor), like they did in Word 2007.

But then I recalled that I already had a macro that copied the content of the selected cell, and I’m used to activate it using Ctrl-Shift-C. I want back to the Options… dialog and found out that although it says Ctrl+<something>, if you type Shift-<something> in that field, the Ctrl label changes to Ctrl+Shift.

I’d say that’s not the most discoverable feature I’ve seen…

PS

The Macro I use for copying a cell (or cells) content is as follows:


Sub CopyCellContent()
    Dim MyData As DataObject
    Dim s As String
    Dim i As Long
    Set MyData = New DataObject
    If IsArray(Selection.Value) Then
        s = Selection.Cells(1).Value
        For i = 2 To Selection.Cells.Count
            s = s & ", " & Selection.Cells(i).Value
        Next i
        MyData.SetText s
    Else
        MyData.SetText Selection.Value
    End If
    MyData.PutInClipboard
End Sub

Flix.co.il on Firefox

June 6, 2007 by splintor

Flix.co.il is a an Israeli video sharing site, and recently I noticed that when someone links to a movie over there, my Firefox fails to display it, and I have to revert to IE to display. That doesn’t happen that much for me to install the IETab extension. but today, I decided to check what’s going on, and see if a user script can be written to overcome it.

One of the strangest things was that I saw no complaint about it in the Israeli Blogosphere, and I thought that if there was a problem with Firefox support on that site, bloggers would have rant about it, and someone would even write a user script to solve it.

However, when I checked it I found out that the site uses Javascript libraries from plaxo.com when the “send movie to a friend” feature is used, in order to import their address book. Normally, this should not be a problem, but SmartFilter defines Plaxo.com as “Social Networking” and such sites are blocked by our IT people as non-job related site, so when the browser requests it, it gets an error HTML, and if it tries to treat the returned page as JavaScript code, errors occurs. For some reason I didn’t quite understand, IE can cope with that JavaScript error, but Firefox stop execution the code in the page, so the movie Flash <object> and <embed> tags are not created, and the movie is not displayed.

After that was found, it was easy to write a user script that creates that movie Flash <embed> tag if the page failed to do it.

Checking it some more, I saw that if you refresh the page several times the movie start playing. This might be related to the fact that the plaxo.com libraries are loaded in an <iframe>, and the load order might change.

June 4, 2007 by splintor

After I read some more people saying how Launchy is really good, I thought I’d give it a try, although I said I’m not the kind of guy who uses it.

In fact I found it useful for some types of task. I really enjoyed finding out that it is learning, so if you once type one or two letters and select an app from the list and not take Launchy suggestion, Launchy will remember your selection, and the next time you type these letter(s), you will get your last selection as the first suggestion. This made me teach Launchy to start some applications using their first letter such as O for Outlook and F for firefox. This is mainly useful in my laptop startup process at home, where I start Firefox and Outlook after connecting to VPN. I know I could have written a script to do it, but Launchy makes it very easy to do it without writing that script.

Another usage I found useful is to mute or "unmute" the speaker. Before Launchy, if I didn’t know if the speakers were off or not, and I wanted to turn them on or off, I had to click the speaker icon in the system tray, wait two seconds for the volume slider to appear, and then set the Mute checkbox to what I want. After I started using Launchy, I downloaded mute.exe from here, and then created two shortcuts - mute.lnk and unmute.lnk, and then I "taught" Launchy to use "M" and "U" to run them.

I did find some problems with it:

  • It doesn’t support Hebrew. I tried running a Firefox favorite with a Hebrew name, and it just didn’t find it. Maybe it’s just the Foxy plugin that sucks, since it does find Hebrew strings in the Start menu.
  • Trying to teach him to run a Firefox favorite with just one letter behave strangely. It keeps showing the favorite page title, instead of the name of the favorite.
  • It would be nice if whenever it saw the beginning of a file path (like "C:’" or "’’host’") it would auto-complete it, but do it properly, like Total Commander 7 does it.

Don’t forget to go over those TODO before releasing…

May 28, 2007 by splintor

I’m looking for an online backup solution for my (and my wife’s) documents. At first I thought Gspace will do the trick, but it only runs as part of Firefox and doesn’t know how to do background backups, so I’ll probably go with Mozy, which looks promising. Of course, my main concern in picking a backup provider, apart from price, is its reliability, so it won’t just disappear one day, and this make Gmail a major candidate, but I guess Mozy is also safe, as I hear a lot of people recommending it.

However, during the test, I inspected Xdrive, which looked nice, but it appears it doesn’t really support Hebrew filenames very well, which is quite crucial, so this one is no longer an option. However, due to my laziness, I haven’t uninstalled it yet.

Today I saw the Xdrive icon is in my system tray, and wanted to stop it. Since it didn’t have menu item or a command to stop it, I went to Process Explorer. I saw that it had two process related to it: XdriveService.exe and XdriveTray.exe. Then I noticed the process description and company name of XdriveTray.exe - TODO: <File description> and TODO: <Company name>. Oops. I guess the developers forgot to change that in the resource file created by their IDE…

KatMouse enables mouse wheel for VB6 and Remedy

May 7, 2007 by splintor

Via LiefHacker, I just found KatMouse.

The main goal of this small utility is to enable scrolling with the mouse wheel in windows that don’t have the keyboard focus.

But I mainly find it useful to use the mouse wheel in applications that don’t handle mouse wheel event. Up until now, I found two such applications that I use - Visual Basic 6, in which I still fill at home for some quick tasks like testing our COM class library, and Remedy User which we recently switched to for customer support and bug tracking.

KatMouse simply sends the correct message to those application and makes the mouse wheel works for them. I did find some problems with it - it disabled the mouse wheel in Excel 2007 worksheets and in Word 2007 Document Map sidebar. Fortunately, KatMouse provides an ultra-easy way to configure it to ignore specific window classes, using a Spy++ like windows finder, so the problem was quickly and easily solved.

The only problem that still remains is that my Dell D620 mouse-pad doesn’t have a mouse wheel… :(

Update: There is one problem I found with KatMouse which I couldn’t resolve. In Excel 2007, when you do data filtering, and click the arrow at one of the title cells, you get a complex menu with some options like sort and advanced filtering, and also a list of all values in the column so you can select from it. This list doesn’t handle mouse wheel events. It didn’t bother me until now - like any window with no wheel support, I’d try using the mouse wheel, and when it didn’t work, I would scroll with the scrollbar. However, when KatMouse is active, using the mouse wheel causes the special filter menu to disappear. The problem is I can’t find out how to tell KatMouse not to handle mouse wheel events for this menu, as it disappears on every mouse click or key down, so I can’t get its window class. Not such a big nuisance, but nevertheless…

Update 2: One additional place I found KatMouse useful is with DiskFrontier which does not support mouse wheel which tends to be really annoying. A quick class customization in KatMouse solved the old problem.

Second rename command in Total Commander

May 7, 2007 by splintor

I use Total Commander to manage my files. I find it invaluable. Today, I accidentally discovered a great feature it has which I was not aware of.

One of the nuisances of renaming a file is to remember to keep the extension, since when I enter the “inplace rename” mode, the entire filename can be edited, including the extension.

I just noticed that when I repeat the command that starts the “inplace rename” mode, only the filename without the extension is selected, which makes it very handy to rename the file while keeping the extension.

From my tests, this only works if you use the keyboard shortcut to start the “inplace rename” mode. By default it is Shift-F6. In my configuration, F2 also does the same thing, to be compatible with Windows Explorer. However, other methods to enter the “inplace rename” mode, such as clicking the report name twice or using File menu -> Basic File Handling -> Rename (Inline) doesn’t have this effect.

Searching some more, I noticed this is explicitly mentioned in the online help, in the “F6: Rename / Move” topic. It also mention another nice feature:

When renaming a ZIP file to an EXE file, Total Commander will ask if you want to create a self extracting ZIP archive. If you choose ‘yes’, the EXE file will be converted.

Joost invitations

May 2, 2007 by splintor

Kim has sent me an invitation to Joost. I’m still looking for some thing I want to see there, but meanwhile, I noticed I can send invitations, so if you want some, leave your e-mail in the comments.