Jump to content

ControlClick Dosn't Work :)


Recommended Posts

Hello, I'm back, i want to improve my AutoIT Skill, so i decited to create simple APP.

I decided to work with my calc.exe , so.

There is small example what i wanted to take.

1. ControlSend 2

2. ControlSend +

3. ControlSend 2

4. ControlClick =

Bold Works, None Nope.

Why ControlClick? thats why i want use a Mouse Click to improve my Control Skill :D , just Control Send would be so easy to me, I'm always looking for hardest way so.

There's my script:

Opt('WinTitleMatchMode','2')
$Title = 'Kalkulator'
$process = WinGetHandle(WinGetTitle($Title))
ControlSend($process,'','',"{2}")
ControlSend($process,'','',"{+}")
ControlSend($process,'','',"{2}")
ControlClick($process,'','',"left",1,200,250)

Working fine 1,2,3 but it can't click the button = via mouse left click.

x= 200 and y = 250 are possitions i taken from _WinApp_ GetMouse Possitions so I'm sure it's corretly, you can also check in this picture, i also made small red point where should be mouse click.

2ErhNlT.png

It was placed on top left corner and was minimized.

Edited by Potar
Link to comment
Share on other sites

Have you tried it with Control ID for the third ControlClick parameter?

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

Normally you can't get away with leaving certain parameters, like Control ID, out of the command, but it appears you have been able to do this with ControlSend. If you use the correct ID, you won't need the Mouse positioning.

Like as has been suggested above, fire up the Window Info Tool and have a play with it, until you understand how it works. Pay particular attention to the Controls tab, the active window of Calculator, and the mouse hover position.

Unfortunately, I cannot check your code, as I don't have an installation of AutoIt on this machine, only the Help file.

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

Okay, i did it, works with calc  :)

But now i want to do it via X,Y of mouse for another one, for example i did program in c++ and now the Window Info Tool cant find my created button (like in calc INSTANCE / BUTTON etc.) :)

So thaths why i want to use x,y.

Edited by Potar
Link to comment
Share on other sites

EDIT - Typed this while you guys were already talking.  Ah well.  ;)

 

If you just want to send stuff to calculator, use this (it's fine to send all keystrokes together):

Opt('WinTitleMatchMode','2')
$Title = 'Calculator'
$process = WinGetHandle(WinGetTitle($Title))
ControlSend($process,'','',"2{+}2{ENTER}")

If you want to target specific buttons, use this:

Opt('WinTitleMatchMode','2')
$Title = 'Calculator'
$process = WinGetHandle(WinGetTitle($Title))
ControlClick($process,'','[CLASS:Button; INSTANCE:11]')
ControlClick($process,'','[CLASS:Button; INSTANCE:23]')
ControlClick($process,'','[CLASS:Button; INSTANCE:11]')
ControlClick($process,'','[CLASS:Button; INSTANCE:28]')

I got the "[CLASS:Button; INSTANCE:11]" information by using AutoIt Window Info, like I suggested before.  Check your Start menu - you likely have it in your AutoIt folder.  When the program is running, go to the Control tab.  Then drag the Finder Tool over the control you want to know about - like the Equals button on the calculator.  The Advanced Mode part is what you need to identify the control.  You can also go to the Summary tab (scroll all the way right) and copy the information directly.  The Finder Tool will tell you about each control you want to use.

Note that you won't actually see the mouse move - the application is internally told that those controls were clicked.

Edited by Artisan
Link to comment
Share on other sites

Okay, try this (careful - these co-ords worked for me, but my calculator is likely in a different position than yours):

Opt('WinTitleMatchMode','2')
$Title = 'Calculator'
WinActivate($Title)
MouseClick("primary", 361, 499)
MouseClick("primary", 438, 526)
MouseClick("primary", 361, 499)
MouseClick("primary", 475, 512)

Use the Mouse tab in AutoIt Window Info to know what x/y co-ordinates to use.
 
You can use WinMove if you need to position the window.  You can also use Opt('MouseCoordMode','2') if you want to use co-ordinates relative to the client area of the window (so it doesn't matter where the window is, but the co-ords take a little more work to figure out).

Edited by Artisan
Link to comment
Share on other sites

It is working fine but i won't use MouseClick, i want to do the calculation in minimized calc :)

Only using X and Y and click to = button.

Edited by Potar
Link to comment
Share on other sites

Read my post:

 

But now i want to do it via X,Y of mouse for another one, for example i did program in c++ and now the Window Info Tool cant find my created button (like in calc INSTANCE / BUTTON etc., there aren't any controls just mouse possition and color :)

So thaths why i want to use x,y.

Link to comment
Share on other sites

If it's a program you made, there's nothing stopping you from modifying it.  But I'll assume you don't want to do that.  You need to know that your x/y co-ords are correct.  Try something like this:

HotKeySet("{ESC}", "Quit")
AutoItSetOption("MouseCoordMode", "2")

$x = 0
$y = 0

While 1
    If $x <> MouseGetPos(0) Or $y <> MouseGetPos(1) Then
        $x = MouseGetPos(0)
        $y = MouseGetPos(1)
        ToolTip($x & ", " & $y)
    EndIf
    Sleep(100)
WEnd

Func Quit()
    Exit
EndFunc
Link to comment
Share on other sites

It is working fine but i won't use MouseClick, i want to do the calculation in minimized calc :)

Only using X and Y and click to = button.

Now you have me suspicious of you, if I wasn't a little before.

If you have Calculator minimized, then you really don't need it all, as you can do all the maths with AutoIt code.

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

Yeah maybe thats why its called controlclick, if there isnt any control then it cant click it.

There is another way to click smth via mouse click to minimized window?

 

@up

It was just an example.

Edited by Potar
Link to comment
Share on other sites

Oh seriously, you do not know how to do it so you are telling something about rules?

you are just so weak to help me with that i already did it with winapi postmessage so have fun unskilled guys ^_^

THAT WASNT ANY TYPE OF BOT ETC WHAT YOU WANT TO SAY SO CYA

Edited by Potar
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...