Jump to content
Docfxit

Selecting with a mouse

Recommended Posts

Docfxit

I am trying to select a file in a window and then delete it.

It works some of the time and then it stops working.

When I start the script it works.  A  minute goes by and it stops working.

MouseSelect.jpg

The script starts by selecting the first file at MouseMove(91,338)  then it deletes the file by selecting the X at MouseMove(128,291).

The next file should be highlighted automatically.

When it gets to the end of the script and starts over is where it doesn't select the first file in the list at MouseMove(91,338)

I wanted to add a wait but I can't get AutoIt Window Info to show me how to select the first file in the list.  Window Info only selects the entire box starting with Name and including all files in that box.

Opt("WinWaitDelay",100)
Opt("WinTitleMatchMode",4)
Opt("WinDetectHiddenText",1)
Opt("MouseCoordMode",0)
AutoItSetOption("TrayIconDebug", 1) ;0-off
; Set so that tray displays current line number
HotKeySet("{ESC}", "_Exit") ;If you press ESC the script will stop
While 1 = 1
WinWait("Find","Search &subdirectori")
If Not WinActive("Find","Search &subdirectori") Then WinActivate("Find","Search &subdirectori")
WinWaitActive("Find","Search &subdirectori")
MouseMove(91,338)
Sleep(1000)
MouseUp("left")
sleep(100)
MouseMove(128,291)
sleep(100)
MouseDown("left")
MouseUp("left")
sleep(100)
MouseDown("left")
MouseUp("left")
sleep(100)
MouseDown("left")
MouseUp("left")
sleep(100)
MouseDown("left")
MouseUp("left")
sleep(100)
MouseDown("left")
MouseUp("left")
sleep(100)
MouseDown("left")
MouseUp("left")
sleep(100)
MouseDown("left")
MouseUp("left")
sleep(100)
MouseDown("left")
MouseUp("left")
sleep(100)
MouseDown("left")
MouseUp("left")
sleep(100)
MouseDown("left")
MouseUp("left")
sleep(100)
MouseDown("left")
MouseUp("left")
sleep(100)
MouseDown("left")
MouseUp("left")
sleep(100)
MouseDown("left")
MouseUp("left")
sleep(100)
MouseDown("left")
MouseUp("left")
sleep(100)
MouseDown("left")
MouseUp("left")
sleep(100)
MouseDown("left")
MouseUp("left")
sleep(100)
MouseDown("left")
MouseUp("left")
sleep(100)
MouseDown("left")
MouseUp("left")
sleep(100)
MouseDown("left")
MouseUp("left")
sleep(100)
MouseDown("left")
MouseUp("left")
Sleep(2000)
WEnd

Func _Exit()
Sleep(100)
Exit
EndFunc ;==> _Exit()

Is there a more reliable way to select the first file?

Thanks,

Docfxit

Share this post


Link to post
Share on other sites
Danyfirex

Hello.  If It is a Common Windows Control you propably could use ControlListView function.

 

Saludos

Share this post


Link to post
Share on other sites
Docfxit

Hi Danyfirex

Maybe I'm not doing this correctly.

This is what is in the box:

FindList.jpg

This is what the info window shows:

InfoWindow.jpg

This is the code I am using:

ControlListView("Find", "", "SysListView321", "SelectAll")
ControlListView("Find", "", "SysListView321", "Deselect", 2, 5)
MsgBox($MB_SYSTEMMODAL, "", ControlListView("Find", "", "SysListView321", "GetText", 9, 0))
MsgBox($MB_SYSTEMMODAL, "", ControlListView("Find", "", "SysListView321", "FindItem", "14 KB", 1))
MsgBox($MB_SYSTEMMODAL, "", ControlListView("Find", "", "SysListView321", "GetSelected", 1))

This is the first message box that comes up:

Message1.jpg

This is the second message box that comes up:

Message2.jpg

This is part of the third message box that comes up:

Message3.jpg

I don't see how to get any of it to be helpful.

 

Thanks,

Docfxit

Share this post


Link to post
Share on other sites
Danyfirex

Basically you need to find your item. then select it.

Maybe something like this.

Local $iIndex=ControlListView("Find", "", "SysListView321" ,"FindItem","StringToFind")
ControlListView("Find", "", "SysListView321" ,"Select",$iIndex)

Then you could click the delete button. check if it is a clickable button/toolbar using the AutoIt window Info tool.

 

Saludos

 

Share this post


Link to post
Share on other sites
Docfxit

After using your example, Instead of it selecting one file at a time, it selected all files in the list.

Instead of me having to delete one file at a time I am able to delete all files in one selection.

This means that it can delete 10,000 with one click on the delete key.

This is a really great solution.

This is the code I ended up with:

Opt("WinWaitDelay",100)
Opt("WinTitleMatchMode",4)
Opt("WinDetectHiddenText",1)
Opt("MouseCoordMode",0)
AutoItSetOption("TrayIconDebug", 1) ;0-off
; Set so that tray displays current line number

Local $iIndex=ControlListView("Find", "", "SysListView321" ,"FindItem","StringToFind")
ControlListView("Find", "", "SysListView321" ,"Select",$iIndex)

WinWait("Find","Search &subdirectori")
If Not WinActive("Find","Search &subdirectori") Then WinActivate("Find","Search &subdirectori")
WinWaitActive("Find","Search &subdirectori")
MouseMove(128,291)
sleep(1000)
MouseDown("left")
MouseUp("left")

Thank you very much,

Docfxit

Share this post


Link to post
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

×