468,107 Members | 1,302 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,107 developers. It's quick & easy.

Launch WinApp from Keyboard press

Hi

I am in need of a way to launch my WinForms-app (app.exe) just by pressing a
keyboard combination like (Ctrl-Alt-P).
This functionality should be present "out of the box" after the app
(app.exe) is deployed on the Client's PC. The only way I know - is to place
a shortcut on the desktop and associate a "ShortCut Key" to it by
right-clicking on the shorcut on the desktop.

Now - how do I, do that during installation using Windows Installer (from
VS.NET 2003)??

Thanks a million!

/Ole Hanson
Nov 16 '05 #1
13 3097
Ole Hanson wrote:
Hi

I am in need of a way to launch my WinForms-app (app.exe) just by pressing a
keyboard combination like (Ctrl-Alt-P).
This functionality should be present "out of the box" after the app
(app.exe) is deployed on the Client's PC. The only way I know - is to place
a shortcut on the desktop and associate a "ShortCut Key" to it by
right-clicking on the shorcut on the desktop.

Now - how do I, do that during installation using Windows Installer (from
VS.NET 2003)??

Thanks a million!

/Ole Hanson


I'm interested in the same question. Only I was looking for assigning my progmra to a key like Print Screen.
I doubt its possible though. Maybe there is some registry setting.
Otherwise the program has to be running you have register a hotkey, so messages are sent to the application.
I guess you could make a very small service that does that and then launches the main application.
My program takes around 13mb of memory to stay open, its not something I could afford starting with the computer.
Nov 16 '05 #2
There is no direct way of specifying the Shortcut key for an exe in the
setup project.

Try this

Create a c# project to create a Shell Link for your EXE. You can specify the
shortcut key while creating Shell Link in the program.

After compiling the program, add the C# program as a "Custom action" in the
"custom action editor"

To create Shell link in c# use the interface specified in the following URL

http://www.vbaccelerator.com/home/NE...jects/Creating
_and_Modifying_Shortcuts/ShellLink_Code_zip_ShellLink%5CShellLink_cs.asp

--
Shak
(Houston)
"Ole Hanson" <ol********@ole.ole> wrote in message
news:cc**********@news.cybercity.dk...
Hi

I am in need of a way to launch my WinForms-app (app.exe) just by pressing a keyboard combination like (Ctrl-Alt-P).
This functionality should be present "out of the box" after the app
(app.exe) is deployed on the Client's PC. The only way I know - is to place a shortcut on the desktop and associate a "ShortCut Key" to it by
right-clicking on the shorcut on the desktop.

Now - how do I, do that during installation using Windows Installer (from
VS.NET 2003)??

Thanks a million!

/Ole Hanson

Nov 16 '05 #3
You should also look into global hooks:
http://www.codeproject.com/csharp/globalhook.asp

One solution is to install a global hook and have your application run in
the background (maybe even as a service that runs at startup). The hook
could then launch the main window of the application.

--
John Wood
EMail: first name, dot, second name at priorganize.com
"Ole Hanson" <ol********@ole.ole> wrote in message
news:cc**********@news.cybercity.dk...
Hi

I am in need of a way to launch my WinForms-app (app.exe) just by pressing a keyboard combination like (Ctrl-Alt-P).
This functionality should be present "out of the box" after the app
(app.exe) is deployed on the Client's PC. The only way I know - is to place a shortcut on the desktop and associate a "ShortCut Key" to it by
right-clicking on the shorcut on the desktop.

Now - how do I, do that during installation using Windows Installer (from
VS.NET 2003)??

Thanks a million!

/Ole Hanson

Nov 16 '05 #4
John Wood wrote:
You should also look into global hooks:
http://www.codeproject.com/csharp/globalhook.asp

One solution is to install a global hook and have your application run in
the background (maybe even as a service that runs at startup). The hook
could then launch the main window of the application.


Thank you for that link. Its EXACTLY what I was looking for. A tiny monitoring servie that can be enabled diabled from other apps
through public methods. AND it satisfy my other need for global mouse hooks. Thanks a lot.

Nick Z.
Nov 16 '05 #5
>> > My program takes around 13mb of memory to stay open, its not something
I could afford starting with the computer. <<

When you say this, are you referring to the impact it would have at startup?
(ie. time to start windows?). This shouldn't be so long if you're not
referencing many assemblies (especially try to miss out winforms if you
can).

Or are you referring to the memory overhead always present when the
application is running? Because the latter shouldn't be a problem as the
application will likely be paged out.

--
John Wood
EMail: first name, dot, second name at priorganize.com
"Nick" <pa*****@optonline.net> wrote in message
news:R5*********************@news4.srv.hcvlny.cv.n et...
Ole Hanson wrote:
Hi

I am in need of a way to launch my WinForms-app (app.exe) just by pressing a keyboard combination like (Ctrl-Alt-P).
This functionality should be present "out of the box" after the app
(app.exe) is deployed on the Client's PC. The only way I know - is to place a shortcut on the desktop and associate a "ShortCut Key" to it by
right-clicking on the shorcut on the desktop.

