NickBtheITguy Posted July 8, 2009 Share Posted July 8, 2009 (edited) I have a script that goes through and basically selects every entry on the screen so they can be deleted. They are in list format and I pass a Down and a Space key press. This works. But what I am running into is that I am not able to break the loop when I reach the end of the list. I have posted a screenshot of the bottom of the application and the code I have so far on the script. It gets to that last entry and then just continues to select and deselect the last entry. The control ID is 7009 in the code.; This is the loop that goes through and selects all of the entries. If Not ControlFocus("Engagement Plus", "", 7009) Then ExitLoop Else while ControlFocus("Engagement Plus", "", 7009) Send("{SPACE}") Send("{DOWN}") wend Endif Send("{ALT}F") Send("D") WinWaitActive("Delete Confirmation") Send("{Enter}") Edited July 8, 2009 by NickBtheITguy Link to comment Share on other sites More sharing options...
llewxam Posted July 8, 2009 Share Posted July 8, 2009 I have a script that goes through and basically selects every entry on the screen so they can be deleted. They are in list format and I pass a Down and a Space key press. This works. But what I am running into is that I am not able to break the loop when I reach the end of the list. I have posted a screenshot of the bottom of the application and the code I have so far on the script. It gets to that last entry and then just continues to select and deselect the last entry. The control ID is 7009 in the code. ; This is the loop that goes through and selects all of the entries. If Not ControlFocus("Engagement Plus", "", 7009) Then ExitLoop Else while ControlFocus("Engagement Plus", "", 7009) Send("{SPACE}") Send("{DOWN}") wend Endif Send("{ALT}F") Send("D") WinWaitActive("Delete Confirmation") Send("{Enter}") The ExitLoop has to be within a "Do...Until", an "If...EndIf" isn't valid. I made a very slight change: Do If Not ControlFocus("Engagement Plus", "", 7009) Then ExitLoop Else while ControlFocus("Engagement Plus", "", 7009) Send("{SPACE}") Send("{DOWN}") wend Endif Until 1=2 Send("{ALT}F") Send("D") WinWaitActive("Delete Confirmation") Send("{Enter}") That no longer fails with a CTRL-F5 (syntax check). Not sure if that will fix everything, but check it out. Ian My projects: IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged. INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them. PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses. Sync Tool - Folder sync tool with lots of real time information and several checking methods. USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions. Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent. CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction. MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app. 2048 Game - My version of 2048, fun tile game. Juice Lab - Ecigarette liquid making calculator. Data Protector - Secure notes to save sensitive information. VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive. Find in File - Searches files containing a specified phrase. Link to comment Share on other sites More sharing options...
eignxing Posted July 8, 2009 Share Posted July 8, 2009 Something like this? example with notepad: sleep(2000) If ControlFocus("Untitled - Notepad", "", 15) = 1 Then Do Send("{SPACE}") Send("{DOWN}") Until ControlFocus("Untitled - Notepad", "", 15) <> 1 EndIf Link to comment Share on other sites More sharing options...
NickBtheITguy Posted July 8, 2009 Author Share Posted July 8, 2009 The ExitLoop has to be within a "Do...Until", an "If...EndIf" isn't valid. I made a very slight change: Do If Not ControlFocus("Engagement Plus", "", 7009) Then ExitLoop Else while ControlFocus("Engagement Plus", "", 7009) Send("{SPACE}") Send("{DOWN}") wend Endif Until 1=2 Send("{ALT}F") Send("D") WinWaitActive("Delete Confirmation") Send("{Enter}") That no longer fails with a CTRL-F5 (syntax check). Not sure if that will fix everything, but check it out. Ian I'm not having a problem with the loop running or syntax check popping anything up. The problem is that the last entry will always have focus so the script just continues to run at the end selecting and deselecting the last entry. Link to comment Share on other sites More sharing options...
NickBtheITguy Posted July 8, 2009 Author Share Posted July 8, 2009 Something like this? example with notepad: sleep(2000) If ControlFocus("Untitled - Notepad", "", 15) = 1 Then Do Send("{SPACE}") Send("{DOWN}") Until ControlFocus("Untitled - Notepad", "", 15) <> 1 EndIf The problem that I am running into though is that last entry always has focus. So by saying lets loop until it doesn't, I never get to the point where it doesn't have focus. Link to comment Share on other sites More sharing options...
bo8ster Posted July 9, 2009 Share Posted July 9, 2009 (edited) Its less about how to break the loop, more that the loop will never break because it never knows to. It is always going to have focus even when it gets to the end and since it does not know when it gets to the end, it is never going to stop. The problem is more the control condition you chose then anything else. You need to know when you are at the bottom, I suggest you get a handle to the listview or whatever it is then get the count. From there you will know how many times to loop. Also I would guess the ControlID is for the control, not the one row in the control. Edited July 9, 2009 by bo8ster Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic] Link to comment Share on other sites More sharing options...
NickBtheITguy Posted July 9, 2009 Author Share Posted July 9, 2009 Its less about how to break the loop, more that the loop will never break because it never knows to. It is always going to have focus even when it gets to the end and since it does not know when it gets to the end, it is never going to stop. The problem is more the control condition you chose then anything else.You need to know when you are at the bottom, I suggest you get a handle to the listview or whatever it is then get the count. From there you will know how many times to loop.Also I would guess the ControlID is for the control, not the one row in the control.Wouldn't I run into the same problem trying to get the count of the listview? Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 9, 2009 Share Posted July 9, 2009 Wouldn't I run into the same problem trying to get the count of the listview?Spend some time in the help file with the example scripts there. Try out ControlListView(), and if you feel bold, try out the _GuiCtrlListView_* functions.Get the ID or handle to the ListView, get the item count, then loop only enough times to cover that count. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
NickBtheITguy Posted July 9, 2009 Author Share Posted July 9, 2009 Spend some time in the help file with the example scripts there. Try out ControlListView(), and if you feel bold, try out the _GuiCtrlListView_* functions.Get the ID or handle to the ListView, get the item count, then loop only enough times to cover that count. Thanks for your help guys. I think I misunderstood earlier about the ControlListView(). That was exactly what I was looking for. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now