Jump to content


Photo

LUA: How to send a specific key to client (reg. ENTER or -)


    7 replies to this topic

    #1 Skyrant

    Skyrant

      Member

    • Members
    • PipPip
    • 27 posts

      Posted 30 October 2014 - 09:24 PM

      LUA development questions:

       

      How do i send a ENTER key to the game/client. As if someone pressed the ENTER key or someone pressed - to open the menu?

       



      #2 Iryoku

      Iryoku

        Advanced Member

      • Windower Staff
      • 488 posts

        Posted 31 October 2014 - 12:46 AM

        We don't have any specific function to do this. You can, however, send a set_key command with windower.send_command. Generally speaking, this isn't a very good approach, though; there are usually more direct and efficient ways to achieve what you want. You should probably describe what you want to accomplish, instead.



        #3 Skyrant

        Skyrant

          Member

        • Members
        • PipPip
        • 27 posts

          Posted 31 October 2014 - 11:26 AM

          Like i said, i want to simulate ENTER to advance a cutscene or - to open the main menu. Very simple. I tried windower.send_command('setkey enter down;setkey enter up') and that worked. It's not pretty but it does the trick.



          #4 Iryoku

          Iryoku

            Advanced Member

          • Windower Staff
          • 488 posts

            Posted 31 October 2014 - 07:09 PM

            The Enternity addon already makes most cutscenes auto-advance. It only stops when there's a choice you need to make. It does this by removing the "wait for enter" byte sequence from the chat log, which is much faster than pressing enter since the next line won't be delayed.



            #5 Skyrant

            Skyrant

              Member

            • Members
            • PipPip
            • 27 posts

              Posted 31 October 2014 - 07:46 PM

              I know the eternity addon, it was just an example. For now my workaround does the trick. but it would be nice to be able to send control characters to the client, like ENTER, PageUp/Down etc.



              #6 Iryoku

              Iryoku

                Advanced Member

              • Windower Staff
              • 488 posts

                Posted 31 October 2014 - 08:00 PM

                I'd just rather not encourage sending key presses. There's almost always a better way to get things done (generally, packet manipulations are more robust). There are a few cases where sending key presses is the only way to accomplish a task, but what we have in place now is a sufficient workaround for those very rare cases.



                #7 zaxtiss

                zaxtiss

                  Advanced Member

                • Members
                • PipPipPip
                • 49 posts

                  Posted 05 October 2015 - 07:17 PM

                  What were you trying to get done with page up / down?

                  #8 Iryoku

                  Iryoku

                    Advanced Member

                  • Windower Staff
                  • 488 posts

                    Posted 05 October 2015 - 10:15 PM

                    That was what I wanted him to clarify. This is a classic example of the XY Problem.






                    1 user(s) are reading this topic

                    0 members, 1 guests, 0 anonymous users