Windows 8 keyboard shortcuts

I have been using Windows 8 a lot recently and one thing I have learned is that to get the most out of the operating system you really need to get comfortable using all of the keyboard shortcuts. Unlike the traditional desktop interface of the Windows 7 world, Windows 8 has both a desktop and an apps Start screen. This means that when apps get installed they usually appear on the Start screen. You launch apps from this screen and you use the desktop work area to manage your files and work with your programs.

After playing around with the system I have discovered 23 keyboard shortcuts to navigate the system. So allow me to share with you some of my favourites.

Note: The Windows key is normally located between the Ctrl and Alt keys on most keyboards.

KEYSTROKE ACTION
Windows logo key (Windows key) Toggle between desktop and Start screen
Windows logo key + start typing Search your PC
Windows logo key + C Open the Charms bar
Windows logo key + D Display the desktop
Windows logo key + E Open Windows Explorer
Windows logo key + F Open the Search charms to search files
Windows logo key + H Open the Share charm
Windows logo key + I Open the Settings charm
Windows logo key + J Switch between the Fill and Snapped apps
Windows logo key + K Open the Devices charm
Windows logo key + M Minimize everything displayed on the desktop
Windows logo key + Q Open the Search charms to search apps
Windows logo key + R Open the Run command
Windows logo key + U Open the Ease of Access Center
Windows logo key + W Open the Search charms to search settings
Windows logo key + X Open the Windows Tools Menu to see system functions like Task Manager, Command Prompt, Control Panel and many others
Windows logo key + Z Display the commands available for an app
Windows logo key + Print Screen Takes a screenshot and saves it to your Screenshots folder in the Pictures library
Windows logo key + Tab Cycle through your open apps
Alt + F4 Close a Windows 8 app
Alt + Tab Cycle through your open programs (including apps)
Ctrl + Mouse scroll wheel Activate semantic zoom on Start screen
Esc Close a charm

Determine what Windows operating system you are running

Here is an easy way to check what version of the Windows operating system you are running on your computer.

There are two ways to do this:

1. Open the Run window by going to Start > Run

Run Dialog

2. Open the Command Prompt (normally located under Start > All Programs > Accessories > Command Prompt).

Command Prompt

Type “winver” into either dialog and hit Enter.

You should then see an About Windows dialog box like this:

About Windows

The top line will give you the operating system name and version (Professional, Ultimate, etc.). You can also get information such as the Version number, Build number and which Service Pack has been installed. There is also licencing information relating to the operating system.

Export an ODBC Data Source from the registry

I recently found myself needing to do some Crystal Reports testing on a virtual machine. The tests were successful on my laptop but we use a  virtual machine running Windows Server 2008 R2 and IIS7 as a clean environment for testing. With these tests we were using both ODBC and SQL OLE DB connections to our database. The OLE DB connections were easy enough to replicate but we wanted to make sure our ODBC settings matched my laptop environment. To do this we used the Export feature in the system registry of my Windows 7 laptop.

Before I demonstrate this though I should explain what ODBC is. Open Database Connectivity (ODBC)  is a standard way for connecting to databases. ODBC and the associated driver can connect to a database regardless of the database manufacturer or the operating system on which it runs.

I will demonstrate the steps below on how to run the export.

1. First we need to see which ODBC connections we want to move. To view the existing ODBC connections we can open the ODBC Data Source Administrator. To do this click the Start button and type “ODBC” into “Search programs and files” on the Start Menu. Click “Data Sources (ODBC)” to run the program. It can also be launched from Administrative Tools | Data Sources (ODBC) if it is enabled on your machine. A tabbed dialog box will appear. Most of your ODBC connections should be housed under the User DSN tab.

2. To begin the export process we need to start the Registry Editor. To do this we can search “regedit” from the Start Menu and click Regedit.exe to begin. Another way is to launch the Run Command, enter “regedit” into the dialog and hit OK.

3. You  should now be within the Registry Editor. ODBC Data Sources are stored as keys within the Windows registry. Fortunately they are easy to retrieve. Your DSNs will be housed in two separate spots on Windows 7. (Other operating systems tend to place these in different files so you may need to hunt around.)

    User DSNs: Computer\HKEY_CURRENT_USER\Software\ODBC\ODBC.INI

System DSNs: Computer\HKEY_LOCAL_MACHINE\Software\ODBC\ODBC.INI

Registry Editor

4. Once you have found the correct folder you can now export the desired connection(s). Right click the ODBC.INI folder and select Export to copy every ODBC key in the folder. You can also choose a more granular level of exporting by selecting one DSN within the folder at a time. Unfortunately  the CTRL key cannot be used to select multiple files for one export.

Registry Export

A dialog window will appear. You can choose to export it in multiple file types (although .reg is the standard) and where to save the exported file. You can also select what you want included in the file through the Export Range. The option defaults to “Selected branch” which means you only get the DSN properties listed in the key. You can also select “All” and this will export every registry key in your system. A caveat though – when exporting using All within the Export Range it exported a file containing 3, 907, 557 rows of data. (I ran it twice to be sure this was correct). If you do not have many DSNs to move you might be better off to export each DSN individually.

