Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

App Start Behavior 1

Status
Not open for further replies.

EBGreen

Programmer
Apr 1, 2004
2,867
US
Ok, I have done some searching and will continue to do so. I would like to code it so that if my app is run with the SHIFT key held down it behaves differently than if it is just run normally. Any point in the right direction is appreciated.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
HACK

what are you trying to accomplish? have you considered a config file to determine how an application functions? Maybe make things user specific - or allow the user to switch into a certain mode.

Holding down a shift key seems like a hack to me - unless you are booting into crap mode of windows.

 
It is for a utility that we will give to our first level helpdesk staff since they have a hard time collecting the information that we want when they come to us with an issue. Basically it will run 99% of the time in a completely GUI-less mode and collect a basic set of information. FOr that other 1% of the time though I want them to be able to double click it with the shift key down (or something similar) and have it bring up a form where they can tweak what information is collected. Obviously I could (and will) control this through a command line option, but that would require them to run it from a run command with the parameter. The goal here is to make things as simple as possible.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
You could provide them with 2 different short-cuts, labeled appropriately. In the Properties page of the short-cut, just add the appropriate command line argument to the end of the "target" string.
 
That would work if we ever deploy the tool. Right now it will be an as needed stand alone app that they would copy to an end user's machine an run it.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Big picture it is fine if this is not possible. I can make do with just the command line. This would be in the "bells and whistles" category. I saw it as an interesting thing to try and figure out.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
It already does a notification icon that displays status information. By the time it gets to this point though, it is already collecting data. You would need to configure what data to collect before collection begins.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
In that case - yes, I'd add a configuration icon which runs your command line app with some arguments

The user can then choose to configure or run your app

 
Ok, so here is the scenario. First, this app is not installed on any end user machine. This is the progression of events:

1) The user has a problem
2) They call the help desk
3) The helpdesk tries to correct the problem but cannot figure it out
4) The helpdesk calls my group
5) We ask them to collect certain data from the end user's machine
6) They either copy the app directly to the user's machine or they email it to them
7) They tell the user to double click the app
8) The app collects the data that we typically need and zips it all up into a file
9) The user emails the file back or the tech pulls it directly from the user's machine
10) The file is given to us and we do our thing


That is the way it works for 99% of the uses. What I am working on is the other 1%. Let's say that from the nature of the issue we suspect that we know the cause of the problem. To be sure though we need them to collect the contents of a specific registry key that we don't normally collect by default. Here is how I would like that to go:

Steps 1-6 are the same then:
7) The helpdesk tech takes remote control of the machine
8) The tech runs the app while holding the shift key down
9) the config dialog opens and they enter the path to the registry key that we need in a text field
10) They click ok
11) the data is collected along with the extra key.


Distributing a config shortcut is not really valid since the app is never distributed in the traditional sense. If it is not possible to do what I want, that is fine, but I would just like to know one way or the other.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
add a reference to Microsoft.VisualBasic in your project.

Code:
using Microsoft.VisualBasic.Devices;

void Main()
{
 Keyboard keyboard = new Keyboard();
 if ( keyboard.ShiftKeyDown )
 {
  // do something...
 }
}

why doesn't Devices.Keyboard exist in C#?


mr s. <;)

 
Thank you very much. Exactly what I was looking for I suspect. I'll try it and let you know.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Yup. That was it thanks again and a star for you.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
bill77771:

it should be in the System namespace by default: System.Devices.Keyboard.

importing VB-only code seems to defeat the point somewhat.


mr s. <;)

 
AH, yes, in a perfect world. But, VB-only code? Didn't know there was such a thing. (At least I think this is true. I'm new to .net.) Far as I can tell, it's VB-in-name-only; just a dll that needs a new name and some better MSDN documentation. Still, it works.
Thanks,
Bill

 
Why not look for the KeyDown/KeyPress/KeyUp event and use:

if(System.Windows.Forms.KeyEventArgs.KeyCode == Keys.Shift)
{
// Do Something
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top