Jump to content

Controlclick newbie question


Recommended Posts

I've been using autoit for a bit and know the very basics, however, I now need to do a mouse click on relative co-ordinates. I cannot seem to get the syntax right - can someone point out where I am going wrong?

ControlClick("DISK Protect Management Tool","","[iD:1015]",34,31) for:

Title: DISK Protect Management Tool

Class: #32770

Position: 283, 75

Size: 457, 467

Style: 0x94CA20CC

ExStyle: 0x00010101

>>>> Control <<<<

Class: SysListView32

Instance: 1

ClassnameNN: SysListView321

ID: 1015

Text:

Position: 45, 132

Size: 159, 148

ControlClick Coords: 34, 31

Style: 0x5001880D

ExStyle: 0x00000204

Link to comment
Share on other sites

Try this:

ControlClick("DISK Protect Management Tool","","[CLASSNN:SysListView321]")

-edit-

Coordinates not needed.

I need the co-ordinates to be included as by clicking on the control ID does not highlight the first option in the list - I tried the above with co-ordinates but no joy - any other ideas???

Link to comment
Share on other sites

I don't know.. I suppose you could do this:

ControlGetPos("DISK Protect Management Tool","","[CLASSNN:SysListView321]")

and then perform an actual click using MouseClick() with the coordinates returned by the previous code.

If you want to select an item in an explorer window listview, I suppose you could try something like this too:

$path = @ScriptDir
ShellExecute("explorer.exe", "/n,/select," & $path)

$path is the folder you want to select.

Link to comment
Share on other sites

I don't know.. I suppose you could do this:

ControlGetPos("DISK Protect Management Tool","","[CLASSNN:SysListView321]")

and then perform an actual click using MouseClick() with the coordinates returned by the previous code.

If you want to select an item in an explorer window listview, I suppose you could try something like this too:

$path = @ScriptDir
ShellExecute("explorer.exe", "/n,/select," & $path)

$path is the folder you want to select.

Thank you for making the effort to reply. If I just use mouse click with the actual co-ordinates it works, but with controlclick coords it doesn't. I want to make sure it works under all resolutions and wondering how getpos or getfocus helps?
Link to comment
Share on other sites

Would you mind telling us what you are trying to do? It seems to me that all you want to do is set focus to a listview control in an explorer window by clicking on it.

Then ControlFocus() should do the job.

ControlGetPos() returns the position and size of a given control. Look at this example:

Opt("MouseCoordMode",2)
HotKeySet("a","_Click")
HotKeySet("{esc}","_Quit")
Run("notepad")
WinWaitActive("[CLASS:Notepad]")

While 1
    Sleep(100)
WEnd
    
Func _Click()
    $Pos=ControlGetPos("[CLASS:Notepad]","","[CLASSNN:Edit1]")
    MouseClick("right",$Pos[0]+$Pos[2]/2,$Pos[1]+$Pos[3]/2)
EndFunc

Func _Quit()
    Exit
EndFunc

When you press "a" it will always right click in the middle of the edit control, no matter the size or position of the window.

Press ESC to exit.

Edited by Nahuel
Link to comment
Share on other sites

Hello mattyskinner,

I'm going to make an assumption here that you're desired effect is the selection of the first item in a SysListView32 control that appears in a popup dialog belonging to the "DISK" tool, correct? If mouse clicking isn't necessary, then perhaps the following could be an option:

$title = "DISK Protect Management Tool"
$listView = "[ID:1035]"

; Activate PopUp and focus on the desired control
WinActivate( $title )
ControlFocus( $title, "", $listView )

; Deselect all items first...
$numItems = ControlListView( $title, "", $listView , "GetItemCount" )
ControlListView( $title, "", $listView , "DeSelect", 0, $numItems )

; ...then select the first item ( 0 - based ) by sending "ENTER"
ControlListView( $title, "", $listView , "Select", 0 )
ControlSend( $title, "", $listView , "{ENTER}" )

If not, I agree with Nahuel: sharing your attempts thus far would help us see what your desired outcome is.

Zach...

Edited by zfisherdrums
Link to comment
Share on other sites

Hello mattyskinner,

I'm going to make an assumption here that you're desired effect is the selection of the first item in a SysListView32 control that appears in a popup dialog belonging to the "DISK" tool, correct? If mouse clicking isn't necessary, then perhaps the following could be an option:

$title = "DISK Protect Management Tool"
$listView = "[ID:1035]"

; Activate PopUp and focus on the desired control
WinActivate( $title )
ControlFocus( $title, "", $listView )

; Deselect all items first...
$numItems = ControlListView( $title, "", $listView , "GetItemCount" )
ControlListView( $title, "", $listView , "DeSelect", 0, $numItems )

; ...then select the first item ( 0 - based ) by sending "ENTER"
ControlListView( $title, "", $listView , "Select", 0 )
ControlSend( $title, "", $listView , "{ENTER}" )

If not, I agree with Nahuel: sharing your attempts thus far would help us see what your desired outcome is.

Zach...

Sorry if I haven't given you much to work on. My script runs a windows application, which shows a gui and then makes the window active. Unfortunately the control I want to interact with cannot be accessed by tabbing or any other method. It is a list of user names, but the text of the user names are not seen by autoit. The only way for me to highlight the name is by mouse clicking on it. I would've therefore assumed as the control is recognised and i've got controlclick coords I could use that to select the first user in the list. I am concerned about screen resolutions so I'd like the coords to be relative. Is there an easier way to do this?

Do I need to do Control focus or getpos first??

Edited by mattyskinner
Link to comment
Share on other sites

  • 3 weeks later...

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