Mouse clicking start button not working, solution: run macro as admin

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
Josku
Newbie
Posts: 4
Joined: Fri Mar 04, 2022 1:28 pm

Mouse clicking start button not working, solution: run macro as admin

Post by Josku » Fri Mar 04, 2022 1:53 pm

Hi,

I am trying to make a simple code with starts a separate measurement software by clicking the start button and closing it after certain period of time by clicking stop button. The SW has UI, where I as a user normally have to press the buttons. I noticed that for some reason I can´t start the program using the macro scheduler Lclick. I can find the start button location using for example FindImagePos or even MouseMove to a specific pixel but then the program wont open with Lclick. When I try to run a single line of code with debug step (F8 button) the code works as it should be. Meaning, it will first locate the start button and then runs the Lclick all fine.

I noticed that when macro tries to LClick the software start button, the focus stays gray. Like it would not be active. I tried setting focus which makes the correct software active, but then the mouse does not move to correct place. So if I run:

SetFocus>
FindImagePos>
MouseMove>XArr_0,YArr_0
LClick

I get focus to the right screen, but the mouse won´t move.

If I run:

FindImagePos>
MouseMove>XArr_0,YArr_0
LClick
Mouse moves to the correct position, but the screen is not even focused after clicking

Before ripping all of my hairs with this, I have few questions:

Does the Lclick I make from mouse and Lclick from Macro scheduler differ somehow? Can commercial program tell those apart and ignore the macro Lclick?

Why does the Lclick I perform with debug step differ from running the whole code (even if the code would have exactly same lines, nothing more nothing less in it)?

Thanks in advance
Last edited by Josku on Thu Mar 10, 2022 1:57 pm, edited 1 time in total.

User avatar
JRL
Automation Wizard
Posts: 3497
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: Mouse clicking start button not working, works with debug step

Post by JRL » Fri Mar 04, 2022 2:53 pm

Why does the Lclick I perform with debug step differ from running the whole code (even if the code would have exactly same lines, nothing more nothing less in it)?
Timing.
My guess is the you're automated software doesn't have enough time to recognize that the mouse has arrived before you make the click. Try placing a wait between the move and the click. Make the wait a couple seconds to start with then, if that helps, experiment with making the wait shorter.

FindImagePos>
MouseMove>XArr_0,YArr_0
Wait>2
LClick

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1348
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Mouse clicking start button not working, works with debug step

Post by Dorian (MJT support) » Fri Mar 04, 2022 3:12 pm

As JRL mentions, timing is often the culprit if something works in the debugger but not in real-time.

If you're trying to click on an object within a program, also try the Find Object Wizard. You may find this a more reliable way of clicking Start/Stop if the object is visible to Macro Scheduler. Image Recognition is a perfect substitute for when those methods are not an option.
Yes, we have a Custom Scripting Service. Message me or go here

Josku
Newbie
Posts: 4
Joined: Fri Mar 04, 2022 1:28 pm

Re: Mouse clicking start button not working, works with debug step

Post by Josku » Mon Mar 07, 2022 10:14 am

Hi JRL and Dorian,

Thanks for the comments, I had 0.5 sec wait times included, I tried increasing it up to 5 seconds and still it did not work.

I tried that Find object function, what I learned is that the button I am trying to press doesn't have a unique UIAutomation Name. For example, Calculator buttons 7 or % have names "UIAutomation Name: Seven" and "UIAutomation Name: Percent". Even though there are multiple buttons in the target program, all of them have the same name. I think this means that those buttons are not available for some reason.

I tried to compile an .exe file and installed macro scheduler trial to a different PC to test it but still no luck.

I noticed a mistake I did, when I tried to use debug I kept pressing the debug button with mouse. When I press
MouseMove>XArr_0,YArr_0, mouse would move to the start button and then I pressed that button myself, instead of debug running the Lclick command. This means that it simply doesn´t run even unless I click the UI start button.

User avatar
JRL
Automation Wizard
Posts: 3497
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: Mouse clicking start button not working, works with debug step

Post by JRL » Mon Mar 07, 2022 1:54 pm

Can you use the tab key in the application to manually move from button to button? If you land on the button after pressing tab does pressing "Enter" then actuate the button? If these answers are yes, then perhaps a script using keyboard functions might work.

SetFocus>WindowName
Press Tab /* Specified number of times
Wait>1
Press Enter

Josku
Newbie
Posts: 4
Joined: Fri Mar 04, 2022 1:28 pm

Re: Mouse clicking start button not working, works with debug step

Post by Josku » Tue Mar 08, 2022 7:23 am

I tried now, tab didn´t work.

Could this be poor UI design or clever way to stop people from using macro as it feels impossible to interract with the UI without actually using mouse?

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1348
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Mouse clicking start button not working, works with debug step

Post by Dorian (MJT support) » Tue Mar 08, 2022 11:29 am

Aaaah, is the application running as admin?

If so, Macro Scheduler needs to run as admin too. Controlling apps that run as admin
Yes, we have a Custom Scripting Service. Message me or go here

Josku
Newbie
Posts: 4
Joined: Fri Mar 04, 2022 1:28 pm

Re: Mouse clicking start button not working, works with debug step

Post by Josku » Thu Mar 10, 2022 1:56 pm

That fixed the problem! I was able to click the start button when I run the macro as an admin. Thanks a lot for the help, I had already given up on the hope! :D

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1348
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Mouse clicking start button not working, solution: run macro as admin

Post by Dorian (MJT support) » Thu Mar 10, 2022 2:15 pm

You're very welcome.
Yes, we have a Custom Scripting Service. Message me or go here

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts