How to Send Web Requests and Fill Text fields.

General discussions about Automagic and automation in general

Moderator: Martin

Post Reply
art3m15
Posts: 1
Joined: 27 Mar 2014 02:06

How to Send Web Requests and Fill Text fields.

Post by art3m15 » 27 Mar 2014 02:12

Is there a way to use this app to make a script that can fill text fields, send web requests, or click buttons? I would also like to know if this app offers the option to randomize text that is set to be inputted into text fields and if I can use conditional statements to detect when text should be filled out. If this app doesn't support the features above, can someone share an app that does besides Tasker? I already know about Tasker, but it's not compatible with my device.

User avatar
Martin
Posts: 4437
Joined: 09 Nov 2012 14:23

Re: How to Send Web Requests and Fill Text fields.

Post by Martin » 27 Mar 2014 16:51

Hi,

Most of the features are supported by Automagic but some actions might require root and might be difficult to configure, especially simulating input can be difficult to get right:
-fill text fields, click buttons: action Control UI or Execute Root Command: input text abc and Execute Root Command: input tap x y
-send web request: action HTTP Request
-randomize text: can probably be achieved with action Script. Scripts also support conditions (if-then-else).

Please test the evaluation version to see whether Automagic works on your device and to test if you like the way it works:
http://automagic4android.com/en/evaluation

Regards,
Martin

ZSasha
Posts: 103
Joined: 11 Oct 2013 03:48

Re: How to Send Web Requests and Fill Text fields.

Post by ZSasha » 07 Apr 2014 21:36

Hi Martin,

May I advise you to look at the program called "LastPass".

It is online password manager but what makes it special - after the latest update it now can "sense" password fields and interact with them actually putting your password into those fields for you.

What makes it remarkable is the fact that it can do that even for other applications and not just a web pages!
For example when I click on "password" field to type a password for WiFi, LastPass dialog pops up asking me to fill in the field.

If you could see how it was done, may be you could implement similar feature in Automagic too?

User avatar
Martin
Posts: 4437
Joined: 09 Nov 2012 14:23

Re: How to Send Web Requests and Fill Text fields.

Post by Martin » 11 Apr 2014 09:48

Hi,

Thanks for the pointer, very interesting app.

You can use the paste function in Control UI to paste content from the clipboard into a text field of another app (Android 4.3+). It seems that the text field needs to be focused first.
A flow could look like this:
-action Copy Text to Clipboard: test
-action Control UI with script:

Code: Select all

focus(540, 618);
sleep(1000);
paste(540, 618);
The sleep can probably be reduced to a few milliseconds or removed altogether.

Automagic and LastPass both use the accessibility feedback type 'Generic' so the services of the apps clash. You can change the Accessibility Feedback Type of Automagic in the preferences of Automagic to something else like Visual if this causes a problem on your device.


Filling forms in Google Chrome seems to be done using a javascript in the address bar (bookmarklet), that's probably the reason they are showing a popup message hiding the address bar and are asking to press enter ;-).
For testing purposes you can type javascript:alert("Hi!") into the address bar and press enter. This should display a message dialog in Chrome. You can also write more complicated javascript that searches the forms on the page and fills in the values into some text fields.

Regards,
Martin

BoBo
Posts: 74
Joined: 05 May 2014 12:45

Re: How to Send Web Requests and Fill Text fields.

Post by BoBo » 13 May 2014 21:52

You can also write more complicated javascript that searches the forms on the page and fills in the values into some text fields.
The following description has been taken from here - on{x}

Code: Select all

httpClient
Provides HTTP communication functionality.
actions

HttpScriptClientPromise ajax(Object args, Object onSuccess, Object onError) - Sends an http request 
This method should be invoked from JavaScript.

Parameters:

args - the ajax object, containing the following optional parameters
       - url: (String) - REQUIRED. A string containing the URL to which the request is sent.
       - type: (String) - The type of request to make ('POST' or 'GET'). Default is GET.
       - data: (String) - Data to be sent to the server. Default is null.
       - headers: (Map) - A map of additional header key/value pairs to send along with the request (default is null).

   for example: {'Content-Type': 'application/text'} is the array with one key-value object. {'Content-Type': 'application/text',...}

onSuccess - Function onSuccess(body, textStatus, response)
   A callback to be called when the http response is returned with no error. Default is null.
   Data holds the body of the response. Text status is the response status line.

onError - Function onError(textStatus, response)
   A callback to be called when the http fails with an error. Default is null.
   Text status is the response status line, or a descriptive error message in case response was null.
   (you can't have both an error and a response callback called from the request).

Returns:

the request object, it can be used to cancel pending ajax operation.
The onSuccess() and onError() callbacks have the same "response" argument. The response object supports the following properties: String statusText - The response status summary. int status - The response status code. Dictionary headers - A JavaScript dictionary of        the response headers. String getClassName()

Sample:

Send request to GET bing.com

var notification = device.notifications.createNotification('Calling bing.com');
device.ajax(
    {
      url: 'http://www.bing.com/',
      type: 'GET',
      headers: {
        'Content-Type': 'application/xml'
      }
    },
    function onSuccess(body, textStatus, response) {
      var parsedBody;
      if(!(body && (parsedBody = JSON.parse(body)))) {
        var error = {};
        error.message = 'invalid body format';
        error.content = body;
          console.error('error: ',error);
      }
      console.info('successfully received http response!');
      notification.content = 'successfully received http response!';
      notification.show();
    },
    function onError(textStatus, response) {
      var error = {};
      error.message = textStatus;
      error.statusCode = response.status;
        console.error('error: ',error);
    });

Post Reply