Setting list item gaps in Microsoft OneNote (AutoHotKey script)

Although I like Microsoft OneNote and use it continuously, it does have a few failings. One of these is the inability to set the default styles and layout for text.

In particular, when you create a new paragraph or list entry in OneNote, the default – non-changeable – setting is to have no white space between the paragraphs.

This is very poor design and makes more than a small amount of text quite unreadable. I’ve raised this with Microsoft but who knows if or when it might be sorted.

In the mean time, I need a far quicker way of changing this. Currently, I’ve had to:

  1. Select the container with the text I want to format
  2. Use the menu to show the List Task Pane ([alt]o/L)
  3. Mouse click on the text box to change (you cannot tab into it)
  4. Change the 0.00 pt default to something like the 6.00 pt that I prefer
  5. Close the List Task Pane

Not nice!

Having determined that there is nothing clever that can be done in OneNote, I decided that the old standy “AutoHotKey” would be useful. So I’ve created a script for AutoHotKey that will change the inter-list gap for the currently selected container.

; [win]-z Set OneNote list to 6pt separation
#z::
; We need a partial title match but we will also reset to previous setting
oldTitleMatchMode := A_TitleMatchMode
SetTitleMatchMode, 2

debug            := 1                                                           ; Set to 1 to output debug messages, or 0
winTitlePart := " - Microsoft Office OneNote"   ; Partial title of ON windows
winText          := "List"                                                      ; Text to identify List Task Pane - Visible Window Text: MsoDockRight, Task Pane, List
listDefault      := "0.00 pt"                                           ; The default setting for list separation between items
listNew          := "6.00 pt"                                           ; My desired spacing between list items

; Only do something if ON is the active window
IfWinActive, %winTitlePart%
{
        ; We need the List Task Pane to be visible
        IfWinNotExist, %winTitlePart%, %winText%
        {
                ;IfEqual, debug, 1, MsgBox List not active
                ; Send chars to activate menu, can't use WinMenuSelectItem with Office apps
                ;   SendPlay is used to prevent the Windows key locking the PC (Win+L)
                SendPlay, !oL
        }
        ; List Task Pane should now be visible, save the existing setting
        ControlGetText, Var1 , RichEdit20W2, %winTitlePart%, %winText%
        ; If the current setting is the default setting then make the change
        if Var1 = %listDefault%
        {
                ; Focus on the input box & set the text
                ControlFocus, RichEdit20W2, %winTitlePart%, %winText%
                ControlSetText, RichEdit20W2, %listNew%, %winTitlePart%, %winText%
                ; This is optional to check if we were successful
                ControlGetText, Var2 , RichEdit20W2, %winTitlePart%, %winText%
                if ErrorLevel   ; i.e. it's not blank or zero then error
                        MsgBox, %Var1% - %Var2% - Problem - %ErrorLevel%.
                else
                        IfEqual, debug, 1, MsgBox, OK - %Var1% - %Var2%.
        }
        ; Close the List Task Pane (actually it closes the Task Pane, period, sorry)
        SendPlay, ^{F1}
}
else    ; ON not active so do nothing
        IfEqual, debug, 1, MsgBox, OneNote not active

SetTitleMatchMode, %oldTitleMatchMode%
return

OK, so it’s a bit rough-and-ready but it does save a whole lot of time. I’ve got this in my default AHK script so it is loaded whenever I log in and is activated with [win]z.


Technorati : , , , , , ,
Diigo Tag Search : , , , , , ,

Quick test of new comments system (using DISQUS)

Just testing a new commenting system – Disqus.

Looks like it works OK so I’ll keep it online for now. Currently, you no longer need to be logged in (previously you needed to present either a Blogger, Google or OpenID credential to comment because of spam) since Disqus is supposed to handle this better. However, if the spam starts to reappear, I’ll have to restrict it again.

For blog authors, check out Psolonoid as well. It provides an easy and controlable way of creating links (like trackbacks) between blog entries.

Changing system environment variables from the Windows command line

There are several ways to change global or user environment variables manually in Windows. Most are well known so I wont repeat them here (e.g. in Vista or Windows 7, Control Panel/User Accounts, Change my environment variables).

However, sometimes you want to do this from a command (aka script or batch) file. This is not as straightforwards as it might seem. That’s because if you simply set the variable – e.g. set FRED=JimBob – it is only set while you are in that command file. Once the script has finished, the variable will no longer be set.

