473,408 Members | 1,854 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

hot keys in Console Application

Hi! I am new to C#. I read two C# books in the last two days which only
covered the basics. And now I am on my third day. The books were really bad,
because they did not cover windows applications, only ten to twenty pages how
to create forms.

So now you know why I want to have hotkeys in a CONSOLE Application. Is this
possible? I would be glad if you could give me some links in the msdn or just
the names of the functions needed.

If it's not possible how can I do it with minimum effort?
Aug 17 '07 #1
4 3710
Alexander wrote:
Hi! I am new to C#. I read two C# books in the last two days which only
covered the basics. And now I am on my third day. The books were really bad,
because they did not cover windows applications, only ten to twenty pages how
to create forms.

So now you know why I want to have hotkeys in a CONSOLE Application.
Maybe I'm just thick, but I don't know why you want to have hotkeys in a
console application. I presume the first paragraph was supposed to
explain that, but I don't get it.
Is this
possible? I would be glad if you could give me some links in the msdn or just
the names of the functions needed.

If it's not possible how can I do it with minimum effort?
You should probably be more specific. Typically, a "hot key" is a
shortcut key that maps to some GUI command. Because a GUI application
is constantly in an event-handling loop (or at least, it should be :) )
it can always respond to user input.

A console application only responds to user input at certain times. If
you want to write a console application that can always respond to user
input, you should probably use a secondary thread to do whatever the
application is normally supposed to do, and have your main thread sit in
a loop accepting user input with ReadKey(). Then you can process the
keyboard input however you like.

Of course, you'll have to have some way for the threads to communicate
with each other, which introduces some complexity. The alternative is
to somehow have your main processing interrupt itself periodically to
check for input and respond to that. This is similar, but not
necessarily identical, to how the inter-thread communication would work
anyway, so to some extent that's "six of one, half-dozen of the other". :)

Pete
Aug 17 '07 #2
On Aug 16, 7:47 pm, Alexander <Alexan...@discussions.microsoft.com>
wrote:
Hi! I am new to C#. I read two C# books in the last two days which only
covered the basics. And now I am on my third day. The books were really bad,
because they did not cover windows applications, only ten to twenty pages how
to create forms.

So now you know why I want to have hotkeys in a CONSOLE Application. Is this
possible? I would be glad if you could give me some links in the msdn or just
the names of the functions needed.

If it's not possible how can I do it with minimum effort?
Hi Alexander,
Not sure what books you read but here is a link to a excellent free
one, pdf.
This covers the C# language. Also, a console app does not use windows
GUI( windows forms).

http://www.charlespetzold.com/dotnet/

Jeff
Aug 17 '07 #3
So like my subject says, I have a windows form that has a side bar with some controls. The users are going to use the web browser for reading a script and it would be great if they didn't have to use the mouse to click the buttons but they could use hotkeys to hit the buttons. There are a couple problems I have encountered. First, I remember using VB 6.0 and being able to set the text of a button with an & and using the next character after it in the text as a shortcut. It looks like that would work here but it doesn't. Another issue I have is that while they are scrolling on the browser and maybe clicking buttons, I don't now how to send the window key strokes because the browser is getting "all of the attention" haha. How do I fix this?

EggHeadCafe - .NET Developer Portal of Choice
http://www.eggheadcafe.com
Aug 24 '07 #4
On Fri, 24 Aug 2007 11:37:28 -0700, Triple Threat wrote:
>So like my subject says, I have a windows form that has a side bar with some controls.
The users are going to use the web browser for reading a script and it would be great
if they didn't have to use the mouse to click the buttons but they could use hotkeys
to hit the buttons. There are a couple problems I have encountered. First, I remember
using VB 6.0 and being able to set the text of a button with an & and using the next
character after it in the text as a shortcut. It looks like that would work here but
it doesn't. Another issue I have is that while they are scrolling on the browser and
maybe clicking buttons, I don't now how to send the window key strokes because the
browser is getting "all of the attention" haha. How do I fix this?

EggHeadCafe - .NET Developer Portal of Choice
http://www.eggheadcafe.com
Use:

SendKeys.Send("^f");

to emulate a keystroke from code. SendKeys.Send() sends a keystroke
to the form that has focus.

rossum

Aug 24 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Etienne Charland | last post by:
Hi, there is an application running on a remote desktop (under Citrix ICA, but the same problem applies for RDC or PC Anywhere). Now, I want to send keys to the remote application from a local app....
1
by: Oz | last post by:
This is long. Bear with me, as I will really go through all the convoluted stuff that shows there is a problem with streams (at least when used to redirect stdout). The basic idea is that my...
7
by: Joseph Lee | last post by:
Hi All, I am having problem when i am using hashtable to keep an array of bytes value as keys. Take a look at the code snippet below --------------------------------------------------- ...
5
by: Flip | last post by:
I'm trying to create a form which a user can type out a key, and the CTRL-ALT-SHIFT keys are recognized (via ModifiedKeys object) and then pass the letter the user pressed to the windows API method...
3
by: Atchoum | last post by:
Hi, I am using the inireader class from mentalis.org but this does not provide a function for retrieving all the key values of a particular section. Anyone has developed such a function? I tried...
6
by: buzzweetman | last post by:
Many times I have a Dictionary<string, SomeTypeand need to get the list of keys out of it as a List<string>, to pass to a another method that expects a List<string>. I often do the following: ...
4
by: Mo | last post by:
Hi, I am writing a console application to send a key sequence to an old clunky application on a regular interval using the windows scheduler. I can get it to work if it is a windows form...
3
by: hurricane_number_one | last post by:
I want to be able to play/pause/next/back the tracks in whatever media player app is running. So if iTunes is running, it will receive those commands, if Windows Media Player is, it will receive...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.