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
    • Recent
    • Tags
    • Users
    • Login

    Getting keyboard character [SOLVED]

    Scheduled Pinned Locked Moved PYTHON Development
    4 Posts 0 Posters 354 Views
    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 Offline
      Helper
      last edited by

      On 12/10/2015 at 06:50, xxxxxxxx wrote:

      I want to get the character that the user pressed on the keyboard.

      I am using some code posted here on the forum, but the value is always > 128.
      How to get the character the user pressed?

              channel = bc.GetLong(c4d.BFM_INPUT_CHANNEL)
              print "channel: ", channel
              if channel<128: # ascii key code
                  chr = str(unichr(channel))
                  print chr
                  if chr=='B':
                      return True
      
      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 13/10/2015 at 01:47, xxxxxxxx wrote:

        Hello,

        to get the string representation of the character pressed use BFM_INPUT_ASC. You see how it is used in the Liquid Painter tool example.

        Best wishes,
        Sebastian

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

          On 19/10/2015 at 04:38, xxxxxxxx wrote:

          Thanks.
           I can now use it in a commandplugin message:

                  dev = bc.GetInt32(c4d.BFM_INPUT_DEVICE)
                  if dev == c4d.BFM_INPUT_KEYBOARD:
                      print "Keyboard, qual, VALUE: ", bc.GetInt32(c4d.BFM_INPUT_QUALIFIER), bc.GetString(c4d.BFM_INPUT_ASC)
                      return True
          

          but it is not working in the coremessage of a message plugin.
          I am doing this because the message plugin always detects the keyboard and my own plugin only when it is active.
          Is a ">" detected, then a messsage is send from the message plugin to my own pluhin.

          -Pim

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

            On 19/10/2015 at 09:25, xxxxxxxx wrote:

            Hello,

            do you mean with "message plugin" a MessageData plugin? Could you post some more complete code? Since the original question is answered you might want to open a new thread.

            Best wishes,
            Sebastian

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