473,406 Members | 2,620 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,406 software developers and data experts.

SendKeys.send format to send Ctrl-C = SendKeys.Send("^(C)"); ?

DOSrelic
Cos I got the right window but nothing is copied to the Clipboard altho text is highlighted! Here is a little snippet from the method:
Expand|Select|Wrap|Line Numbers
  1. internal void getHighlightedText()
  2.         {
  3.  // why can it not copy?
  4.             string fff = Clipboard.GetText();
  5.             AttachThreadInput(_activeThreadId, _myProcessId, true);
  6.             SetForegroundWindow(_hWnd);
  7.             SendKeys.Send("^(C)");
  8.             fff = Clipboard.GetText();
  9.             AttachThreadInput(_activeThreadId, _myProcessId, false); //release the attachment
  10.             if (Clipboard.ContainsText())
  11.             {
  12.  
But it doesn't? Any ideas why as the correct windows get highlighted?
Your knowledge and experience will be greatly appreciated, cheers.
Feb 9 '10 #1

✓ answered by tlhintoq

Am I sending the correct string to SendKeys?
Yah got me. Make a quickie Forms app of your own with a text box to test it against. That way you can debug both ends of the process. When your test app receives a keypress then it can tell you want it got and so on.

Otherwise you are shooting an arrow at a target - in the dark.

6 14776
tlhintoq
3,525 Expert 2GB
Don't try to do it through keystroke trickery. Just use the clipboard class and send what you want to the clipboard.
http://msdn.microsoft.com/en-us/libr...clipboard.aspx
Feb 9 '10 #2
Hi tlhintoq, yes and that's what I'm trying to do. Get the other app to utilise the clipboard to copy the highlighted text! If I go ctrl-C then hit the hotkey it works fine but I can't seem to send the ctrl-c keypresses to the foremost window to simulate the copy to clipboard command, any idea why?
Feb 9 '10 #3
tlhintoq
3,525 Expert 2GB
"The other app" ?

So you're not trying to have your application send to the clipboard...
You're trying to programmatically control someone else's application, and make it think a user has pressed control-c.

Does that sound like a correct clarification?

My first guess is that the *window* has nothing to send to the clipboard.
But maybe a control *in* the window does. Forms don't generally have any content to go to the clipboard, but a textbox for example has a .Text property that has text that can go on the clipboard.
Feb 9 '10 #4
Almost correct but I am trying to modify the selected text as per the user's request via a hotkey. Much like wordweb can access anything you have highlighted anywhere but it does not seem to be getting the ctrl-c sequence?The theory being that if I send ctrl-c to the user's current window it would automatically copy the highlighted text in the foreground window to the clipboard so my app can then work on it. Am I sending the correct string to SendKeys? If I am then the problem must lie elsewhere, right?
Feb 9 '10 #5
tlhintoq
3,525 Expert 2GB
Am I sending the correct string to SendKeys?
Yah got me. Make a quickie Forms app of your own with a text box to test it against. That way you can debug both ends of the process. When your test app receives a keypress then it can tell you want it got and so on.

Otherwise you are shooting an arrow at a target - in the dark.
Feb 9 '10 #6
Cheers tlhintoq. Thanks for your help again.
Feb 9 '10 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Mr. Bungle | last post by:
I would like to send email automatically via a command button. I have accomplished this just fine through the following code: (Outlook should already be open for reliable results) Private Sub...
0
by: CLarkou | last post by:
My program in Access (Office 97/2000/XP/2003) opens a database (MAIN MENU) with a listing of all databases in a directory. User selects what database wants to open, and program opens it. I am not...
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: ABinBoston | last post by:
I have a macro that uses the SendKeys function to send F9 - to auto save a record. The Application runs perfectly on many PCs, but on one I get the following error. SendKeys Action Requires...
5
by: Wayne Gibson | last post by:
Hi, Was wondering if somebody could help.. I'm trying to use Sendkeys on a Windows forms. I have entered the following command to simulate a CTRL+ALT+1.. ...
1
by: Logan McKinley | last post by:
I have an application that uses SendKeys.SendWait(...) to send RTF (formatting and all) to a word. I was hoping it would parse the formatting, therefore retaining the original formatting of the...
0
by: Andy Purcell | last post by:
Hello, I am trying to use Send.Send() or Send.SendWait() to simulate an audio mute key being pressed. What string argument should I use for this purpose? Thanks, andy
5
by: Daniel N. | last post by:
I am trying have an application hold down the Shift key (+) and the Alt key (%) simultaneously for a given period of time, or until a condition is met. I tried this but it doesn't work:...
2
by: MLH | last post by:
I have the following code with a SendKeys statement in it. 100 If Me.Dirty Then MsgBox "Form is Dirty!" 120 Dim MyQ As String, MyTitle As String, Response As Boolean 140 MyQ =...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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.