There are a number of examples of setting system or user environment variables available if you do a Google search but most of them are incomplete – they do not immediately make the new value available to all applications (and particularly to new command shells).

To make sure that the new value is available system-wide, you have to tell Windows to refresh the environment variable list and the easiest way to ensure this happens is to change the variable from a Windows Scripting Host (WSH) script.

Here is an example script to do this. Save this file as something like set-env.vbs somewhere convenient.

'Set/Change/Delete An Environment Variable
'  In this simple script, we mainly assume that the variable space is USER.
'  The variable is not only changed for the calling script, it also forces a system-wide
'    refresh of the lists so the created/updated/deleted variable is immediately available
'    to all applications.
'
'Syntax:
'  With 3 arguments
'    Creates or changes the named variable in the in the given environment variable list
'    set-env.vbs <variable type> <variable name> <assigned value>
'
'  With 2 arguments - Assumes the variable type is USER
'    Creates or changes the named variable in the current USER's environment variable list
'    set-env.vbs <variable name> <assigned value>
'
'  With 1 argument - Assumes the variable type is USER
'    Deletes the named variable from the current USER's environment variable list
'    set-env.vbs <variable name>
'
'  With no arguments
'    No action taken
'
'Where:
'  <variable type> is one of
'    "System" (HKLM),
'    "User"   (HKCU),
'    "Volatile" or "Process"
'
'Author:
'  Julian Knight, http://www.knightnet.org.uk/contact.htm
'
'License:
'  Permission is given to reuse this code in any way desired
'  No support is given or implied for this code
'

Set WSHShell = WScript.CreateObject("WScript.Shell")

' Get arguments
Set oArgs=WScript.arguments

WScript.Echo
Select Case oArgs.Count
        case 3
                ' If we have 3 arguments, assume <type> <name> <value> and create/change
                WSHShell.Environment(oArgs.item(0)).item(oArgs.item(1)) = oArgs.item(2)
                WScript.Echo "Created or Changed Environment Variable: " & oArgs.item(0) & ", " & oArgs.item(1) & ", " & oArgs.item(2)
        case 2
                ' If we have 2 arguments, assume <name> <value> and create/change in USER space
                WSHShell.Environment("USER").item(oArgs.item(0)) = oArgs.item(1)
                WScript.echo "Created or Changed Environment Variable: USER, " & oArgs.item(0) & ", " & oArgs.item(1)
        case 1
                ' If we have 1 arg, assume <name> and delete in USER space
                WSHShell.Environment("USER").Remove(oArgs.item(0))
                WScript.echo "Deleted Environment Variable: USER, " & oArgs.item(0)
        case Else
                ' Otherwise do nothing
                WScript.echo "No action"
End select
WScript.Echo

Note that in Vista or above, you will need to run the command file with elevated privileges for this to work. The normal command prompt gets this automatically but if you want to run the file from Windows Explorer, you will need to create a shortcut and change the settings.

You can now use this in your batch command scripts, for example:

@echo.
@REM change http_proxy variable for current user (forces change & refreshes system so new setting is immediately available to everything)
@cscript.exe //nologo C:\set-env.vbs http_proxy http://localhost:3128
@echo.

@choice /T 5 /D y /N /M "Switch complete, now using local proxy"
@echo.


Technorati : , , , ,

Diigo Tag Search : , , , ,

Windows 7 (Build 7000) still my main desktop OS

A quick update on Windows 7. I’m still using the version from MSDN, Build 7000.

Unfortunately, it will not let me report bugs for some reason, the “Send Feedback” link always fails to authenticate my Windows Live login. However, I do have a few issues and a few likes.

Issues with Windows 7

