Announcement

Collapse
No announcement yet.

Sending ALT-N to top level window

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Sending ALT-N to top level window

    How can I send ALT-N to current window?

    Thanks

    ------------------
    -Greg
    -Greg
    [email protected]
    MCP,MCSA,MCSE,MCSD

  • #2
    SendMessage hWnd, %WM_CHAR, wparam, lparam

    MCM
    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      Michael,

      That's pretty basic but I wanted to know how to send it to the
      top level window or all windows. I've tried this:

      SendMessage %HWND_BROADCAST, %WM_CHAR, 78, 29

      Doesnt work. Basically I'm wanting to simulate a remote
      installation of a setup program and it prompts for a user to
      press next and that is the only prompt. so I need to simulate
      ALT-N on the top level window.



      ------------------
      -Greg
      -Greg
      [email protected]
      MCP,MCSA,MCSE,MCSD

      Comment


      • #4
        Greg --

        As far as I know, it's not possible (or even a good idea ) to "broadcast" a keystroke to multiple windows in one step.

        Have you looked at the keybd_event API? That is the most reliable way to send a keystroke to the window that has the foreground because it is independent of the target app. It will work for GUI-style apps, console apps, DOS apps...

        For a complete example search the BBS for keybd_event.

        -- Eric


        ------------------
        Perfect Sync Development Tools
        Perfect Sync Web Site
        Contact Us: mailto:[email protected][email protected]</A>

        [This message has been edited by Eric Pearson (edited July 27, 2001).]
        "Not my circus, not my monkeys."

        Comment


        • #5
          Originally posted by Gregery D Engle:
          Michael,

          That's pretty basic but I wanted to know how to send it to the
          top level window or all windows. I've tried this:

          SendMessage %HWND_BROADCAST, %WM_CHAR, 78, 29

          Doesnt work. Basically I'm wanting to simulate a remote
          installation of a setup program and it prompts for a user to
          press next and that is the only prompt. so I need to simulate
          ALT-N on the top level window.

          What's about
          hwnd = FindWindow(windowclass, windowcaption)
          hwnd = FindWindowEx(hwnd, 0, "Button", "&Next"

          SendMessage hWnd, BM_CLICK, 0, 0

          ------------------
          E-Mail (home): mailto:[email protected][email protected]</A>
          E-Mail (work): mailto:[email protected][email protected]</A>

          Comment


          • #6
            Sven --

            That might work too, but it would be limited to English versions of Windows.

            Hmmm... On the other hand, so would Alt-N, probably.

            -- Eric

            ------------------
            Perfect Sync Development Tools
            Perfect Sync Web Site
            Contact Us: mailto:[email protected][email protected]</A>
            "Not my circus, not my monkeys."

            Comment


            • #7
              There is a magic Keybd_Event (for roreground window).
              But better to start Spy++ and to look WM_COMMAND.

              ------------------
              E-MAIL: [email protected]

              Comment


              • #8
                Um, wouldn't "broadcasting" a keystroke assume that all Top-level windows are currently in a state such that they are even looking for that key?

                I can personally assure you that I have an application I have written which does NOT look for alt-n on any screen.

                In your case - a "remote install - I think a couple copies of PC Anywhere at about $150.00 per out to handle the remoteness a lot quicker and less expensively than trying to find a code solution...

                MCM



                [This message has been edited by Michael Mattias (edited July 27, 2001).]
                Michael Mattias
                Tal Systems (retired)
                Port Washington WI USA
                [email protected]
                http://www.talsystems.com

                Comment


                • #9
                  Michael,

                  I mean a silent install. I have 80 computers to upgrade in a
                  few hours. Much easier to simply put something in the login
                  script.

                  ------------------
                  -Greg
                  -Greg
                  [email protected]
                  MCP,MCSA,MCSE,MCSD

                  Comment


                  • #10
                    According to Jeffery Richter and Jonathan Locke in their Book Windows 95 A Developers Guide
                    The only fool-proof method of sending keystrokes is to use the Journal PlayBack Hook.

                    James


                    ------------------

                    Comment

                    Working...
                    X