9 Replies Latest reply on Nov 17, 2010 3:46 AM by mattias72

    Buddy API sendKeys

    GCMNajjar

      I am using webxtra(5.1) with BuddyAPI (using Win7, and Dir8.5 and ba version 4.07). After opening a website that has a text field, I want Dir to auto-fill this field in order to go to the next screen.  Here what I am doing

       

      baPlaceCursor( 94 , 453 ) -- place the cursor over the text field (it works)

      baMouseClick( "left" ) -- simulate a click (it works, the text cursor starts blinking)

      set OK = baSendKeys( "hello" ) -- (nothing happens)

       

      This works if I do it for a field within Director itself but not on the webXtra or any other window (MSWord or Explorer etc).  Is the correct use of this command? I also have Dir11.5 but non of the ba commands work!

       

      Hope you can help,

       

      Al

        • 1. Re: Buddy API sendKeys
          Sean_Wilson Adobe Community Professional
          set OK = baSendKeys( "hello" ) -- (nothing happens)

           

          If nothing happens, you should "examine" the value of your variable 'OK' to see if an error occurred and if so what it is (check the Buddy API docs)

           

           

          This works if I do it for a field within Director itself but not on the webXtra or any other window (MSWord or Explorer etc).  Is the correct use of this command? I also have Dir11.5 but non of the ba commands work!

           

          I don't know why it doesn't work in D11.5 - are you testing the authoring environment or a projector? Do you have the xtra correctly installed? Is there an error message, or does it fail silently - that is: how do you know the commands don't work?

           

          You can get the window handle of the WebXtra sprite. Maybe you should use baActivateWindow() before baSendKeys().

          • 2. Re: Buddy API sendKeys
            GCMNajjar Level 1

            The returned value is 0 which signifies the command was executed correctly.  I tried to get the active window but I always get the Director window handle and never the sprite which is odd!  As to the xtra installation,  the xtra works with other commands except sendKeys which tells me it works but something is peculiar with the way I am using it.

             

            Al

            • 3. Re: Buddy API sendKeys
              Sean_Wilson Adobe Community Professional

              The window handle Buddy obtains ( via baChildWindowList(baStageHandle()) ) seems to be identical with the property at sprite("WebXtra").browserReference - so you could use this in your call to baActivateWindow() and prior to baSendKeys().

               

              That is, something like:

              bActivated = baActivateWindow( sprite("WebXtra").browserReference )
              intSent = baSendKeys("hello")
              
              • 4. Re: Buddy API sendKeys
                GCMNajjar Level 1

                Sean

                bActivateWindow() return 0 which means it isn't successful after using your code.  However, I tried the same code to type into another application (Explorer) and it works.  So it seems the problem is that even though I am clicking on the webXtra sprite, baSendKeys is not recognizing that as a window, instead it is sending these keys to the Director or the Stage window which explains why it is not working.  So the trick is to find the window handle for the xtra which logically should be obtained as you suggested, so I am puzzled.

                 

                Many thanks for your help and any other suggestion you may come up with.  I will keep trying and keep you posted.

                 

                Al

                • 5. Re: Buddy API sendKeys
                  Sean_Wilson Adobe Community Professional

                  Sorry - I'm all out of suggestions. It was always going to be a hack. Did you ask Mauricio of Tabuleiro whether he has any suggestions?

                  • 6. Re: Buddy API sendKeys
                    Brad Eustace

                    Hi GCMNajjar,

                     

                    There might be another solution using a different method.

                     

                    If you are trying to auto complete a form to send data to the internet - it might be even better to use a PHP script hosted on the web server and use GetNetText to post the information you want to the server. This would possibly be the cleaner way to complete information on a form. I think it would be risky setting the mouse position and then entering data using the keyboard command keys as the user might interrupt  the process or change the position of movie on the screen.

                     

                    Just a thought anyway.

                     

                    Cheers,

                    Brad.

                    • 7. Re: Buddy API sendKeys
                      mattias72

                      Well it works... but for some reason u must wait about 1 sec before u call  this function   set OK = baSendKeys(  "hello" )

                      Like I did I used

                       

                      --frame 4

                      baPlaceCursor( 94 , 453 )  -- place the cursor over the text field (it works)

                      baMouseClick( "left" ) --  simulate a click (it works, the text cursor starts blinking)

                       

                      -frame 15

                      set OK = baSendKeys(  "hello" ) -- (It writes hello)

                       

                      /Mattias

                      • 8. Re: Buddy API sendKeys
                        mattias72 Level 1

                        It aint working in Windows Vista ... strange.... works fine in XP and NT though

                        • 9. Re: Buddy API sendKeys
                          mattias72 Level 1

                          I send this in message window in director on windows vista as administrator

                          put baSendKeys( "hello" )

                           

                          and the result is --6

                           

                          according to helpfile:

                          Returns:

                          Integer.
                          Returns an error code. 

                          0

                          success

                          1

                          invalid character in string

                          2

                          window unavailable

                          3

                          unknown error

                          4

                          another SendKeys function is still under  way

                           

                          On windows XP it says

                          --0 and it writes    hello     as it should

                           

                          How can I make it work on Windows Vista?