Jump to content

How i can move the mouse to place by controlclick cords?


Guest
 Share

Recommended Posts

How i can move the mouse to place by controlclick cords?

For example look at that this code:

ControlClick ("", "", "ui23Drawn_W327", "", "", 766, 27)

This code refers to a specific location but it did not bring the mouse to this location.

How to do mouse Moves to this position (with Function ControlClick And not with Function MouseMove)

The Function MouseMove Always move the mouse to the same place which is not good.

Thanks!

Edited by Guest
Link to comment
Share on other sites

I know but I could not get the title of the window but it does not matter because it works just not move the mouse it's just clicking in the specific location but not move the mouse to this position.

Link to comment
Share on other sites

So, use MouseClick.

But it moves the mouse to a fixed location and that's not good when I move the window or changing resolution
Link to comment
Share on other sites

But it moves the mouse to a fixed location and that's not good when I move the window or changing resolution

If you don't know his title or handle you can't use controlclick if not active.

Mouseclick with Opt ( "MouseCoordMode", 0 ) ; relative coords to the active window.

or

ControlClick ("[active]", "", "ui23Drawn_W327", "", "", 766, 27)

AutoI window Info Tools Return nothing ?

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

If you don't know his title or handle you can't use controlclick.

Mouseclick with Opt ( "MouseCoordMode", 0 ) ; relative coords to the active window.

Can you give me a small example of that?

Thanks

Link to comment
Share on other sites

No matter.

Before you edit I tried to write something myself and it work out so I figured how to do it alone.

That's what I tried:

Opt ( "MouseCoordMode", 0 )
WinActivate("[CLASS:Notepad]", "")
MouseMove(588, 283, 1)

It works!

Helped me a lot!

I can get the inner window so no problem.

Thank you very much!

Edited by Guest
Link to comment
Share on other sites

  • 2 weeks later...

This would be more helpful if we knew what window you are working with.

Apparently it did not work on the window I'm working with him.

I did regular testing but not on that window ...

This is the window:

*

The script can not read properly that window ..

I do not know what to do ..

Help me!

Thanks

Edited by Guest
Link to comment
Share on other sites

I got a demostration script about some controlcommands... look

#include <winapi.au3>
If not winexists("[Class:CalcFrame]") then ShellExecute("calc")             ; if calc doesn`t exists, it run it.
Winwait("[Class:CalcFrame]")                                                ; waits until calc exists.
$hndl = WinActivate("[Class:CalcFrame]")                                    ; Active calc, and save the window handle in a variable.
$pos = Controlgetpos("[Class:CalcFrame]","","[CLASS:Button; INSTANCE:5]")   ; Get the position of the button "1".
Msgbox(0,"Position of the button","Position of the control inside the clien area"&@CRLF _
                                    &"The X coord of the control inside the client area is "&$pos[0]&@CRLF _
                                    &"The Y coord of the control inside the client area is "&$pos[1]&@CRLF _
                                    &"The width of the control is "&$pos[2]&@CRLF _
                                    &"The height of the control is "&$pos[3]&@CRLF)
; -----------Preparating the Structure for the function call to get the absolute coords of the control -----------
$tPoint = DllStructCreate($tagPoint)    ; The Struct tagPoint is alreade declared, it has two elements "x" and "y"
DllStructsetdata($tPoint, "x",$pos[0])  ; I put in the element X of the structure the X pos of the control
DllStructsetdata($tPoint, "y",$pos[1])  ; I put in the element Y of the structure the X pos of the control
_WinAPI_ClientToScreen($hndl,$tPoint)

;~ Msgbox(0,"Position of the button","Absolute position of the control"&@CRLF _
;~                                  &"The X coord of the control is "&DllStructgetdata($tPoint, "x")&@CRLF _
;~                                  &"The Y coord of the control is "&DllStructgetdata($tPoint, "y")&@CRLF)

;IF YOU WANT TO SAVE THE DATA INTO VARIABLES YOU SHOULD DO THIS.
$x = DllStructgetdata($tPoint, "x")
$y = DllStructgetdata($tPoint, "y")
$tPoint = 0 ; free the struct.

Msgbox(0,"Position of the button","Absolute position of the control"&@CRLF _
                                    &"The X coord of the control is "&$x&@CRLF _
                                    &"The Y coord of the control is "&$y&@CRLF)
mousemove($x, $y, 15)
sleep(500)
mousemove($x + $pos[2], $y + $pos[3], 15)
sleep(500)
MsgBox(0,"ControlSend","You can send the keys input directly to a control")
ControlSend("[Class:CalcFrame]","","[CLASS:#32770; INSTANCE:1]","123456789")
sleep(1000)
ControlClick("[Class:CalcFrame]","","[CLASS:Button; INSTANCE:13]")
sleep(1000)
For $i = 1 to 9
ControlSend("[Class:CalcFrame]","","[CLASS:#32770; INSTANCE:1]",$i)
sleep(500)
Next
sleep(500)
ControlClick("[Class:CalcFrame]","","[CLASS:Button; INSTANCE:13]")
sleep(500)
MsgBox(0,"Non active window try","Now we gonna try to do this but with the window minimized")
sleep(500)
winsetstate("[Class:CalcFrame]","",@SW_MINIMIZE)
sleep(500)
For $i = 9 to 1 step -1
ControlSend("[Class:CalcFrame]","","[CLASS:#32770; INSTANCE:1]",$i)
sleep(500)
Next
Msgbox(0,"It is the end","This is the end of the demostration, good look")
Link to comment
Share on other sites

  • 2 weeks later...

I can't edit my previous post, whatever...

Hello, this topic was very usefull to get replace a couple of mouseclicks with controlclicks. Controlclick is better for a specific location. Butt still some trouble occurs:

Posted Image

I want to get the focus in the field wich is red. With the window info programm i get a classname etc, but when I run the script i can't get the focus in the specific field. I only get focus in the total grid where the field is in. I can use controlclick coordinates again but that doesn't work because the columns can be rearranged by drag and drop. The lay out is variable.

Is it possible to get the focus in the particular field?

Field info:

>>>> Window <<<<

Title: Onderhoud inkoop - Inkoopnummer: 4, Relatie: Gregal S. coop

Class: LpVoForm

Position: -8, 7

Size: 1616, 886

Style: 0x96CF0000

ExStyle: 0x00000100

Handle: 0x0000000000010A36

>>>> Control <<<<

Class: LpVoEditControl

Instance: 3

ClassnameNN: LpVoEditControl3

Name:

Advanced (Class): [CLASS:LpVoEditControl; INSTANCE:3]

ID:

Text:

Position: 607, 360

Size: 99, 18

ControlClick Coords: 56, 8

Style: 0x56800000

ExStyle: 0x00000000

Handle: 0x0000000000010D88

>>>> Mouse <<<<

Position: 663, 423

Cursor ID: 0

Color: 0x000000

>>>> StatusBar <<<<

>>>> ToolsBar <<<<

Link to comment
Share on other sites

I solved the problem.

I did an idea that came to mind.

And it works ..

So it looks something like this:

ControlClick ( "", "", "ui23Drawn_W327", "left", 1, 800, 13)
$pos = Controlgetpos("","","")
MouseClick("left", $pos[0] - 88, $pos[1] + 51, 2, 1)

It works great

:mellow: If that work to you, then fine... i never use ControlClick that way.... This left me with a doubt about what Window he want to automate.

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...