Now - how do I, do that during installation using Windows Installer (from VS.NET 2003)??

Thanks a million!

/Ole Hanson
I'm interested in the same question. Only I was looking for assigning my

progmra to a key like Print Screen. I doubt its possible though. Maybe there is some registry setting.
Otherwise the program has to be running you have register a hotkey, so messages are sent to the application. I guess you could make a very small service that does that and then launches the main application. My program takes around 13mb of memory to stay open, its not something I

could afford starting with the computer.
Nov 16 '05 #6
Yeah it's a great article and library... especially seeing as all the .net
documentation says it's not possible to have global hooks. Sometimes it's
best not to believe what everyone tells you...

--
John Wood
EMail: first name, dot, second name at priorganize.com
"Nick" <pa*****@optonline.net> wrote in message
news:RI*********************@news4.srv.hcvlny.cv.n et...
John Wood wrote:
You should also look into global hooks:
http://www.codeproject.com/csharp/globalhook.asp

One solution is to install a global hook and have your application run in the background (maybe even as a service that runs at startup). The hook
could then launch the main window of the application.

Thank you for that link. Its EXACTLY what I was looking for. A tiny

monitoring servie that can be enabled diabled from other apps through public methods. AND it satisfy my other need for global mouse hooks. Thanks a lot.
Nick Z.

Nov 16 '05 #7
John Wood wrote:
My program takes around 13mb of memory to stay open, its not something


I could afford starting with the computer. <<

When you say this, are you referring to the impact it would have at startup?
(ie. time to start windows?). This shouldn't be so long if you're not
referencing many assemblies (especially try to miss out winforms if you
can).

Or are you referring to the memory overhead always present when the
application is running? Because the latter shouldn't be a problem as the
application will likely be paged out.


I was reffering to both. Startup especially.
What do you mean by it being paged out?
Nov 16 '05 #8
Just an idea that will NOT have anything running in the background consuming
memory.

By writing a small JScript file and the ShellObject (IShell), one can grap
hold of the shortcuts on the users desktop and here assign a "HotKey" (same
as Shorcut Key). This JScript file can be executed on the Commit Event from
the Windows Installer Package (known as Custom Actions). In this way - the
key combination of my desire is associated with the shortcut to my program
directly within the operating system.

/Ole Hanson


"Nick" <pa*****@optonline.net> wrote in message
news:RI*********************@news4.srv.hcvlny.cv.n et...
John Wood wrote:
You should also look into global hooks:
http://www.codeproject.com/csharp/globalhook.asp

One solution is to install a global hook and have your application run in
the background (maybe even as a service that runs at startup). The hook
could then launch the main window of the application.


Thank you for that link. Its EXACTLY what I was looking for. A tiny
monitoring servie that can be enabled diabled from other apps through
public methods. AND it satisfy my other need for global mouse hooks.
Thanks a lot.

Nick Z.

Nov 16 '05 #9
Paged out... in simple terms, the application's virtual memory is written
out to disk (paged out) and freed. When anything tries to access that
memory, it's paged back in and re-allocated.. this happens when you don't
touch an application for like 10 minutes, for example. Basically it means
you don't really have to worry about the memory consumption of an
application that is infrequently used.

The startup penalty can be somewhat removed if you limit the assembles that
are loaded. The WinForms assembly, in particular, has a big penalty in
startup time.

In my application, for example, I have a proxy loader, referencing minimal
assembles... a small executable that uses the Win32 API directly to display
a splash screen, and then load the larger executable that uses
Windows.Forms.

The benefit being that startup time at least appears to be faster (or more
responsive).. better than sitting there wondering what's happening while
it's loading.

--
John Wood
EMail: first name, dot, second name at priorganize.com
"Nick" <pa*****@optonline.net> wrote in message
news:6%*********************@news4.srv.hcvlny.cv.n et...
John Wood wrote:
>My program takes around 13mb of memory to stay open, its not something


I could afford starting with the computer. <<

When you say this, are you referring to the impact it would have at startup? (ie. time to start windows?). This shouldn't be so long if you're not
referencing many assemblies (especially try to miss out winforms if you
can).

Or are you referring to the memory overhead always present when the
application is running? Because the latter shouldn't be a problem as the
application will likely be paged out.


I was reffering to both. Startup especially.
What do you mean by it being paged out?

Nov 16 '05 #10
Ole Hanson wrote:
Just an idea that will NOT have anything running in the background consuming
memory.

By writing a small JScript file and the ShellObject (IShell), one can grap
hold of the shortcuts on the users desktop and here assign a "HotKey" (same
as Shorcut Key). This JScript file can be executed on the Commit Event from
the Windows Installer Package (known as Custom Actions). In this way - the
key combination of my desire is associated with the shortcut to my program
directly within the operating system.

/Ole Hanson


"Nick" <pa*****@optonline.net> wrote in message
news:RI*********************@news4.srv.hcvlny.cv.n et...
John Wood wrote:
You should also look into global hooks:
http://www.codeproject.com/csharp/globalhook.asp

One solution is to install a global hook and have your application run in
the background (maybe even as a service that runs at startup). The hook
could then launch the main window of the application.


