Home  ›  BLOG - Filter: Tools
Autohotkey key remapping
Samstag, 06. Februar 2010, Christoph Ertl

Keyboard layoutIn my last post I used SharpKeys to remap the keyboard layout because of my intensive use of home and end keys. Great deal. Works really fine.
But this solution has one major drawback. At the office I use an external keyboard. In this case  I have the inverse of the annoying keyboard layout.

Changing the keyboard mapping to the current situation with SharpKeys is not a solution as the steps would be

  1. Start SharpKeys
  2. Enter/Remove mapping 1
  3. Enter/Remove mapping 2
  4. Enter/Remove mapping 3
  5. Enter/Remove mapping 4
  6. Write to registry
  7. Logout
  8. Login

It’s takes time, is stupid work and is error prone.

So I started searching again and found the tool called AutoHotkey. This tool supports anything around keystrokes, running macros and many more. And it also provides key remapping. The first intention was to forget the solution with SharpKeys and use AutoHotkey instead. But it’s not that simple.

Pro SharpKeys:

  • The settings are written to the registry.
  • The application doesn’t have to run to get the mapping work.

Pro AutoHotkey:

  • Easy to change settings.

The double remapping solution

The solution that' fits best for me is as follows:

  • Using SharpKeys to remap the keyboard to work best with the keyboard of the notebook. Let’s call it “Device settings”.
    This is the default setting of my device and no application is running to get this mapping done.
  • Using AutoHotkey to remap to original keys when using an external keyboard. Let’s call it “External settings”.
    This mode needs an application to run. With external power supply and a very small footprint this is really no problem.

The Steps to switch to External settings or back to Device settings are:

  1. Start/Stop ExternalKeyboard.ahk

Great, I love it. A little tricky but works really great.

I was really surprised how easy the key remapping was done with an AutoHotkey script. It’s that simple:

Home::PgUp
End::PgDn
PgUp::Home
PgDn::End

Remapping keys of keyboard to refine keyboard layout
Sonntag, 31. Jänner 2010, Christoph Ertl

Keyboard layout

There are a lot of things to consider when coming to a decision about which notebook to buy. Among the obvious facts like cpu power, memory, ports etc. there’s another important fact to consider.
The keyboard layout !!

Some manufacturers are playing around with the layout that you even cannot find the key you are looking for when searching with your eyes. Hitting it while typing is impossible.

What are most misplaced keys?

  • enter key (too small)
  • right shift key (too small or at the wrong position)
  • home, end keys (access via Fn-Key)

Depending on your computer usage you will not even recognize this fact. But if you are typing a lot you will despair on it.
And if you are writing source code, which is a per line writing, you will miss the home and end keys a lot. I can’t live without them.

So when searching for my new daily companion I had a look at the keyboard layout especially the size and position of the shift key and the position of the enter key. I couldn’t find that much business notebooks having the home and end keys as separate keys. We are talking about 12” subnotebooks. So what.

I corrected the keyboard layout with software. In my case home is “under” page up and end “under” page down. I just swapped this keys. Great. I really like it.

image

To change keys you can use the tool SharpKeys which is simple and great.

screenshot sharpkeys

Google Wave - Die neue Kommunikation
Freitag, 25. September 2009, Christoph Ertl

Google Wave Email, Chatten und gemeinsames Arbeiten an Dokumenten sind ja heutzutage allgegenwärtig. Das Problem der vorhandenen Konzepte ist - vor allem bei Emails - dass es keinen Kommunikationsfaden gibt, dem man folgen kann. Man denke nur an eine Emailkonversation zweier Partner. Nachdem bereits einige Mails hin- und her- geschickt wurden, wird ein weiterer Partner involviert. Spätestens hier entsteht ein Durcheinander, weil alle Beteiligten auf unterschiedliche Versionen der Mails antworten. Das "Textchaos" ist vorprogrammiert.
Auf die Probleme basierend auf inkonsequente Nutzung von Emails möchte ich hier gar nicht eingehen.

