1. Black Friday Sale - 50% off

    B4A Standard for $29 instead of $59!
    Buy Now
    Dismiss Notice

B4A Library SendInput - Emulate user input within your app

Discussion in 'Additional libraries, classes and official updates' started by Jim Brown, Mar 14, 2014.

  1. Jim Brown

    Jim Brown Active Member Licensed User

    SendInput Library v0.2

    * v0.2 31/03/2014
    Added: SwipeParams - Now allowing the delay between each swipe pulse to be increased or decreased.
    Moved: 'Step' parameter from SendSwipe to SwipeParams

    This library allows you to emulate user input within the application. You can send key codes, a string of keys, a single touch tap, and swipe actions.

    To begin using the library you simply define a variable:
    Sub Globals
    ' define a variable for the SendInput library
        Dim si As SendInput
    End Sub
    That's all. The following commands can now be used to send/emulate user input:

    ' Send a single keycode

    ' Send a string of keys

    ' Send a touch tap to absolute coordinate 300,200

    ' Send a swipe action from absolute coordinates 60,70 to 200,300
    si.SendSwipe(60,70 , 200,300)

    ' Change the swipe parameters.
    ' Here, the steps between each swipe point are set to 50 and the
    ' delay between each swipe point to 25ms.
    ' NOTE: It may be necessary to increase the delay for older devices in order
    ' to allow time for the system to pick up each swipe point.
    The download link (below) includes a demo to test out the library.


    Download the library from here - DOWNLOAD
    Last edited: Jun 7, 2018
  2. JakeBullet70

    JakeBullet70 Well-Known Member Licensed User

    Douglas Farias likes this.
  3. Beja

    Beja Expert Licensed User

    Thank you so much for this very very important library. This lib is specially important and useful for presentation and educational Apps.

    God bless you!
  4. carchek

    carchek Member Licensed User

    Your library is out of this world, just what I needed for my project!
    But I have a question. How can I make, da app saves current location on screen and then after 5 seconds scrolls down until user presses a button?
    I am using it as si.sendSwipe; And using it to scroll down a website opened in WebBrowser1.

    Rockefeller Goldman likes this.
  5. Jim Brown

    Jim Brown Active Member Licensed User

    Hello Gegor,
    You can achieve the above with a timer. See attached example.
    Click Start AutoScroll button to begin the auto-scroll action. The webpage will scroll every 5 seconds.
    Press the button again to stop the auto-scrolling.

    Attached Files:

    Rockefeller Goldman and carchek like this.
  6. carchek

    carchek Member Licensed User

    You are very kind! Here, take my like. :)
  7. Jim Brown

    Jim Brown Active Member Licensed User

    Library updated. Added a SwipeParams setting applicable for the swipe action.
    Note that the SendSwipe() Step parameter has now been moved to the SwipeParams().
    Last edited: Mar 31, 2014
  8. G-ShadoW

    G-ShadoW Active Member Licensed User

    Is it possible to send 'service commands' with your library?
    For example, on samsung mobile phone's you have many options for engineer menu.
    *#0011# or *#197328640# etc, is this posible ?
    I have try but without succsess.
  9. G-ShadoW

    G-ShadoW Active Member Licensed User

    I have found a way to send non ussd commands like *#*#197328640#*#* all working ok (without your library)
    but I cant send any command using si.SendKeyCode(KeyCodes.KEYCODE_MENU) etc...
    can your library work also from service module ?
  10. Jim Brown

    Jim Brown Active Member Licensed User

    Hi G-ShadoW
    My (simple) library can only mimic inputs to the program you create.
    One idea, have you looked at Tasker in the Play store? This is a great tool and far more advanced in terms of allowing external control.
  11. G-ShadoW

    G-ShadoW Active Member Licensed User

    Thx for reply, is there any other way to programaticaly send command for menu pressed?
  12. Jim Brown

    Jim Brown Active Member Licensed User

    Yes, but I don't have access to my PC for a while so I can't recall the name of the MENU keycode
    Perhaps ...

    si.SendKeyCode(KeyCodes.KEYCODE_MENU) ?
  13. G-ShadoW

    G-ShadoW Active Member Licensed User

    No, this is not working even phone is rooted!
  14. Jim Brown

    Jim Brown Active Member Licensed User

    Does the sample demo work?
    The SendKeys buttion runs a series of key strokes and single key clicks as follows:

    Sub btn_SendKeys_Click
    Select Rnd(1,8)
    Case 1 : si.SendKeys("Basic")
    Case 2 : si.SendKeys("Android")
    Case 3 : si.SendKeys("Hello")
    Case 4 : si.SendKeys(" ")
    Case 5 : si.SendKeys("123")
    Case 6 : si.SendKeyCode(KeyCodes.KEYCODE_DEL)
    Case 7 : si.SendKeyCode(KeyCodes.KEYCODE_MENU)
    End Select
    End Sub
  15. Herbert32

    Herbert32 Member Licensed User

    It seems that this Library has been deleted and stays in the authors Bin at google-drive.

    Dear Jim, can you please make this library available again?

    or maybe someone who downloaded it earlier can share it please?


    thank you in advance.
  16. Jim Brown

    Jim Brown Active Member Licensed User

    Hello Herbert,
    I have re-uploaded the file and repaired the link above. Hopefully the library still works after all the Android version changes.
    JordiCP and DonManfred like this.
  17. DonManfred

    DonManfred Expert Licensed User

    i did a quick test. It works; even when setting the targetsdk to 26. Tested on Samsung Note 8, Android 8

    Thank you for re-uploading!
    Jim Brown likes this.
  18. Herbert32

    Herbert32 Member Licensed User

    Thank you, Jim,

    it works perfectly on my target device with android 4.2.2

    great to see how the community here helps
    Jim Brown likes this.
  19. Jim Brown

    Jim Brown Active Member Licensed User

    Great! Thanks DonManfred and Herbert. I'm happy to hear it still works.
    DonManfred likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice