[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Space Bar

Posted on 2006-11-28
8
Medium Priority
?
1,018 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 30

Expert Comment

by:anarki_jimbel
ID: 18033637
0
 
LVL 86

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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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 86

Accepted Solution

by:
Mike Tomlinson earned 375 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

649 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