472,992 Members | 3,390 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

SendKeys.Send("^(P)") not working

Hi,

I am trying to use the "System.Windows.Forms.SendKeys" class for triggering
the Ctrl+P key.

Syntax:
System.Windows.Forms.SendKeys.Send("^(P)")

This is not working ..what could be the reason..?

Situation:
I have a menu in my form, which is given a short key "Ctrl+P", now when the
form gets loaded, when I press the "Ctrl+P" then the menu functionality is
working. But the same thing I wanted to trigger on a button on click with
the following code..

System.Windows.Forms.SendKeys.Send("^(P)")

this is not working..

Note: Infact any of the "Ctr+AnyAlphabet", ie, Ctrl+A or..Ctrl+B..or
...C..like that is not working when using
System.Windows.Forms.SendKeys.Send("^(P)")
But the same thing is working fine, when I have as "Ctrl+AnyNumber", ie,
Ctrl+1 or Ctrl+2 with
System.Windows.Forms.SendKeys.Send("^(1)")

Please help!
- Gary
Nov 20 '05 #1
6 30737
Hi Gary,

Try System.Windows.Forms.SendKeys.Send("^(p)")

The shortcut key is Ctrl+P and this menu item is triggered by pressing Ctrl
+ "small p" and not Ctrl + "capital P". Using SendKeys, you are sending Ctrl
+ "capital P", which very rightly, will not and does not work.

-Prateek

"Gary" <ms****@microsoft.com> wrote in message
news:e1**************@TK2MSFTNGP12.phx.gbl...
Hi,

I am trying to use the "System.Windows.Forms.SendKeys" class for triggering
the Ctrl+P key.

Syntax:
System.Windows.Forms.SendKeys.Send("^(P)")

This is not working ..what could be the reason..?

Situation:
I have a menu in my form, which is given a short key "Ctrl+P", now when the
form gets loaded, when I press the "Ctrl+P" then the menu functionality is
working. But the same thing I wanted to trigger on a button on click with
the following code..

System.Windows.Forms.SendKeys.Send("^(P)")

this is not working..

Note: Infact any of the "Ctr+AnyAlphabet", ie, Ctrl+A or..Ctrl+B..or
...C..like that is not working when using
System.Windows.Forms.SendKeys.Send("^(P)")
But the same thing is working fine, when I have as "Ctrl+AnyNumber", ie,
Ctrl+1 or Ctrl+2 with
System.Windows.Forms.SendKeys.Send("^(1)")

Please help!
- Gary

Nov 20 '05 #2
Thanks a lot Prateek,
It certainly works :)

- Gary -

"Prateek" <pr**********@msn.com> wrote in message
news:uq**************@TK2MSFTNGP10.phx.gbl...
Hi Gary,

Try System.Windows.Forms.SendKeys.Send("^(p)")

The shortcut key is Ctrl+P and this menu item is triggered by pressing Ctrl + "small p" and not Ctrl + "capital P". Using SendKeys, you are sending Ctrl + "capital P", which very rightly, will not and does not work.

-Prateek

"Gary" <ms****@microsoft.com> wrote in message
news:e1**************@TK2MSFTNGP12.phx.gbl...
Hi,

I am trying to use the "System.Windows.Forms.SendKeys" class for triggering the Ctrl+P key.

Syntax:
System.Windows.Forms.SendKeys.Send("^(P)")

This is not working ..what could be the reason..?

Situation:
I have a menu in my form, which is given a short key "Ctrl+P", now when the form gets loaded, when I press the "Ctrl+P" then the menu functionality is
working. But the same thing I wanted to trigger on a button on click with
the following code..

System.Windows.Forms.SendKeys.Send("^(P)")

this is not working..

Note: Infact any of the "Ctr+AnyAlphabet", ie, Ctrl+A or..Ctrl+B..or
..C..like that is not working when using
System.Windows.Forms.SendKeys.Send("^(P)")
But the same thing is working fine, when I have as "Ctrl+AnyNumber", ie,
Ctrl+1 or Ctrl+2 with
System.Windows.Forms.SendKeys.Send("^(1)")

Please help!
- Gary

Nov 20 '05 #3
*YIKES* Don't Do This!!!! You shouldn't send keystrokes around, just to
invoke some code, you can do it directly. Sending keystrokes is *very*
unreliable, and usually bad programming practice.

<Rant Over>

Hi, Just call the event handler that responds to the menu item:

Public Sub MenuItem1_Click(...) Handles MenuItem1.Click
' This is the sub that handles your menu item click
End Sub

Public Sub ButtonClick (...) Handles Button1.Click
' This is your button