Google hat sich dieses Problems angenommen und Google Wave entwickelt. Das Grundkonzept ist denkbar einfach und die Umsetzung sehr beeindruckend.

Anstatt einer Nachricht, auf die eine oder mehrere Antworten geschickt werden, steht hier das Unterhaltungsthema, die sogenannte Wave, im Vordergrund. Es wird zuerst ein "Behälter" für die Kommunikation über ein bestimmtes Thema erstellt. In diesen Behälter schreiben dann alle Beteiligten hinein - und das live. Videos, Screenshots und eine Beschreibung ist auf der Homepage von Google Wave zu finden.

Das Werkzeug wurde erstmals auf der Google IO vorgestellt und fand bereits beim anwesenden Publikum sehr großen Anklang.
Seitdem rollt die Welle immer mehr in die Öffentlichkeit. Dass hier nicht nur positive Stimmen zu hören sind, liegt in der Natur der Sache. Eines muss man auf jeden Fall festhalten. Es war an der Zeit für ein völlig neues, auf den Erfahrungen und Problemen der Vergangenheit basiertes, Konzept zu entwickeln. Und Google ist das meines Erachtens sehr gut gelungen.

Wie die Welle weiterrollt und sich entwickelt ist abzuwarten. Es besteht auf jeden Fall Hoffnung für eine einfachere und produktivere Kommunikation. Vor allem wenn weitere Hersteller auf diesen Zug aufspringen (Und das hoffentlich so, dass alle "Wave" Anbieter zusammenarbeiten).

In Zukunft werden sicherlich viele Menschen mit Google Wave schreiben. Mal sehen wie viele "Googleschreiber" es geben wird ;-)

Different behavior in Debug and Release version of a .NET application - How to find the bug
Samstag, 06. Dezember 2008, Christoph Ertl

binary conflict A few days ago I had a problem at a .NET 1.1 project where the release version of the application had a different behavior than the debug version. I felt like in the old days when developing with C++ and struggling through precompiler instructions.

The beginning

Tried to reproduce the bug with a Unit test which was not possible. Had a detailed look at the production data and refined the unit test. No success. At this point I had the suspicion that this could' be a debug vs. release problem. Tried the unit test in release mode and the test failed.

OK. There's a difference but how to find out where and what is the difference? And if found, why is there a difference?

Where's the difference?

Even with the information from the unit test it's not easy to find out why there is a difference. First of all we have to find the location of the difference. To find the location I used a profiler while running the unit test in debug and in release mode.

Then I compared the two call stacks and within seconds I got the method where the difference was located.

image 
callstack (orderd by execution time) as expected in the debug execution.

 

image
different callstack (ordered by execution time) in the release execution.

What's the difference?

Now we know the method were the difference is located. The next step is to compare the code of the release and debug assembly. This is best done using Redgate's .NET reflector.

Comparing the methods is an easy task with .NET Reflector. If your method is too large you can use an add-in which supports comparing two assemblies.

Why is there a difference?

While comparing the two version of the code you see in detail what's different. But why?

The difference can be caused by some reasons:

  1. Removed code in release assembly because of the Conditional attribute.
    Check the method which is missing in the callstack if it is marked with this attribute.
  2. The difference can also be caused by a compiler optimization like inlining etc. but this should not lead to a different behavior unless there is an
  3. Error in the compiler
    In this case you must try to change your code and see what's the result. A detailed inspection and understanding of the differences can help.

The found bug

For the sake of completeness the details about the bug I found. This bug only arises with the compiler shipped with Visual Studio .NET 2003. With Visual Studio .NET 2005/2008 there were no problems.

The code written in the editor:

private static void DoIt(bool flag) {
 
if(flag) {
   
using(MyDisposable d = DoItNormal()) {
   
}
 
}
 
else {
   
DoItDifferent();
 
}
}

The debug version inspected with .NET Reflector:

Debug assembly inspected

The release version inspected with .NET Reflector:

Release assembly inspected

Removing the empty using block and calling Dispose() explicitly solves the problem.

References