C# WPF select/focus notepad

12/20/2014 14:37 Hikarim#1
Hello,
today i wanted to try and make an WPF application that after i click a button it selects an open notepad and sends keys to it...

i googled and found this: [Only registered and activated users can see links. Click Here To Register...]

and if i just copy paste that into my app, it gives me errors :(
can anyone please explain me how this works and how i can make my button select the already oppened notepad and send the keys to it (A,enter,B,enter,C)

this is what i have so far:
Code:
      private void button1_Click(object sender, RoutedEventArgs e)
        {

            SendKeys.Send("{A}");
            SendKeys.Send("{ENTER}");
            SendKeys.Send("{B}");
            SendKeys.Send("{ENTER}");
            SendKeys.Send("{C}");

        }
12/20/2014 16:51 alpines#2
I think you forgot the using statements which are necessary to access SendKeys.
Before you send the keys make sure that you actually activate the window, otherwise you'll be sending these keys to your own window.
12/20/2014 17:31 Hikarim#3
Quote:
Originally Posted by alpines View Post
I think you forgot the using statements which are necessary to access SendKeys.
Before you send the keys make sure that you actually activate the window, otherwise you'll be sending these keys to your own window.
i have them above, this is just the button function, thats what im asking, how do i activate another window?
12/20/2014 17:36 Mostey#4
Quote:
Originally Posted by Hikarim View Post
i have them above, this is just the button function, thats what im asking, how do i activate another window?
Took me 3 seconds to google that: [Only registered and activated users can see links. Click Here To Register...]

They even refer to notepad, please at least show some effort before asking questions.
12/20/2014 17:54 Hikarim#5
Quote:
Originally Posted by Mostey View Post
Took me 3 seconds to google that: [Only registered and activated users can see links. Click Here To Register...]

They even refer to notepad, please at least show some effort before asking questions.
How about you read my post? how about that? -I even linked the same link you did, and i said it doesnt work for me, so please...learn to read.
12/20/2014 18:30 Menan#6
It's not the same link bro!
12/20/2014 19:44 alpines#7
Quote:
Originally Posted by Hikarim View Post
Same basic code... if you dont have an answer to my question dont post! Bunch of douchebags
I'd count you to those too becasue you're not trying to be helpful to solve your problem.

Many basic problems are already solved 1000 times and more so why don't you google it?

Not to forget: You say the snippet you copied crashes and displays errors. Why don't you show us the errors?
12/20/2014 19:52 Mostey#8
Quote:
Originally Posted by Hikarim View Post
Same basic code... if you dont have an answer to my question dont post! Bunch of douchebags
It's a different implementation, ShowWindow and SetForegroundWindow are different functions and besides that, the examples do not contain the same "basic" code. But yeah, however. The douchebags trying to help you are not getting anything in reward but insults from you. I wouldn't be surprised if nobody wants to help you.