MenuItem1_Click(MenuItem1, New System.EventArgs())

End Sub

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

"Maybe it's a game called 'Punish the User'"
"Gary" <ms****@microsoft.com> wrote in message
news:e1**************@TK2MSFTNGP12.phx.gbl...
: Hi,
:
: I am trying to use the "System.Windows.Forms.SendKeys" class for
triggering
: the Ctrl+P key.
:
: Syntax:
: System.Windows.Forms.SendKeys.Send("^(P)")
:
: This is not working ..what could be the reason..?
:
: Situation:
: I have a menu in my form, which is given a short key "Ctrl+P", now when
the
: form gets loaded, when I press the "Ctrl+P" then the menu functionality is
: working. But the same thing I wanted to trigger on a button on click with
: the following code..
:
: System.Windows.Forms.SendKeys.Send("^(P)")
:
: this is not working..
:
: Note: Infact any of the "Ctr+AnyAlphabet", ie, Ctrl+A or..Ctrl+B..or
: ..C..like that is not working when using
: System.Windows.Forms.SendKeys.Send("^(P)")
: But the same thing is working fine, when I have as "Ctrl+AnyNumber", ie,
: Ctrl+1 or Ctrl+2 with
: System.Windows.Forms.SendKeys.Send("^(1)")
:
: Please help!
: - Gary
:
:
Nov 20 '05 #4
Hello,

"Tom Spink" <th**********@ntlworld.com> schrieb:
MenuItem1_Click(MenuItem1, New System.EventArgs())


Why not use 'MenuItem.PerformClick'?

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #5
That's the one. I wasn't sure if it was a member, I knew about a button, but
not a menu item. I couldn't check, because VS.NET was in VC++ mode. ;-)

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

"Maybe it's a game called 'Punish the User'"
"Herfried K. Wagner [MVP]" <hi*******@m.activevb.de> wrote in message
news:uA**************@tk2msftngp13.phx.gbl...
: Hello,
:
: "Tom Spink" <th**********@ntlworld.com> schrieb:
: > MenuItem1_Click(MenuItem1, New System.EventArgs())
:
: Why not use 'MenuItem.PerformClick'?
:
: --
: Herfried K. Wagner
: MVP · VB Classic, VB.NET
: http://www.mvps.org/dotnet
:
:
Nov 20 '05 #6
Hello,

"Tom Spink" <th**********@ntlworld.com> schrieb:
That's the one. I wasn't sure if it was a member, I knew
about a button, but not a menu item.


I was not sure too but then I thought the framework would be very
inconsistent if there was not a 'PerformClick' method for the 'MenuItem'
class too.

;-)

I couldn't check, because VS.NET was in VC++ mode. ;-)

LOL

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #7

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

Similar topics

0
by: David Kanter | last post by:
Hello, I have a question regarding SendKeys(). I am working on a small VB .Net script that manipulates/automates programs through SendKeys(). Unfortunately, I have run into several problems. ...
2
by: RBohannon | last post by:
I need to create a report in MS Word populated with data from A2K. I have been asked to create the report in Word so that parts of it can be edited as necessary later. The data in the report are...
2
by: Gary | last post by:
I am trying to use the "System.Windows.Forms.SendKeys" class for triggering the Ctrl+P key. Syntax: System.Windows.Forms.SendKeys.Send("^(P)"); This is not working ..what could be the...
0
by: dawn | last post by:
Hi, I'm trying to send input from one form into another in my c# app. I manage to make the form I'm trying to input to active (or at least I think so, cuz when I press keys on my keyboard they...
1
by: Bryan | last post by:
I am writing a C# Windows App that updates out Excel reports' modules. The app is complete, but has a problem. The only way MS allows you to unprotect the VBA code in Excel is to do it by hand or...
0
by: Neil | last post by:
Can anyone tell me if there's a way to fillin a web form using SendKeys? I have written a program that uses Com Interop to create an instance of IE, and navigate to the correct webpage. Then I...
3
by: Phil Galey | last post by:
I have a VB.NET application that uses SendKeys to close the open document in QuarkXPress 5.0 I'm using the following commands: AppActivate(QXP_Process_ID) SendKeys.SendWait("^{F4}") in an...
5
by: =?Utf-8?B?U3JpbWFu?= | last post by:
Hi, We are launching .net window from vb6 form. In .net form tabbing(tab out from one control to another control) was not working. for that i have written a code like Sendkeys.send("{TAB}") in the...
0
by: jairathore | last post by:
Hi, I m working on a project on which my requirment is like that remotely i control another application by using sendkey.sendwait method, i m sending some keystroke to that application and...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

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.