Possibly Windows 7 Beta Issues

  • Power options only shows 2 out of 3 std options
  • Creating new folder in all users (in explorer), creates new folder but doesn’t allow rename (says folder already in use) yet allows delete
  • Screen resolution seems to randomly reset to something lower (NVIDIA WDM driver). Often can’t be put back to native resolution again without either a reboot or lots of tries and messing. Often happens after UAC prompts, sleep and logon screensaver, also sometimes when plugging in an external monitor. Trying to reset often causes Windows to go to a LOWER resolution that it started with (1024×768 which seems to be some kind of default)
  • Some folders that are accessible from Windows Explorer main interface give “Access Denied” when accessed from file open/save dialogues
  • Windows update failed from behind ISA proxy when using a proxy.pac file even though IE was working OK
  • Send Feedback failed from behind ISA proxy (even though IE works OK) – both on proxy.pac and direct proxy setting – gives invalid username/password. Actually, this always fails no matter what, it is not just a proxy issue as far as I can tell
  • Windows Mobile 6.1 device not recognised (HTC Touch HD) (Workaround: Install Windows Mobile Centre for Vista)
  • Shift-Delete on a picked file does not always delete file (shift-RMB/Delete does)
  • Windows Explorer does not always refresh correctly (e.g. Duplicate file & group entry [grouped by date], files not removed after delete), clears after F5/Refresh. Sometimes the refresh is very slow (2-3 seconds)
  • Wmic command line tool does not work correctly. The examples in Technet do not work if you want to specify an output template. The templates are not in %systemroot%\system32\wbem (note that the example given in Technet incorrect has a leading \) as expected by wmic, instead they are in a sub-folder, .\en-US and wmic cannot find them. You cannot put in a path either it seems. Copying the template to the parent folder does work. Interestingly, the “files” in the sub-folder are actually linked to sub-folders of %systemroot%\winsxs. Reported via technet.

Fundamental Windows issues still around in Windows 7

  • Can’t temporarily or quickly show hidden files and folders (for admin) – have to use the sledge-hammer approach of changing the Explorer settings which means drilling down several menus (NB: There is a script someone has written to toggle this setting)
  • When files/folders in use, Windows still doesn’t say who or what is using them! (e.g. USB)
  • Non-resizable dialog boxes (e.g. Power options/Advanced Settings, Driver Installation, …) – Even IE8 suffers from this (e.g. Customize Toolbar)


    This really is unacceptable in the 21st century!
  • Disk Management still does not allow a partition (at least the boot one) to be moved. It can be shrunk and can expand if there is space AFTER it but not if the space is BEFORE it
  • Add/Remove programmes – this is an area that Linux has really triumphed over Windows. Windows still has no standard way of keeping applications up-to-date. Also ARP still doesn’t enforce proper clean-up of data (especially the registry). At least this process is vastly quicker than previously
  • Mouse wheel scroll actions are still inconsistent (though better than previously). Some apps, you have to click in a list before the wheel will scroll (e.g. Most native Windows dialogs – add/remove programmes, Explorer) & still scroll even when the mouse is not over the list, others (e.g. Office) need only have the parent window active and don’t scroll when the mouse is not over the list
  • Still cannot easily manage NTFS links (hard/soft/parse points) even though they have been natively supported since Windows/NT! Hint: Use Link Shell Extension (though see MKLINK command line tool as well)
  • Still cannot natively mount an ISO image file (even though VHD files are now supported). Still cannot create an image natively. At least you can burn an image to CD/DVD natively now.
  • It’s inconceivable that, in this day of multiple monitors, Windows still can’t have different backgrounds on different monitors. At least there are some handy Windows shortcuts now to move windows between monitors

So, if those are the issues, what about the likes?

What I like about Windows 7

  • It is fast! Certainly a lot faster than Vista (not hard). It’s quick to start up and shut down as well
  • Left hand pane of Windows Explorer is now much better organised
  • UAC not quite as intrusive (though see issues)
  • Task bar – wasn’t sure I would like this but it does work well
  • Explorer Libraries – Nice little tweak to Windows Explorer, adds the ability to add many folders to a virtual folder and set one of them as the default write location

Hmm, that seems as though I dislike Windows 7? Well actually that impression is wrong. Windows 7 really is what Vista should have been. Lets forget Vista shall we, it was a mistake rather like Windows ME.

I’m still using Windows 7 even though I do get some problems so that should say something. If Microsoft and other key partners – hello NVIDIA! – can get the final issues sorted out, this is going to be a crackingly good operating system for any PC built in the last five to ten years.


Technorati : ,

Diigo Tag Search : ,

How to get and use your local IP address in a Windows 7 (and Vista) batch command file

If, like me, you spend a lot of time on a variety of customer sites, you will probably be familiar with the issues around swapping networks.

I’ve already blogged about the problems with Windows 7, Vista and Firefox proxy settings and I will do some more articles on getting on with problematic proxies later. However, I wanted to let people know how to get hold of your IP address from within a batch (command) file.

