Solved

Space Bar

Posted on 2006-11-28
8
1,003 Views
Last Modified: 2008-01-09
Can someone tell me how to code a space bar press in C# please?
0
Comment
Question by:ilovespam12000
8 Comments
 
LVL 29

Expert Comment

by:anarki_jimbel
ID: 18033637
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 18034123
Do you want to TRAP a space bar keypress or SEND a space bar keypress?

If the latter, use SendKeys.Send().
0
 
LVL 8

Expert Comment

by:sabeesh
ID: 18034218
string str = "ggggg" + (char)Keys.Space  + "rrrrr";
            MessageBox.Show(str);
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:ilovespam12000
ID: 18037086
Idle Mind - I need to send a space bar keypress
0
 

Author Comment

by:ilovespam12000
ID: 18037175
Sams publishing assumes a key was pressed.
0
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 125 total points
ID: 18037497
Make sure the app has focus, then use SendKeys.Send():
http://msdn2.microsoft.com/en-us/library/system.windows.forms.sendkeys.send.aspx

Something like:

    SendKeys.Send(" ");

If that doesn't work then you may need to use Win APIs to simulate the keypress at the keyboard level.  You can use keybd_event() or SendInput() for that.

Below are some links that show them being used, though not for Space bar in particular.

keybd_event():
http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/Q_20813844.html

SendInput():
http://www.experts-exchange.com/Programming/Programming_Languages/C_Sharp/Q_21650933.html
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now