UIClick not working

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
ibatey
Newbie
Posts: 10
Joined: Thu Dec 17, 2015 9:24 pm

UIClick not working

Post by ibatey » Tue Jun 19, 2018 5:19 pm

Hi
Apologies if this is an obvious one.

I am automating a transaction in Sage Accounts. First step is to click on a menu item to bring up the relevant sub-menu. I identified the relevant element using the Findobject wizard and set it to click the element. It inserted the code:

Code: Select all

SetFocus>Sage 50 Accounts Essentials - Practice Company
UIClick>{"Sage 50 Accounts Essentials - Practice Company"},{"Products and services"}
However, this does not work.

If I do a similar thing differently, then it works:

Code: Select all

GetWindowHandle>Sage 50 Accounts Essentials - Practice Company,hWndParent
FindObject>hWndParent,AfxWnd120,,12,hWnd,X1,Y1,X2,Y2,result
Let>WIN_USEHANDLE=1
let>x={Int(%X1%-(%X1%-%X2%)/2)}
let>y={Int(%Y1%-(%Y1%-%Y2%)/2)}
MouseMove>x,y
LClick
Any idea what I could do to make the first code work as it's simpler and i suspect less prone to problems as you are not fiddling with mouse moves.

PS, as it's a menu item, I can also use keyboard shortcuts i know, but I'm trying to understand what the problem is because i'll need to resolve it later in the macro.

Code: Select all

SetFocus>Sage 50 Accounts Essentials - Practice Company
CapsOff
Press ALT
Send>07
Release ALT

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: UIClick not working

Post by Marcus Tettmar » Mon Jun 25, 2018 1:53 pm

I'm afraid this is one of those cases of try it and see, and I am unable to provide explanations for why one method works and one doesn't. UIClick won't always work and it all depends on the target app. Your second method uses a different API, and works because the object is a windowed object and has a handle which you can then post a mouse click event to. UIClick uses a completely different API - it uses the Accessibility Interface. We are automating apps as if they are a black box with no understanding of the internals as we didn't build them. So we just have to try things and see what works.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

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