Jump to content

ControlClick function not working on Calculator


inna
 Share

Recommended Posts

Hi, this is my code:

Run('calc')
Local $hWnd = WinWaitActive("[Class:CalcFrame]", '', 3) ; I also tried WinWaitActive("[Class:Calculator]", '', 3)

Local $xOne = 1215 ; x position of number one button
Local $yOne = 526 ; y position of number one button
Local $xPlus =1332 ; x position of addition button
Local $yPlus =560 ; y position of addition button
Local $xTwo = 1257; x position of number one button
Local $yTwo = 524 ; y position of number one button

Local $i = 1
While $i <= 5
        ControlClick('[CLASS:Button; INSTANCE:1]', '', '', 'left', 1, $xOne, $yOne) ; also tried [CLASS:CalcFrame] and [CLASS:Calculator] and $hWnd
        $i = $i + 1
        ControlClick('[Class:Button; INSTANCE:1]', '', '', 'left', 1, $xPlus, $yPlus) ; also tried [CLASS:CalcFrame] and [CLASS:Calculator] and $hWnd
        sleep(100)
WEnd
ControlClick('[Class:Button; INSTANCE:1]', '', '', 'left', 1, $xTwo, $yTwo) ; also tried [CLASS:CalcFrame] and [CLASS:Calculator] and $hWnd

But it only opens the calculator, but it does not click or hit anywhere or any button.

But if I use MouseMove() or MouseClick(), they work fine.

I tested on both Windows Server 2022 and Windows 10 my laptop.

I found the class names using Autoit Window Info.

Did I miss anything or do anything wrong?

Link to comment
Share on other sites

12 hours ago, Jfish said:

I believe they changed calculator in Win 10.  I think you need to use UIAutomation now: 

 

 

My main goal is to automate a 3rd party application (not Microsoft apps), but I'm trying it with Calculator because it has Button to click on.

I'm trying ...

Edited by inna
Link to comment
Share on other sites

8 minutes ago, inna said:

My main goal is to automate a 3rd party application (not Microsoft apps), but I'm trying it with Calculator because it has Button to click on.

I'm trying ...

I did not understand that:( I get error that the required module is not in the downloaded file.

I'm not sure, but I think if I know how to find the class and titles well, my problem will be solved.

I tried using both Windows's inspect.exe and Autoit Window Info and copied the class names and title from there, but it does not work.

Link to comment
Share on other sites

Calculator's buttons can't be identified in that manner any longer because they moved to WPF in Windows 10. So you need to understand the applications that you are trying to automate and which technology can be used to identify the controls to interact with them.  In the example of Calculator - UIAutomation should work. It should also work on other applications.  

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...