Click here to Skip to main content
11,928,352 members (54,557 online)
Click here to Skip to main content
Add your own
alternative version


26 bookmarked

Store and Organize your Shortcuts for Easy Launching of Files and Applications

, 5 Jan 2009 CPOL
Rate this:
Please Sign up or sign in to vote.
Store and organize your shortcuts for easy launching of files and applications


The tool can be used as a short cut for launching applications using mouse.
There aren't many technical things to tell in this article. Most of the things are available on the Internet and I searched and used them. I will give the links in this article.

The techniques used are:

  1. Mouse hook
  2. How to get icons from EXE


Thanks to Stephen Toub for the useful article on how to hook the mouse in C#.

How to Use

  • After starting the application, the application will run in the background. To view the tool:

    1. Use the mouse wheel click.
    2. Or Double click in the tray icon. (useful for mouse with no wheel)
    3. Or Right click on the tray icon, then select "Show" from the menu.


  • 4x4 matrix buttons will appear on the screen. Now set each button for launching the new application. To do that:

    1. Right click on the tray icon to view the menu.
    2. On the menu, select "Setting". The below dialog will open:


    3. The Rows and Cols will change the number of button to display.
    4. Click on each button to give the application path and arguments if any.
    5. Check the startup checkbox if you want to run the application during startup.
    6. There are 3 pages and each page contains 36 buttons. Each button can be configured as a shortcut for an application or can be set as blank.
  • After the matrix of buttons is visible, clicking anywhere on the screen will hide it. Middle click will also hide the matrix of buttons.

    • By rotating the mouse wheel, we can move to next page of buttons.
    • Right click on the buttons will also move to next page. (This is done for mouse with no wheel)
    • Click on the button to launch each application.

Using the Code

Mouse Hook

Please follow the above article for the mouse hook process.

The main window has two delegates that will be called by the mouse hook methods.
One for show and hide the window. ShowHide(int x, int y) will show or hide the window in mouse middle click.

The second one is for scrolling the window. ScrollIcon() will increase the page number of the window.

private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
    if (nCode >= 0 &&
         MouseMessages.WM_LBUTTONUP == (MouseMessages)wParam)
         //Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));
         //Console.WriteLine( + ", " +;
    else if (nCode >= 0 &&
         MouseMessages.WM_MBUTTONDOWN == (MouseMessages)wParam)
	Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));
         return (IntPtr)(-1);
    else if (nCode >= 0 &&
         MouseMessages.WM_MOUSEWHEEL == (MouseMessages)wParam)
         if (scrolIcon() == true)
             return (IntPtr)(-1);
    return CallNextHookEx(_hookID, nCode, wParam, lParam);

Transparent Window

The second part to consider in the tool is a transparent window containing a matrix of buttons.To make a transparent window in WPF is very simple. Below is the XAML code. Make AllowsTransparency = true and Background='Transparent".

<Window x:Class="ZWheel.Window1"
    Title="Window1" Height="180" Width="180"  WindowStyle="None" 
    Background="Transparent" Visibility="Hidden" 
	Icon="/ZWheel;component/ZWheel.ico" Topmost="False" ShowInTaskbar="False">

Get Icons from Filename

The following code is used to get the icons from the file name:

public extern static int ExtractIconEx(string libName, int iconIndex,
IntPtr[] largeIcon, IntPtr[] smallIcon, int nIcons);

public static Icon GetIconFromPath(string filePath)
    int numIcons = 10;//if you want 10 icons for example

    IntPtr[] largeIcon = new IntPtr[numIcons];
    IntPtr[] smallIcon = new IntPtr[numIcons];

    //retrieve icon from array
    Icon smallIco = null;

        if (Directory.Exists(filePath) == true)
             ExtractIconEx("shell32.dll", 0, largeIcon, smallIcon, numIcons);
             smallIco = System.Drawing.Icon.FromHandle(smallIcon[4]);
             ExtractIconEx(filePath, 0, largeIcon, smallIcon, numIcons);
             smallIco = System.Drawing.Icon.FromHandle(smallIcon[0]);
    catch (Exception)
    { }

    return (smallIco);

Put the Icon in the Button

To put the icon on the button, declare each button with an image as below. Get the System.Drawing.icon for the file using the above code. Create a bitmap from the icon and assign the image.Source property as shown in the code below:

<Button Name="P1_Btn00" Grid.Column="0" Grid.Row="0" Click="Btn_Click">
       <Image Name="IC_Btn00" Stretch="None"  />
btnIcon = GetIcon.GetIconFromPath(btnInfo.Path);

Bitmap bmp = btnIcon.ToBitmap();
MemoryStream strm = new MemoryStream();
bmp.Save(strm, System.Drawing.Imaging.ImageFormat.Png);
strm.Seek(0, SeekOrigin.Begin);
PngBitmapDecoder pbd = new PngBitmapDecoder
	(strm, BitmapCreateOptions.None, BitmapCacheOption.Default);
btnImage.Source = pbd.Frames[0];


I know there is nothing much in the code. I put it just to get some comments on the tool for its improvement. I would also like some ideas to use it in Notebook.


  • 22nd December, 2008: Initial post
  • 29th December, 2008: Updated with new EXE version (


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Web Developer
Japan Japan
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralDrag and drop Pin
oned231-Dec-08 9:55
memberoned231-Dec-08 9:55 
GeneralRe: Drag and drop Pin
_anil_1-Jan-09 3:19
member_anil_1-Jan-09 3:19 
GeneralRe: Drag and drop Pin
_anil_6-Jan-09 0:24
member_anil_6-Jan-09 0:24 
GeneralVersion Release Pin
_anil_23-Dec-08 22:13
member_anil_23-Dec-08 22:13 
General[Message Deleted] Pin
georgejh23-Dec-08 3:04
membergeorgejh23-Dec-08 3:04 
GeneralRe: This methodology is under copyright sisnce 1998 Pin
_anil_23-Dec-08 3:42
member_anil_23-Dec-08 3:42 
I have developed it for my use and for learning WPF. Its some thing similar to your application but very simple one than yours.
If Microsoft had patent for notpad it doesn't mean that we are not allow to develop out editor. Wink | ;)


General[Message Deleted] Pin
georgejh23-Dec-08 3:50
membergeorgejh23-Dec-08 3:50 
GeneralRe: This methodology is under copyright sisnce 1998 Pin
_anil_23-Dec-08 3:55
member_anil_23-Dec-08 3:55 
General[Message Deleted] Pin
georgejh23-Dec-08 4:11
membergeorgejh23-Dec-08 4:11 
General[Message Deleted] Pin
georgejh23-Dec-08 4:13
membergeorgejh23-Dec-08 4:13 
GeneralRe: This methodology is under copyright sisnce 1998 Pin
_anil_23-Dec-08 4:53
member_anil_23-Dec-08 4:53 
GeneralRe: This methodology is under copyright sisnce 1998 Pin
Alex Kvachev23-Dec-08 6:36
memberAlex Kvachev23-Dec-08 6:36 
GeneralVote 3 Pin
johannesnestler22-Dec-08 23:29
memberjohannesnestler22-Dec-08 23:29 
GeneralRe: Vote 3 [modified] Pin
_anil_23-Dec-08 3:37
member_anil_23-Dec-08 3:37 
GeneralRe: Vote 3 Pin
_anil_23-Dec-08 22:15
member_anil_23-Dec-08 22:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.151126.1 | Last Updated 5 Jan 2009
Article Copyright 2008 by _anil_
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid