Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Getting ESC Key input

    PYTHON Development
    0
    4
    480
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Helper
      last edited by

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 27/10/2012 at 21:01, xxxxxxxx wrote:

      Have problems getting the ESC keyboard input to be
      read instead of for example a qualifier key as in this code:

        
      bc=c4d.BaseContainer()   
      if c4d.gui.GetInputState(c4d.BFM_INPUT_KEYBOARD,c4d.BFM_INPUT_CHANNEL, bc) :   
           if bc[c4d.BFM_INPUT_QUALIFIER] & c4d.QCTRL:   
                print "ESC (should be)Pressed"   
      

      Anyone know the correct constants to use?
      I think I've tried all combinations I could
      think of but just run around in circles atm.

      Cheers
      Lennart

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 28/10/2012 at 09:02, xxxxxxxx wrote:

        Good timing.
        I just went through this same hell yesterday. When trying to implement the Esc keypress in my C++ ThreadsExample plugin.

        Give this code a shot:

        #Checks to see if the Esc key was pressed in Python  
        import c4d  
        from c4d import gui  
        def main() :  
          
          msg = c4d.BaseContainer()  
          if gui.GetInputState(c4d.BFM_INPUT_KEYBOARD, c4d.KEY_ESC, msg) :   
              if msg.GetLong(c4d.BFM_INPUT_VALUE)==True:  
                  print "ESC pressed"
        

        The SDK's are very vague and almost no help at all. You can't just go look it up in the SDK.
        I basically had to use my entire bag of tricks and notes from other people's code that I've collected over the years to figure it out. And even then it was rather difficult.

        Here is the C++ code in case anyone needs it too:

        //Checks to see if the Esc key was pressed in C++      
        BaseContainer msg;  
        if(GetInputState(BFM_INPUT_KEYBOARD, KEY_ESC, msg))      
        {  
          if(msg.GetData(BFM_INPUT_VALUE)==TRUE)             //If the Esc button was pressed  
          {  
           GePrint("You pushed the Esc key");             //Print this to the console  
          }  
        }
        

        -ScottA

        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 28/10/2012 at 09:26, xxxxxxxx wrote:

          Thanks Scott. That works fine for my purposes,
          breaking a for loop.

          Cheers
          Lennart

          1 Reply Last reply Reply Quote 0
          • H
            Helper
            last edited by

            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

            On 28/10/2012 at 09:50, xxxxxxxx wrote:

            Looks like one can use the operator on the msg(BaseContainer) directly.

              
            msg=c4d.BaseContainer()   
                if c4d.gui.GetInputState(c4d.BFM_INPUT_KEYBOARD,c4d.KEY_ESC, msg) :   
                    if msg[c4d.BFM_INPUT_VALUE]:   
                        print "ESC Pressed"   
            

            Cheers
            Lennart

            1 Reply Last reply Reply Quote 0
            • First post
              Last post