Announcement

Collapse
No announcement yet.

Capturing Alt-X

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

  • Capturing Alt-X

    I know I've seen hwo to do this but I want to capture ALT-X or ALT-Z or any alt key like that...

    Can I just get a scancode or do I need to know the ALT key was pressed?

    Right now I can get other keys:
    Code:
    I = WaitKey$
    Select Case Asc(I)
           Case 13,121,89
    End Select
    ------------------
    Scott Turchin
    MCSE, MCP+I
    Computer Creations Software
    http://www.tngbbs.com/ccs
    Scott Turchin
    MCSE, MCP+I
    http://www.tngbbs.com
    ----------------------
    True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

  • #2
    Easiest is to use an accelerator table, but something like the
    following can also be used:
    Code:
         CASE %WM_SYSKEYDOWN
            IF wParam = ASC("X") AND _
               (GetKeyState(%VK_MENU) AND &H8000) <> 0 THEN BEEP
    Note: Not sure it works in DDT dialogs - DDT is hungry and eats
    lots of messages. In subclassed controls / "SDK-style" message
    handlers it works fine though..


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

    Comment


    • #3
      There's another API Call that may help:

      L& = GetAsyncKeyState(%VK_MENU)

      This'll return non-zero if the ALT key were presses since the
      last call to the function.

      Note that the MSB or LSB might be set, based on different
      conditions - you'll have to read win32.hlp for the details.

      It's been a while since I used this function, so read up on it
      before using it, please.

      The function will return zero if the ALT key was NOT pressed since
      the last call to the function.

      Regards,


      ------------------
      Clay C. Clear

      mailto:[email protected][email protected]</A>

      Clay Clear's Software

      Comment


      • #4
        Originally posted by Scott Turchin:
        Right now I can get other keys:
        Code:
        I = WaitKey$
        Select Case Asc(I)
               Case 13,121,89
        End Select
        Er... are you using PB/CC or PB/DLL here? WAITKEY$ is a PB/CC function.

        For PB/CC, checkout the INSHIFT function.

        For PB/DLL, you could use accelerators, GetAsyncKeyState, or even use a keyboard hook. The best choice will depend on what you want to achieve, and what kind of UI you are using. Search for "WH_KEYBOARD" for hook examples.




        ------------------
        Lance
        PowerBASIC Support
        mailto:[email protected][email protected]</A>
        Lance
        mailto:[email protected]

        Comment


        • #5
          When you use PB/DLL, you can also use a hotkey. This enables you to trap
          a key combination independent of which program has focus.
          Search the source code forum for "RegisterHotkey".
          If you want I can mail you source code that uses a hotkey.
          Kind regards
          Eddy


          ------------------
          [email protected]
          Eddy

          Comment


          • #6
            "Alt+X" suggests closing an app... using a hotkey may not be the best choice since that would make it possible to close the app even when another app has the foreground (focus). Also, many app's use the Alt+X combination, and this would be intercepted by the hotkey, producing possibly "unexpected" results.


            ------------------
            Lance
            PowerBASIC Support
            mailto:[email protected][email protected]</A>
            Lance
            mailto:[email protected]

            Comment


            • #7
              Well Lance,
              It is not exactly clear to me what Scott wants to do with this ALT-X..
              Does he want to close his application or on the contrary, does he want to
              prevent that his application is closed by intercepting the key combination..?
              To close his application, he can simply use the old ALT-F4...
              Eddy



              ------------------
              [email protected]
              Eddy

              Comment


              • #8
                I goofed, it is PB/CC, my cable modem comes up for a few minutes at a time (They're working on it, it rains, cable goes out..)...

                Anyway, yes, I want to exit a PB/CC app using ALT-X.



                ------------------
                Scott Turchin
                MCSE, MCP+I
                Computer Creations Software
                http://www.tngbbs.com/ccs
                Scott Turchin
                MCSE, MCP+I
                http://www.tngbbs.com
                ----------------------
                True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

                Comment

                Working...
                X