Jump to content

vtr

Members
  • Posts

    7
  • Joined

  • Last visited

vtr's Achievements

Seeker

Seeker (1/7)

1

Reputation

  1. This will most likely be too late for the original poster, but may help somebody searching the archives: dealing with another legacy application, i seem to be able to read the contents out of AfxWnd42s controls using textcapturex by Deskperience Software. i am still having problems reading the content out of those pesky Afx:400000:8:10013:b1010b and similar controls. Hth,
  2. I am trying to automate an application which lets me select items from a number of comboxes and syslistviews and then print out the resulting selection. this worked reasonably well until i also tried to automate the print options using PrintWithOptions() below For each such selection, PrintWithOptions() loops through all permutations of a number of checkboxes - done by setARLCheckbox() which checkboxes i cannot seem to address programmatically, so i resorted to pixelsearch to query their ischecked-status). after a relatively small number of iterations (i counted as few as 66, depending on which computer this is running on), this fails with a #32770 popup stating ""a required resource was"". the application's controls do not get redrawn properly, as well as the controls of other applications' and of the os, including e.g. the taskbar (this is on windows xp sp 2). a websearch reveals this to be a gdi message in mfc/vc programming (which, as other error messages seem to reveal, this application is based on) and the presumed cause leaking of GDI objects (brushes, pens, bitmaps and the like) which should be freed with deleteobject() (?) i know nothing about gdi and mfc programming, but am wondering whether there is something i can improve in my autoit code to work around this (short from trying to intercept this #32770 popup and restarting the application to the desired selection which is what i am currently attempting with PrintWithOptionsResourceFailureChecker - adlibenable would not seem to work for me with this). Thanks in advance, Func PrintWithOptions($stlvalue, $translationlanguageIndex, $printDriver, $filename) Local $arrStlValues $filename = $filename & "_stl=" & $stlvalue $arrStlValues = StringSplit($stlvalue, "") setARLCheckbox($windowtitleTT, $CheckboxPrintsolutionsClassnameNN, Number($arrStlValues[1])) Sleep(500) setARLCheckbox($windowtitleTT, $CheckboxPrintTranslationsClassnameNN, Number($arrStlValues[2])) Sleep(500) setARLCheckbox($windowtitleTT, $CheckboxPrintGrammarlinksClassnameNN, Number($arrStlValues[3])) Sleep(500) $ret = ControlCommand($windowtitleTT, "", $DropdownTranslationLanguageClassnameNN, "SetCurrentSelection", $translationlanguageIndex) MouseClick("left", 40, 70) $ret = WinWaitActive($windowtitleprint, "", 6) If $ret == 0 Then $ret = WinWaitActive($windowtitleprint, "", 6) If $ret == 0 Then PrintWithOptionsResourceFailureChecker($currentLessonLanguageIndex, $currentLessonFamilyIndex, $currentContentTypeIndex, $currentActivityOrUnitOrCultureIndex, $currentSelectionIndex, True, $ret, $windowtitleprint, "mouseclick") MouseClick("left", 40, 70) $ret = WinWaitActive($windowtitleprint, "", 6) EndIf EndIf $ret = ControlCommand($windowtitleprint, "", "ComboBox1", "SelectString", $printDriver) If @error = 1 Then $ret = ControlCommand($windowtitleprint, "", "ComboBox1", "SelectString", $printDriver) If @error = 1 Then PrintWithOptionsResourceFailureChecker($currentLessonLanguageIndex, $currentLessonFamilyIndex, $currentContentTypeIndex, $currentActivityOrUnitOrCultureIndex, $currentSelectionIndex, False, @error, $windowtitleprint, "ComboBox1" & " " & "SelectString") MouseClick("left", 40, 70) $ret = WinWaitActive($windowtitleprint, "", 6) $ret = ControlCommand($windowtitleprint, "", "ComboBox1", "SelectString", $printDriver) EndIf EndIf ; more print dialogues code omitted for clarity Sleep(2000) $ret = WinActivate($windowtitleTT) $ret = WinWaitActive($windowtitleTT, "", 19) If $ret == 0 Then $windowText = WinGetText("") If StringInStr($windowText, "Do you want to replace it") > 0 Then $ret3 = ControlClick($windowtitlePDFSave, "", "Button2") If $ret3 = 0 Then Sleep(500) $ret3 = ControlClick($windowtitlePDFSave, "", "Button2") EndIf Sleep(500) $ret1 = WinWaitActive($windowtitlePDFSave, "", 2) If $ret1 = 1 Then $ret = ControlSetText($windowtitlePDFSave, "", "Edit1", "error" & $errorcounter) EndIf EndIf $ret = WinActivate($windowtitleTT) $ret = WinWaitActive($windowtitleTT, "", 59) If $ret == 0 Then PrintWithOptionsResourceFailureChecker($currentLessonLanguageIndex, $currentLessonFamilyIndex, $currentContentTypeIndex, $currentActivityOrUnitOrCultureIndex, $currentSelectionIndex, True, $ret, $windowtitleTT, "not coming up") $ret = WinActivate($windowtitleTT) EndIf EndIf EndFunc ;==>PrintWithOptions Func setARLCheckbox($strWindowTitle, $ControlName, $isCheckedDesiredstatus) Local $PixelsearchError Local $absMaxX Local $absMaxY Local $absMinX Local $absMinY Local $aintCoord Local $blackcoord Local $isChecked Local $ret $ret = WinActivate($strWindowTitle, "") If $ret == 0 Then Exit EndIf $aintCoord = ControlGetPos($strWindowTitle, "", $ControlName) $absMinX = $aintCoord[0] + 3 $absMinY = $aintCoord[1] + 3 + 26 $absMaxX = $aintCoord[0] + 9 $absMaxY = $aintCoord[1] + 9 + 26 $isChecked = True $blackcoord = PixelSearch($absMinX, $absMinY, $absMaxX, $absMaxY, 0x000000) $PixelsearchError = @error If $PixelsearchError = 1 Then $isChecked = False EndIf If $isCheckedDesiredstatus <> $isChecked Then If $PixelsearchError = 1 Then ControlClick($strWindowTitle, "", $ControlName) Else MouseClick("left", $blackcoord[0], $blackcoord[1]) EndIf EndIf $PixelsearchError = "" $absMaxX = "" $absMaxY = "" $absMinX = "" $absMinY = "" $aintCoord = "" $blackcoord = "" $isChecked = "" $ret = "" EndFunc ;==>setARLCheckbox
  3. Great, thanks a lot, will test in the office tomorrow.
  4. Hi, many thanks for the script, clicking "Copy to clipboard" returns C:\Program Files\AutoIt3\Include\FindClassesByText.au3 (327) : ==> Subscript used with non-Array variable.: If StringInStr($a_Item[0], "'") <> 0 Then If StringInStr($a_Item^ ERROR Is this still supported? Would be useful to have.
  5. Just taking a guess: can't you check for @Error:7 ($_IEStatus_NoMatch) = No Match (from the help-file).
  6. Thanks for what looks very interesting. But while I can get to http://www.autoitscript.com/fileman/users/AutoIt%20Smith/, the file is not there
  7. Thanks a lot for posting this. I had just discovered rAutoIt when I ran into the limitation regarding interacting with non-standard MS-controls. Calling textcaptureX using your function seems an excellent workaround. In the code below I am trying to read a control directly. in the application that i am currently working with i had to introduce some offset variables. The autoit window info tool shows the discrepancy of the y-offset also (a difference between x,y coordinates of "control under mouse" and "mouse detail"). The autoit window info tool does not show a discrepancy that would account for the need for the x-offset, so i had to experiment, but seem to have got it to work for my current application. (If somebody can shed some light onto this , that would be great). Global $TextCaptureXoffset = 10, $TextCaptureYoffset = 30 Global $TextCaptureListViewXoffset = -4, $TextCaptureListViewYoffset = 46 $ocr = _ctrlOCR("Add selection","SysListView321") MsgBox(0,"OCR", $ocr) Func _ctrlOCR($wTitle, $sClassNameNN) $xy = WinGetPos($wTitle) $ctrlXY = ControlGetPos($wTitle,"",$sClassNameNN) $Title = WinGetTitle($wTitle) $hwnd = Dec(StringTrimLeft(WinGetHandle($Title), 2)) $obj = ObjCreate("TCaptureX.TextCaptureX") if StringInStr($sClassNameNN,"SysListView32") <> 0 then $results = $obj.GetTextFromRect($hwnd, $TextCaptureListViewXoffset + $xy[0]+$ctrlXY[0], $TextCaptureListViewYoffset + $xy[1]+$ctrlXY[1] , $ctrlXY[2], $ctrlXY[3]) else $results = $obj.GetTextFromRect($hwnd, $TextCaptureXoffset + $xy[0]+$ctrlXY[0], $TextCaptureYoffset + $xy[1]+$ctrlXY[1] , $ctrlXY[2], $ctrlXY[3]) endif return $results EndFunc
×
×
  • Create New...