Thank you for that link. Its EXACTLY what I was looking for. A tiny
monitoring servie that can be enabled diabled from other apps through
public methods. AND it satisfy my other need for global mouse hooks.
Thanks a lot.

Nick Z.



I was thinking of that but my main concern is the fact that the shortcut key has to be something like
Alt+Ctr+N meaning its not as direct as simply pressing Print Screen or simply N. Or am I wrong.
Nov 16 '05 #11
John Wood wrote:
Paged out... in simple terms, the application's virtual memory is written
out to disk (paged out) and freed. When anything tries to access that
memory, it's paged back in and re-allocated.. this happens when you don't
touch an application for like 10 minutes, for example. Basically it means
you don't really have to worry about the memory consumption of an
application that is infrequently used.

The startup penalty can be somewhat removed if you limit the assembles that
are loaded. The WinForms assembly, in particular, has a big penalty in
startup time.

In my application, for example, I have a proxy loader, referencing minimal
assembles... a small executable that uses the Win32 API directly to display
a splash screen, and then load the larger executable that uses
Windows.Forms.

The benefit being that startup time at least appears to be faster (or more
responsive).. better than sitting there wondering what's happening while
it's loading.


An interesting bit of information, thank you.
However, the assembles that are loaded are mandatory in my application.

And the way I wish to be running the application is.
----
Monitoring service is running in the back.
When key combo detected, launches main app, stops monitoring.
My app *quickly* opens and does its job, enables monitoring service, closes.
----

The following assemblies are referenced in my main application.

using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Runtime.InteropServices;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
using Microsoft.DirectX.AudioVideoPlayback;
Which is quite alot I think.
I was wondering if there is a performance, startup, memory usage, difference to using this instead of referencing a whole
assembly. For example if I need the Device object from DirectX assembly. I do this in code.

---
//not sure if thats the right path, but you get the idea.
Microsoft.DirectX.Device myDevice;
---

Instead of using Microsoft.DirectX;. But I suppose the compiler does that for me. Am I correct?

Nick Z.
Nov 16 '05 #12
Yeah there's not much difference between referencing classes with the fully
qualified namespace, and just putting the 'using' clause at the top of the
file. At the end of the day, if the project contains a reference to the
assembly, it'll be loaded.

Probably the largest of those assemblies would be the directx ones. Is even
the directx assembly used immediately in your application? The good thing
about .net is that it lets you dynamically load assemblies.

--
John Wood
EMail: first name, dot, second name at priorganize.com
"Nick" <pa*****@optonline.net> wrote in message
news:i8*********************@news4.srv.hcvlny.cv.n et...
John Wood wrote:
Paged out... in simple terms, the application's virtual memory is written out to disk (paged out) and freed. When anything tries to access that
memory, it's paged back in and re-allocated.. this happens when you don't touch an application for like 10 minutes, for example. Basically it means you don't really have to worry about the memory consumption of an
application that is infrequently used.

The startup penalty can be somewhat removed if you limit the assembles that are loaded. The WinForms assembly, in particular, has a big penalty in
startup time.

In my application, for example, I have a proxy loader, referencing minimal assembles... a small executable that uses the Win32 API directly to display a splash screen, and then load the larger executable that uses
Windows.Forms.

The benefit being that startup time at least appears to be faster (or more responsive).. better than sitting there wondering what's happening while
it's loading.

An interesting bit of information, thank you.
However, the assembles that are loaded are mandatory in my application.

And the way I wish to be running the application is.
----
Monitoring service is running in the back.
When key combo detected, launches main app, stops monitoring.
My app *quickly* opens and does its job, enables monitoring service,

closes. ----

The following assemblies are referenced in my main application.

using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Runtime.InteropServices;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
using Microsoft.DirectX.AudioVideoPlayback;
Which is quite alot I think.
I was wondering if there is a performance, startup, memory usage, difference to using this instead of referencing a whole assembly. For example if I need the Device object from DirectX assembly. I do this in code.
---
//not sure if thats the right path, but you get the idea.
Microsoft.DirectX.Device myDevice;
---

Instead of using Microsoft.DirectX;. But I suppose the compiler does that for me. Am I correct?
Nick Z.

Nov 16 '05 #13
John Wood wrote:
Yeah there's not much difference between referencing classes with the fully
qualified namespace, and just putting the 'using' clause at the top of the
file. At the end of the day, if the project contains a reference to the
assembly, it'll be loaded.

Probably the largest of those assemblies would be the directx ones. Is even
the directx assembly used immediately in your application? The good thing
about .net is that it lets you dynamically load assemblies.


Hmmm. Thats a good idea. The dx assembly will not be even used MOST of the time. I dindn't even know it was possible.

Thanks.
Nick Z.
Nov 16 '05 #14

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by Pelo GANDO | last post: by
7 posts views Thread by Paul | last post: by
reply views Thread by Nuno | last post: by
4 posts views Thread by Melson | last post: by
reply views Thread by Fromethius | last post: by
5 posts views Thread by bint | last post: by
1 post views Thread by Solo | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.