Creating Autofill and Login for My Ticket System

Hello All,

I am new to using the Keyboard Maestro app.

I am trying to have this app autofill in my login info and click login.

I have used the record button and I am getting hung up on the secondary popup window that asking me to click "next".

It seems like it is recording this action, but when I go to test the macro it doesn't seem to work...

Hey Mark,

Welcome to the forum!  :sunglasses:


Recording macros is a very iffy proposition.

Sometimes they work, but very often you get all kinds of gunk you have to carefully clean them up. Recorded macros do not often manage to be efficient either, so knowing what you're doing is very helpful.

See this if you haven't already:

Getting Started with Keyboard Maestro and the Forum


What ticket system?

Can you provide a URL or a screenshot, so we can get a look at what you're up against?

This is the sort of thing where you have to either predictably drive the UI of the app you're working in – OR if you're using a web browser and KM supports it you can very likely drive it using one of the front-browser actions.

See this for starters:

-Chris

This is the link: https://connect.loffler.com

image

Okay, I've got something working for the first phase.

Note that I've done this two ways – once with a Execute a JavaScript in Google Chrome action and once with native KM actions (just the Company ID for those though).

I can't get anything from the Radio-Button action, so JavaScript seems to be required to click the LOGIN button.

Log-In to Loffler.com v1.00.kmmacros (6.3 KB)

Display-Macro-Image

Keyboard Maestro Export

Something like this should work for dialog number two:

(() => {

   document.querySelector("#nextBtn").click();

})();

But you'll need to right-click on the button and inspect its code to see for sure.

This is what I see

I have tried both of these and it didn't seem to work:

(() => {

   document.querySelector("#button").click();

})();

And:

(() => {

   document.querySelector("#submit").click();

})();

@ccstone knows a lot more than I do, but if that does not work, then recording probably isn't a bad idea.

Or set up exactly what you do manually, for example, tab, type text... and so on, maybe pauses are needed.

As for the button, maybe it works with image recognition and click?

I am just learning this tool and not very good with it.

I did however get it to work using this JavaScript, but I had to change it to use Google and I am not sure how to get it run both Marco's one after the other?

(() => {

   document.getElementsByName('button')[0].click();

})();

Only way I can get it to work is if I have the website open and it is in Google, and I have to right click each Macro and click "Try It". I am sure there is a way to have this tool launch the website, but I am not too sure how to out this together.

What do you mean you had to change it to use Google?

Good job!

That's not the optimal method, but if it works it's good enough for now.

The problem with it is that this method gathers all elements whose name is 'button' into an array and then presents the very first one (element [0]). This is undesirably fragile.

I think this will work, but it's hard to tell for certain without testing.

(() => {

   document.querySelector('div.btn.btn-primary.pull-right.text-uppercase').click()

})();

What does this mean? "In Google"...

Do you mean the Google Chrome web browser?

You can't right-click macros and select try-it – do you mean the JavaScript actions in the macro?

Yes there are a number of such actions:

I gather you're working in Google Chrome – yes?

You need a Google Chrome specific macro group if you don't have one.

You also need to familiarize yourself with the hotkey trigger if you haven't arleady.

For your macro you need to:

  • Open the requisite URL.
     
  • Pause until the log-in dialog is available.
    • Fill out and submit the log-in dialog.
       
  • Pause until the NEXT dialog is available.
    • Select the NEXT button.

This is a fairly complicated process, and there is more than one way to accomplish it.

The most organic if not the easiest is to use JavaScript.

You already have working code for the dialogs, but you need to be able to wait until the requisite elements are available before trying to act on them.

Here's a method for doing that:

1 Like

I had to switch the setting "Google Chrome" in order for the Actions to work, but I can't get it to all run in order. I have just now tried this method of adding "Open URL" which works with Opera, Chrome and Safari, however it stops there and doesn't auto populate the info I have set for my Values, but if I right click and say "Try Action" it will fill it out, but hen I get stuck on the second popup and it clicking the "Next button". I tried adding you script above in a separate action, not sure if that is correct or not?

Hey Mark,

When posting macros to the Keyboard Maestro forum please use these guidelines:

  1. Always Post a Macro File.

    • Post the simplest possible macro that illustrates the problem you're having.
    • Macros often contain tricky little bits that are likely to be missed in a written explanation.
    • Providing a real and testable example is a courtesy, and if people don't have to reinvent the wheel to test your macro it significantly improves the odds that someone will help you.
  2. Always Post a Macro Image.

    • Folks generally won't download something they haven't eyeballed first, so an image of the macro is crucial.

If you haven't seen these they're worth a moment of your time:


Take Care,
Chris

(Keyboard Maestro Moderator)

Exactly what setting "Google Chrome" ????

You may know what you mean, but you haven't communicated it so others can understand what you mean...

That's not shocking – I explained that exact problem in my previous post.

To repeat ⇢ That's not shocking – I explained that exact problem in my previous post.

You have to wait for the requisite element to be available before trying to act on it...

And I provided a link to a macro that shows exactly how to wait until the requisite element IS available.

You could play with pauses and achieve the same result – albeit not nearly as efficiently as using JavaScript to wait for the correct element.

You could also use Pause Until to wait for an image, which would be a bit more specific.

Keep in mind that you're trying to run before you can walk – as nearly everyone who starts using Keyboard Maestro does – myself included.

  • You need to learn the software.
     
  • Break your tasks up into pieces that work, and then tie them together.
     
  • In the programming world things don't "just work" – you have to make them work by conforming to the necessary criteria.
    • It takes time to learn what those criterial are.
       
  • The better you communicate your problems on the forum the sooner you're likely to get worthwhile help.
    • Lack of adequate detail doesn't help.
    • Lack of adequate test macros doesn't help.
    • People generally need to actually see and test your work to provide good guidance.
       
  • Keep in mind that everyone's time is valuable – and that you can save everyone time and aggravation by providing adequate information and example macros.