Registry Export Dialog

Once the Export is saved to disk it will create a .reg file. This file can be opened and examined with a text editor like Notepad. Within the file you will see the various properties of a DSN like server and database names, as well as the selected database driver.

Exported Registry File

With the .reg file open you will now need to modify the file. As you have seen above when you export the ODBC Data Source you only get the DSN properties. However, when you insert this code into the registry on the target machine the DSN will be inserted into the registry but will unavailable elsewhere. To ensure you will have access to the DSN within your Crystal Report file, the ODBC Data Source Administrator and other places you are using ODBC Data Sources you will need to prepend the following code to the file:

[HKEY_CURRENT_USER\Software\ODBC\ODBC.INI\ODBC Data Sources]
"DSN name"="SQL Server"

Modify the “DSN name” to match the name of the ODBC Data Source folder you exported.

Modified Exported Registry File

5. You can now copy the .reg file to the destination computer for installation. Before you install though you might want to open the file and compare the DSN properties. It might be possible the target computer contains different settings than the export file. You can edit the .reg file to match before deploying the file.

6. To insert the values on the target computer open the ODBC Data Source Administrator and select File | Import… to browse to the file. Click Open to run the process. You can also simply double-click the .reg file and it will install the values into the correct locales.

Registry Import

7. The last step is to verify the install. Open the Registry Editor on the destination computer and navigate to the correct DSN folder path. Confirm that your ODBC Data Source is listed in the folder. Close the ODBC Data Source Administrator and re-open it to confirm they are accessible there as well. You can then tweak the DSN further by using the Configure button if need be.

ODBC Data Source Administrator

That is it in a nutshell. In this tutorial we have exported ODBC Data Source connections between two computers running different Microsoft operating systems. We saved ourselves time and headaches by ensuring our connections are identical between the two machines.

Toolbox searching in Visual Studio 2010

As I continue to use Visual Studio 2010 I still find innovative helpers that Microsoft has added along the way.

One of these is the search function within the toolbox. As VS2010 has more controls than ever it can be harder to find things. Just look at my toolbox which has some add-on controls installed as well as the defaults. I have many categories and each one has loads of controls. Finding the control I need used to mean rummaging through each category.

Toolbox

Microsoft has come up with a plan to fix this. They now allow for typeahead keyboard searching within the toolbox which is a definite time saver.

To do this yourself put the cursor focus in the toolbox. As you type your keystrokes get logged on the main status bar of Visual Studio. As the list gets narrowed down you might get multiple selections with the same values. If you do you can use the up and arrows OR the tab key to navigate between them. Once you have the desired control highlighted just hit the Enter key to add the control to your page. (Be sure to place your cursor in the desired location first!)

You can also cancel the search by hitting the Esc key or by moving out of the toolbox. You can also use the Backspace key to correct any typos. If there no controls matching your input then a message is displayed.

Typeahead

Two simple tricks to speed development

I just wanted to post two simple keyboard tricks to speed up development when you are using the Visual Studio 2010 IDE. Both have to do with getting the information you need quickly when developing within the Source page.

First, you can easily flip from the Source page to its Code Behind file by hitting F7. You can also see the Designer page by hitting Shift+F7.

Second, you can access the Properties window of any control by placing your cursor on the control and hitting the F4 key.

I will post more navigation tricks like this in the days to come.

Surround With in C#

As I mentioned in yesterday’s article entitled Inserting snippets in C# you can also insert snippets around existing code. To do this you need to use the Surround With option.

These snippets can be accessed on the design page (where you will receive snippets of HTML and ASP.NET code) or from the code behind page where you can get C# snippets.

You can access these snippets in several ways:

  • Highlight the text that you want the snippet to surround, right-click and select Surround With
  • Highlight the text that you want the snippet to surround and hit CTRL+K, CTRL+S, The same dialog box as above appears
  • Highlight the text that you want the snippet to surround and on the Menu Bar browse to Edit–>Intellisense–>Surround With

Inserting snippets in C#

In Visual Studio 2010 there are a lot of built-in snippets available to the developer. The IDE also allows you to create your own snippets but today I wanted to talk about accessing the built-in ones.

Microsoft provides you with snippets which are pre-written pieces of code that developers tend to use on a regular basis and when dropped in can save you time. Some are just placeholders that you have to modify (like the #region snippet) whereas others act as wrappers of code (like the try-catch block)

Snippets can be accessed on the design page (where you will receive snippets of HTML and ASP.NET code) or from the code behind page where you can get C# snippets along with snippets for developing tests and for working with Microsoft Office products.

You can access these snippets in several ways:

  • Set the cursor on the page where you want the snippet, right-click and select Insert Snippet
  • Set the cursor on the page where you want the snippet and hit CTRL+K, CTRL+X, The same dialog box as above appears.
  • Set the cursor on the page where you want the snippet and on the Menu Bar browse to Edit–>Intellisense–>Insert Snippet
  • Set the cursor on the page where you want the snippet and type the name of the snippet you want (eg #region) and hit the Tab key to get the snippet

 Microsoft also offers the Surround With option which I will explore in another post.