@REM ipconfig | find "IPv4 Address"
@REM Find the IPv4 address from ipconfig (13th var if string is split by both @REM and space)
@for /f "usebackq tokens=13 delims=: " %%i in (`ipconfig ^| find "IPv4 Address" `) do @(
   @set MyIP=%%i
   @REM Split addr into components so networks can easily be checked
   @for /f "usebackq tokens=1-4 delims=." %%a in ('%%i') do @(
      @REM @echo %%a,%%b,%%c,%%d
      @set MyIP1=%%a
      @set MyIP2=%%b
      @set MyIP3=%%c
      @set MyIP4=%%d
   )
)

Note the space after the : on line 3. The FOR command used twice here splits the text output from what is in the () after the “in” using the defined delimiters (“:” and space in the 1st case, “.” in the 2nd). In the first FOR statement, we take element number 13 only, it ends up in variable %%i. In the second case, we take elements number 1 to 4, they go into variables %%a, %%b, %%c, %%d.

Now you have not only the full address but also the componants so if you wanted to check whether you were in a particular class C network, you could do something like:

@set corp_addr_ip4=10.97.100.0

@REM == ADD NEW ADDRESS CHECKS HERE ==
@if "%MyIP1%.%MyIP2%.%MyIP3%.0"=="%corp_addr_ip4%" @goto DOSOMETHING

That would check if your local IP address is between 10.97.100.1 and 10.97.199.254

Note that I’ve used the enhanced FOR statement – the “usebakq” makes the FOR statement more like a UNIX type one where commands are enclosed in back-quotes (`). This certainly works for Windows 7 and should, I think, work for Vista. Prior to Vista, you would need to do things differently anyway. At the very least you would have to search for “IP Address” in the FIND statement as IPCONFIG didn’t include IPv6 information.

Now that you have everything in place, you can control the proxy settings for each application that needs access out of the local network. I’ll blog about that another time.


Technorati : , , ,

Diigo Tag Search : , , ,

Critical Bug in Outlook 2007

I’ve recently stumbled on a bug in Outlook 2007. Apparently it is quite well known and the only reason that I hadn’t found it was that I don’t use Outlook as my main email client. In fact I only use email on it to handle meeting requests.

The bug is that Outlook 2007 ignores the setting regarding sending reply requests for IMAP accounts.

If this seems rather irrellivant to you, you might want to think again.

If you have an email account that receives SPAM and you access it via IMAP, Outlook 2007 will ignore your setting for reply requests (the setting is defaulted to prompt). Since many SPAM emails have reply requested turned on, you will suddenly find that Outlook is trying to send a whole load of email messages that do not appear in any folder! You haven’t been asked, it is just doing it.

This is bad enough as you are now leaking information about your account out onto the Internet – but it gets worse!

Outlook does not send the replies out using the account that recieved the SPAM, it sends them out from the DEFAULT account.

So if you have, lets say for example, a work account that doesn’t recieve significant SPAM and is your default account in Outlook. Then you have a second, personal account perhaps, that does recieve significant SPAM. You will suddenly find that Outlook is sending hidden emails from your work account – these are the reply responses from your personal account. Now you are leaking information about your work account.

Now, there is a new, big update to Outlook 2007 that has just been released. It is not yet on Windows Update but Microsoft are touting it as the biggest and best set of updates for Outlook ever – see Jimmy May’s blog post for more information. Sadly though, despite the hype, the new update does not fix this critical bug.

The update – which will be part of the Service Pack 2 (SP2) for Office 2007 – certainly does vastly speed up the operation of Outlook 2007 so there is some good news.


Technorati : , , , , ,

Diigo Tag Search : , , , , ,

Sun’s VirtualBox gets on with it!

Yep, I keep being amazed by the quality of VirtualBox which is now owned by Sun.

I need to set up a virtual machine to test and demo Sun’s Identity Management (IdM) suite and it needs to be usable with VMware too. So I headed over to the VMware Appliances web site and downloaded a pre-canned Debian 5 server.

This is recognised fine by VirtualBox! I gave the VM a Host Networked connection to the network and with no further configuration, fired up the VM. First thing was to install some additional components so I used the Debian package manager (aptitude) from the command line (no windowing GUI here!) to install the file and database and web server virtual packages. It just worked, no networking problems at all and being a Host network, it is on my local LAN as well as the Internet with no problems.

It’s nice when things “just work”. That’s how it should be!

Of course, it probably wouldn’t have been quite so simple if I wanted a desktop as well. But there are also a number of pre-canned VirtualBox VM’s for downloading.

VirtualBoxImages and HelpDeskLive.


Technorati : , , ,
Diigo Tag Search : , , ,