Mechaflash Posted February 29, 2012 Share Posted February 29, 2012 (edited) An application I'm trying to interface with doesn't allow for files to be passed as arguments to open them, so I have to manipulate the GUI for the application to get it to do this. The open dialogue brings up a ListView32 box, and I have to navigate to a new directory, which I've been using ControlCommand and then ControlSend however, since it is a dropdown menu, the user can potentially interrupt the script, ultimately breaking its functionality. And I know that by many AutoIT standards, that's a bad way to do it as well (and I don't want to get yelled at by Valik ). After I get to my folder in question, I just select all of the files. My current code looks like this Func _OpenFiles() ; Open the group of images that the user selected WinSetOnTop("All My Papers","",1) ControlClick("All My Papers", "", "[CLASS:TPanel;INSTANCE:3]", "Left", 1, 90, 15) WinSetOnTop("All My Papers","",0) $iFileOpenTimer = 0 Do $iFileOpenTimer+=1 $iActive = WinWaitActive("Select Image File", "", 1) If WinExists("Select Image File") Then WinSetOnTop("Select Image File","",1) $hFileOpen = WinGetHandle("Select Image File","") EndIf Until $iFileOpenTimer = 10 OR $iActive = $hFileOpen If $iActive = 0 Then _SendAppError(1,$iAmpPid) EndIf If NOT (ControlGetText("Select Image File","","[CLASS:ComboBox; INSTANCE:1]") = "CHECKS_TO_PROCESS") Then ControlCommand("Select Image File","","[CLASS:ComboBox; INSTANCE:1]", "ShowDropDown", "") Sleep(100) ControlCommand("Select Image File","","[CLASS:ComboBox; INSTANCE:1]", "SelectString", 'My Documents') Sleep(100) ControlSend("Select Image File","","[CLASS:ComboBox; INSTANCE:1]", "{ENTER}") Sleep(100) $sChecksToProcess = ControlListView("Select Image File","","[CLASS:SysListView32; INSTANCE:1]","FindItem", "CHECKS_TO_PROCESS") ControlListView("Select Image File","","[CLASS:SysListView32; INSTANCE:1]","Select", $sChecksToProcess) Sleep(100) ControlSend("Select Image File","","[CLASS:SysListView32; INSTANCE:1]", "{ENTER}") Sleep(100) EndIf ControlListView("Select Image File","","[CLASS:SysListView32; INSTANCE:1]","SelectAll") Sleep(100) ControlSend("Select Image File","","[CLASS:SysListView32; INSTANCE:1]", "{ENTER}") EndFunc I don't know of an alternative method of doing this, but another imaginative thought was to somehow disable USER interaction with the application (but somehow still allow the script to do its magic on the application)? EDIT: Well... I can move the mouse to a safe location... then BlockInput() until its done opening the files... does that seem safe enough? Edited February 29, 2012 by mechaflash213 Spoiler “Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.” Link to comment Share on other sites More sharing options...
Mechaflash Posted February 29, 2012 Author Share Posted February 29, 2012 To make it a bit safer, I added in the Blockinput() as well as WinMove(...,99999,99999) so the user doesn't mess with it while its doing its thing. For the user's sake, I added a progress bar so they don't freak out while their mouse/keyboard are frozen. expandcollapse popupFunc _OpenFiles() ; Open the group of images that the user selected WinSetOnTop("All My Papers","",1) ControlClick("All My Papers", "", "[CLASS:TPanel;INSTANCE:3]", "Left", 1, 90, 15) WinSetOnTop("All My Papers","",0) $iFileOpenTimer = 0 Do $iFileOpenTimer+=1 $iActive = WinWaitActive("Select Image File", "", 1) If WinExists("Select Image File") Then WinSetOnTop("Select Image File","",1) $hFileOpen = WinGetHandle("Select Image File","") EndIf Until $iFileOpenTimer = 10 OR $iActive = $hFileOpen If $iActive = 0 Then _SendAppError(1,$iAmpPid) EndIf If NOT (ControlGetText("Select Image File","","[CLASS:ComboBox; INSTANCE:1]") = "CHECKS_TO_PROCESS") Then ProgressOn("Please Wait..........", "Loading Check Images...") ProgressSet(0) BlockInput(1) WinMove("Select Image File","",99999,99999) ControlCommand("Select Image File","","[CLASS:ComboBox; INSTANCE:1]", "ShowDropDown", "") ProgressSet(10) Sleep(500) ControlCommand("Select Image File","","[CLASS:ComboBox; INSTANCE:1]", "SelectString", 'My Documents') ProgressSet(25) Sleep(500) ControlSend("Select Image File","","[CLASS:ComboBox; INSTANCE:1]", "{ENTER}") ProgressSet(40) Sleep(500) $sChecksToProcess = ControlListView("Select Image File","","[CLASS:SysListView32; INSTANCE:1]","FindItem", "CHECKS_TO_PROCESS") ControlListView("Select Image File","","[CLASS:SysListView32; INSTANCE:1]","Select", $sChecksToProcess) ProgressSet(55) Sleep(500) ControlSend("Select Image File","","[CLASS:SysListView32; INSTANCE:1]", "{ENTER}") ProgressSet(70) Sleep(500) EndIf ControlListView("Select Image File","","[CLASS:SysListView32; INSTANCE:1]","SelectAll") ProgressSet(85) Sleep(500) ControlSend("Select Image File","","[CLASS:SysListView32; INSTANCE:1]", "{ENTER}") BlockInput(0) ProgressSet(100,"","Loading Complete") Sleep(2000) ProgressOff() EndFunc Spoiler “Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.” 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