ijourneaux Posted April 21, 2010 Author Share Posted April 21, 2010 Its a button your having problems with now ? reason i ask is that the control id you are using is to a combobox ? These are the lines that doesn't seem to be executing. The print dialog box appears but I can;t get it to get focus of the button. If I click on the dialog box, I can get focus on the Print button the the script continues as it should ; wait for print dialog to appear do until (ControlFocus("Print", "", "[CLASS:Button; INSTANCE:13]") = 1) ControlClick("Print", "", "[CLASS:Button; INSTANCE:13]") Link to comment Share on other sites More sharing options...
Yoriz Posted April 21, 2010 Share Posted April 21, 2010 Try it like this, ive used notepad to open a print dialog. Run("Notepad") WinWait("Untitled - Notepad") WinMenuSelectItem("Untitled - Notepad", "", "&File", "&Print") WinWaitActive("Print") ControlClick("Print", "&Print", "Button13") GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF. Link to comment Share on other sites More sharing options...
ijourneaux Posted April 22, 2010 Author Share Posted April 22, 2010 Almost completed my first strat to finish script and just about ready to roll it out. About 146 lines longwith 9 func blocks. Still have a few small issues 1. Right now my script ends with _DebugOut ("This is the end.") Exit I get the DebugOut test in the debug window but in AutoIt, the script status is "Still Executing". All of my functions are define after the Exit statement. Is this a bug or is there a mistake in my script? Maybe it is as simple as closng the debug window? 2. Although 80-90% of the time the script executes and doesn't make any mistakes, sometimes when it tries to set the value of 2 checkboxes, the check box is not changed correctly. I am not sure I understand why it would work sometimes and not others. Func SpaceReels($sStatus) _DebugOut ("In Set Space Reels") if(ControlGetText("InfoStore Client", "", "[CLASS:ThunderRT6CheckBox; INSTANCE:1]") <> $sStatus) then ControlCommand("InfoStore Client", "", "[CLASS:ThunderRT6CheckBox; INSTANCE:1]", $sStatus) EndIf do until (ControlFocus("InfoStore Client", "", "[CLASS:ThunderRT6ComboBox; INSTANCE:3]") = 1) EndFunc Thansk again for bearing with me as I worked through the learning curve. Link to comment Share on other sites More sharing options...
Yoriz Posted April 22, 2010 Share Posted April 22, 2010 1. Have never used _DebugOut, didnt even know it existed as a udf till i see it in your code and then checked to see if it was a udf or one of your own functions . definining functions after the exit is not a problem, when a function is called it just goes to it where ever it is located. 2. your Func SpaceReels($sStatus) is not really checking if the window that contains it exists, unless you have that elsewhere in your code, it says its working with a checkbox, for that you'd be better with ControlCommand( "title", "text", controlID, "IsChecked", ""), you then have a do until loop that does nothing for you, it just checks if it can get foucs , if it can it just ends the function if it cant your script will just get stuck in a infinate loop here. heres some code to chew over expandcollapse popupMsgBox(0,"note","attempt to check a checkbox that its parent window deosnt exist", 4) $fTest = _SetCheckState("Print", "Print to &file", "Button3", True) MsgBox(0,"test", "changed ok = " & $fTest, 2) Run("notepad") WinWaitActive("Untitled - Notepad") WinMenuSelectItem("Untitled - Notepad", "", "&File", "&Print") WinWaitActive("Print") MsgBox(0,"note","attempt to check the print to file checkbox", 4) $fTest = _SetCheckState("Print", "Print to &file", "Button3", True) MsgBox(0,"test", "changed ok = " & $fTest, 2) MsgBox(0,"note","attempt to uncheck the print to file checkbox", 4) $fTest = _SetCheckState("Print", "Print to &file", "Button3", False) MsgBox(0,"test", "changed ok = " & $fTest, 2) WinClose("Print") WinWaitClose("Print") WinMenuSelectItem("Untitled - Notepad", "", "&File", "Page Set&up") MsgBox(0,"Note","wont be able to uncheck portrait as its in a group with lanscape", 4) $fTest = _SetCheckState("Page Setup", "P&ortrait", "Button3", False) MsgBox(0,"test", "changed ok = " & $fTest, 2) MsgBox(0,"Note","attempt to set landscape instead", 4) $fTest = _SetCheckState("Page Setup", "L&andscape", "Button4", True) MsgBox(0,"test", "changed ok = " & $fTest, 2) WinClose("Page Setup") WinWaitClose("Page Setup") WinClose("Untitled - Notepad") Func _SetCheckState($sTitle, $text, $sControlID, $fState, $iTimeout = 5) Local $iTimer = TimerInit(), $fStatusOk = False, $sMsg While 1 Sleep(100) Select Case (TimerDiff($iTimer) / 1000) >= $iTimeout $fStatusOk = False $sMsg = "Timmed out after " & round((TimerDiff($iTimer) / 1000) & " Sec" & @CR & "Previous msg = " & $sMsg) ExitLoop Case Not WinExists($sTitle, $text) $fStatusOk = False $sMsg = "Parent window Does not exist" ExitLoop Case Not $fStatusOk If (TimerDiff($iTimer) / 1000) >= $iTimeout/2 Then WinActivate($sTitle, $text) Select Case ControlCommand($sTitle, $text, $sControlID, "IsChecked", "") If $fState Then $fStatusOk = True $sMsg = "set ok" ExitLoop Else MsgBox(0,"Is checked","should uncheck", 1) ControlCommand($sTitle, $text, $sControlID, "UnCheck", "") $fStatusOk = False $sMsg = "not set ok" EndIf Case Else If Not $fState Then $fStatusOk = True $sMsg = "set ok" ExitLoop Else MsgBox(0,"Is not checked","should check", 1) ControlCommand($sTitle, $text, $sControlID, "Check", "") $fStatusOk = False $sMsg = "not set ok" EndIf EndSelect EndSelect WEnd MsgBox(0, "Info", $sMsg, 2) Return $fStatusOk EndFunc GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF. Link to comment Share on other sites More sharing options...
ijourneaux Posted April 29, 2010 Author Share Posted April 29, 2010 I incorporated a version of you timer function to make sure the script doesn't just hang when it can't get focus on a window or a control. I have run in to an interesting case. I have one window that has one title when it is in focus and a second title if it isn't in focus. I ma having trouble reliabily bringing the window in focus and clicking on one of the buttons. Any thoughts? Link to comment Share on other sites More sharing options...
Yoriz Posted April 29, 2010 Share Posted April 29, 2010 Check for the focus window title if it does not exist, check for the non focus title, active the non focus title , wait for it to become the focus title , control click using the focus title. $sWindowInFocusName = "WindowInFocusName" $sWindowNotInFocusName = "WindowNotInFocusName" If _FocusWindow($sWindowInFocusName, $sWindowNotInFocusName) Then ControlClick($sWindowInFocusName, "text", "ContrlID") Func _FocusWindow($sWindowInFocusName, $sWindowNotInFocusName) If WinExists($sWindowInFocusName) Then Return True ; window found ok Else If WinExists($sWindowNotInFocusName) Then WinActivate($sWindowNotInFocusName) If WinWait($sWindowInFocusName,"",10) Then Return True ; window found ok Else Return False ; failed to make active EndIf Else Return False ; window not found at all EndIf EndIf EndFunc If it doesnt need to be in focus , find which exist and use that as title for control click $sWindowInFocusName = "WindowInFocusName" $sWindowNotInFocusName = "WindowNotInFocusName" $sWhichWindow = _EitherWindow($sWindowInFocusName, $sWindowNotInFocusName) If $sWhichWindow Then ControlClick($sWhichWindow, "text", "ContrlID") Func _EitherWindow($sWindowInFocusName, $sWindowNotInFocusName) If WinExists($sWindowInFocusName) Then Return $sWindowInFocusName If WinExists($sWindowNotInFocusName) Then Return $sWindowNotInFocusName Return False EndFunc GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF. Link to comment Share on other sites More sharing options...
ijourneaux Posted April 30, 2010 Author Share Posted April 30, 2010 Well that didn't work quite the way I wanted but it got me past the hump. It appears that WinExists works for both window titles even though there only seems to be one window. Using your example $sWhichWindow = _EitherWindow("pdfFactory", "page") returns "pdfFactory" but I need to send the command to the "page" window. Using $sWhichWindow = _EitherWindow("page, "pdfFactory") works. Link to comment Share on other sites More sharing options...
Yoriz Posted May 1, 2010 Share Posted May 1, 2010 As both WinExists come up as true they cant be the same window as you expected, one must be hidden, thats why if using $sWhichWindow with pdfFactory first it returns pdfFactory and likewise with page first , reason being is it returns the first one found. WinExists will return true on hidden windows. GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF. 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