none
Any idea why I am unable to send the enter key? RRS feed

Answers

  • The first thing to learn is the value of searching. Search for previous answers about SendKeys. You will learn that it is not as easy to use as you think. Beginners tend to think that sending keys is an easy solution but it is not.

    If you search for previous answers then you will find many comments about something called focus. Use of SendKeys requires the focus to be set properly; SetForegroundWindow might be enough but it is not guaranteed.

    Another problem is being able to determine if the SendKeys worked.

    Another problem is that game developers often don't want you to use SendKeys or anything like that.



    Sam Hobbs
    SimpleSamples.Info

    • Marked as answer by _Sniffles_ Monday, June 4, 2018 12:21 AM
    Sunday, June 3, 2018 6:26 PM

All replies

  • The first thing to learn is the value of searching. Search for previous answers about SendKeys. You will learn that it is not as easy to use as you think. Beginners tend to think that sending keys is an easy solution but it is not.

    If you search for previous answers then you will find many comments about something called focus. Use of SendKeys requires the focus to be set properly; SetForegroundWindow might be enough but it is not guaranteed.

    Another problem is being able to determine if the SendKeys worked.

    Another problem is that game developers often don't want you to use SendKeys or anything like that.



    Sam Hobbs
    SimpleSamples.Info

    • Marked as answer by _Sniffles_ Monday, June 4, 2018 12:21 AM
    Sunday, June 3, 2018 6:26 PM
  • In my own post I show that I was using Sendkeys. Are you sure you read it?

    I appreciate your response and your time. I would also appreciate it if you didn't simply assume that you know how much work I put into what I have been able to accomplish on my own.

    I did search actually. A lot. A lot a lot. I've tried sending the keys using a variety of methods and none worked including virtual keys and other methods with various codes which I learned about through searching, figuring out how to get that working on my own without asking anyone for help, then testing each method I could learn about and understand.

    No it isn't easy for a variety of reasons, messaging systems, code not managed by Windows, understanding which applications will or won't respond to certain types of input and or characters. etc things I learned about through searching alone.

    The reason I used it is because It's what came up when searching.....I didn't know any better~. I didn't try to use it because "it's easy." I'm coming to C# from Autohotkey.

    I did read other posts. I was under the impression set foreground window was setting the focus, and I learned its best at least according to one person its best to use it just before sending keys so the proper application is focused.

    I was trying to use sendkeys to simply automate sending in game built in console commands, but sending the grave, accent key to open the console doesn't work, just like the enter key. I'm just trying to start learning someplace. Sendkeys works for seemingly all other characters.

    Everything works fine with Autohotkey but I wanted to learn a more established language and so far trying to accomplish what I thought was going to be a fairly simple thing as it is with other scripting type languages, it wasn't but I learned a great deal.

    I've since given up on that and moved on to learning other things as I think I've learned all I could right now from trying to simply send the enter key and grave key to an external application.

    Anyway thank you for your reply.~



    • Edited by _Sniffles_ Monday, June 4, 2018 12:22 AM
    Monday, June 4, 2018 12:21 AM
  • I apologize for being harsh. I have seen many questions like this over many years.

    See my article Clicking a Button in Another Application. It probably does not do exactly what you need but it might provide the general methodology. I don't know what the control is in the other application so I can't be more specific.



    Sam Hobbs
    SimpleSamples.Info


    Monday, June 4, 2018 12:36 AM