|
Hi!
I've asked a similar question some time ago, but unfortunately without usable results, so I try again.
I put some text into the clipboard and want to trigger a paste action inside a terminal server session (i.e. programmatically do what happens when you press Ctrl+V inside a mstsc window).
Yes, I know that you can't programmatically see the different windows inside the WTS session and that the currently active application will be the target for my paste, but that's exactly what I want.
So far I tried using SendKeys , P/invoke to SendInput and keybd_event , posting WM_PASTE or even WM_KEYDOWN and WM_KEYUP with the exact parameters Spy++ reports, but I can't get it to work.
The first 4 ways simply give no visible result at all, with WM_KEYDOWN/UP I get a plain "v" instead of Ctrl+V.
Does anyone have any further idea?
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
mav.northwind wrote: So far I tried using SendKeys,
Like this?
SendKeys.SendWait("[Clipboard content here]");
or like this:
SendKeys.SendWait("^a^v");
If you've tried the second one, it wont work - as you probably have noticed. Console windows doesn't accept pasting of text. Try getting the content of the clipboard somehow, store it in a string and then write it out like this:
SendKeys.SendWait(clipboardContent);
Kristian Sixhoej
"Failure is not an option" - Gene Kranz
|
|
|
|
|
Hi!
First of all, thanks for you reply.
Unfortunately, neither the first nor the second version has any visible effect on the mstsc window.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Why not do the following, where you know how to write a single char to the console (as indicated in your question where you said you can send a 'v' character):
if (Clipboard.ContainsText()) {
string ct = Clipboard.GetText();
foreach (char c in ct)
WriteCharToConsole(c);
} I know it is a hack, but it will work. Sorry for not getting back to you on your original post, but I got kind of sidetracked. I still plan to look into how to do this the "right" way, but this will suffice until then.
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
Thanks, Jeff.
Skippums wrote: Sorry for not getting back to you on your original post,
No problem here - you're not obliged to solve my problems
The main reason why this "hack" won't do, I'm afraid, is that the clipboard contains RTF...
Nevertheless, thanks for the suggestion.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
What if you read the RTF into the RichTextBox.Rtf property, then read it back out from the RichTextBox.Text property? This raises the hack level to about a 9 out of 10, but again, I think it may work for you. Also, isn't there a way to get RTF text from the clipboard without the formatting? You may want to check into that as well.
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
Sure, there are easy ways to retrieve plain text from RTF, but that's not the point.
The requirement is to paste the contents of a RichTextBox into the terminal server session, just like one would with a local application. Formatting etc. has to be retained.
What I cannot understand is that I don't get the same results when sending the same messages with the same parameters Spy++ is recording...
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Victory is mine! (as Stewie Griffin would say)
Finally, I got some code from a guy in an MCE forum who was sending keystrokes to an mstsc window in response to IR remote control events.
He also used keybd_event (which didn't work in my tests), but also used AttachThreadInput , so I think this was the missing piece.
With this code I was able to send Ctrl+V to mstsc, thus triggering paste into the current application. Works like a charm!
Anyway, thanks for your support!
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Hi,
I am using a DataGrid View on my windows forms.
I want to clear all the rows of the grid on certain event, for that i tried to set the data source property to null. But it also cleared the columns.
I also tried to use the clear function of the rows ut it was of no help;
How can i just clear teh rows and let the columns be intact in there.
Thanks.
Deepak Surana
|
|
|
|
|
deepaks3 wrote: I am using a DataGrid View on my windows forms.
I want to clear all the rows of the grid on certain event, for that i tried to set the data source property to null. But it also cleared the columns.
I also tried to use the clear function of the rows ut it was of no help;
How can i just clear teh rows and let the columns be intact in there.
Clearing a row would surely clear columns too?
Can you give an example of what the result you are looking for?
|
|
|
|
|
Ok,
There are cerain no of rows in the grid, so when i click on the clear button i want that only the column names should be visible but not any rows.
And i have aded the columns on the design time, so i want to retain those columns.
Deepak Surana
|
|
|
|
|
Isn't there a Rows collection that you can clear? AFAIK, it shouldn't change the column headers...
|
|
|
|
|
You may clear the value in loop using row index and column index;
for example: setting null to Row index 0, Column index 0
dgvItemList.Rows[0].Cells[0].Value = "";
I think, u got it. Best of Luck.
Dipak
|
|
|
|
|
dataGridView1.Rows.Clear();
Calling all South African developers! Your participation in this local dev community will be mutually beneficial, to you and us.
|
|
|
|
|
Rows.Clear() isnt working..
Deepak Surana
|
|
|
|
|
Instead of trying to clear the rows on the dataGridView, try clearing the rows on it's data source. lets sat the source of the datagridView is in a DataSet. Lets just make this one up: this.YourDataSet.YourDataTable . Clear the rows from the DataTable, and the DataGridView will see the changes in the DataTable and reflect the cleared rows. Try this:
this.YourDataSet.YourDataTable.Clear();
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
Actually its very simple...
grid.datasource = null;
grid.rows.clear();
grid.refresh();
and a Indian Programmer gave me the solution by the way....
so if an Indian asked a programming question in the forest .... it will be Urgent.. and i think only Indians can solve it.. no others..
Deepak Surana
|
|
|
|
|
Hi,
i want add(not sum) the two difrrent integer veriables value in an array
like this
int i=14;
int j=15;
int []array=new int[3];
array[0]=??? i j
then out of array[0]=1415
I AM WORKING ON "PLOTTER ROBOT"(FYP).
|
|
|
|
|
if i use
string [] str=new string[3];
int i=14;
int j=15;
array[0]=""+i+""+j;
then
array[0]=1415
is it possible in int[]?
I AM WORKING ON "PLOTTER ROBOT"(FYP).
|
|
|
|
|
Convert the two integers into strings, concatenate and assign.
|
|
|
|
|
You get the number if digits in j(it's easier to covert it to string and use the Length property)
private static string Add(int i, int j)
{
int result = (int)(i * (int)Math.Pow((double)10, (double)(j.ToString().Length)) + j);
return result.ToString();
}
Be carefull..this method returns the result as a string..as "adding" to integers might be bigger than Int32.MaxValue !
|
|
|
|
|
Ups..I didn't see that someone already answered.. sorry
|
|
|
|
|
Hi,
I have a Client Server Application that communicates through
socket.
The Client is a VC++(6.0 version) and the Server is a C# application.
While trying to connect to the Socket from the VC++ application by entering the ip for example in - 012.220.200.001 - format I am unable to connect to the listening Socket. I get 10061 or 10049 exception.
But when I try to connect to the Socket server by entering the ip in the format 127.000.000.001(localhost), I am able to connect.
I want to connect to the Server by entering the ip address in either ways.
Please suggest.
Let me know if I will have to change the listen functionality which is currenty
Socket workerSocket = new Socket(AddressFamily.InterNetwork,
SocketType.Stream,
ProtocolType.Tcp)
IPEndPoint ipLocal = new IPEndPoint (IPAddress.Any, port);
m_mainSocket.Bind( ipLocal );
m_mainSocket.Listen(4);
With Thanks and Regards,
Abraham Chethuvelil
|
|
|
|
|
Are you in a local network? ie. Connected to the internet through a router or similar?
Because if you are, and you enter your IP address, you are besically sending the request to the router, which has no idea what machine to pass it on to.
You'd have to set up some port forwarding to get it to work.
My current favourite word is: Bauble!
-SK Genius
|
|
|
|
|
Hi!
I think the format of your IP address is screwed.
If you start it with '0' the numbers will be interpreted as octal.
I just tried a ping to "012.220.200.001" and ping told me that it actually tried to connect to 10.220.200.1!
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|