Wise Posted December 3, 2021 Posted December 3, 2021 Hallo I want to restore data from an LTO tape that was unfortunately copied to it incorrectly (there are a lot of small individual files on it). Unfortunately after restoring each individual file such an error message appears: Restoration of the files seems to have been executed successfully nevertheless. Now I have to click over 7000 times to that error to restore the whole tape :( If I could automate this with Autoit it would help me tremendously. Unfortunately I don't know anything about AutoIt at this time and my attempt to just send a RETURN keystroke regularly doesn't work. There is not even a single keystroke sent (although it works with the RETURN keystroke e.g. in Notepad). That was this first script: Sleep (5000) While True Send("{ENTER}") Sleep (1000) WEnd It is not even necessary to press the button. It would be enough to simply close the alarm window I don't understand how to wait and send for special "Windows". I used the Au3Info Program and got the following Information about that error Window: expandcollapse popup>>>> Window <<<< Title: ch13_20190802000000.mp4 Class: #32770 Position: 845, 484 Size: 233, 149 Style: 0x94C803C5 ExStyle: 0x00010101 Handle: 0x0000000000360EC2 >>>> Control <<<< Class: Button Instance: 1 ClassnameNN: Button1 Name: Advanced (Class): [CLASS:Button; INSTANCE:1] ID: 2 Text: OK Position: 132, 88 Size: 80, 23 ControlClick Coords: 38, 10 Style: 0x50030000 ExStyle: 0x00000004 Handle: 0x000000000084153E >>>> Mouse <<<< Position: 1018, 608 Cursor ID: 0 Color: 0xE1C17F >>>> StatusBar <<<< >>>> ToolsBar <<<< >>>> Visible Text <<<< OK CRC-Fehler: 0<>C40B7756 >>>> Hidden Text <<<< The window title changes of course with each file for which this message occurs For example, I tried the following to close this error-message window: Sleep (5000) Local $hWnd = WinWait("[CLASS:#32770]", "", 10) While True ControlClick($hWnd, "", "Button1") Sleep (1000) WinClose($hWnd) Sleep (1000) WEnd Does anyone have any idea how I can make this work properly?
Wise Posted December 3, 2021 Author Posted December 3, 2021 Sometimes a slightly different message comes up, like this one: From Au3Info I got this Infos about that Message Box: expandcollapse popup>>>> Window <<<< Title: Z-DATdump Restore Class: #32770 Position: 834, 471 Size: 257, 149 Style: 0x94C803C5 ExStyle: 0x00010101 Handle: 0x00000000001E1A3A >>>> Control <<<< Class: Button Instance: 1 ClassnameNN: Button1 Name: Advanced (Class): [CLASS:Button; INSTANCE:1] ID: 1 Text: OK Position: 71, 88 Size: 80, 23 ControlClick Coords: 46, 16 Style: 0x50030000 ExStyle: 0x00000004 Handle: 0x00000000001C1AF4 >>>> Mouse <<<< Position: 954, 601 Cursor ID: 0 Color: 0xE1E1E1 >>>> StatusBar <<<< >>>> ToolsBar <<<< >>>> Visible Text <<<< OK Abbrechen autorun.inf:CRC 0<>4C4204CC >>>> Hidden Text <<<<
Leendert-Jan Posted December 3, 2021 Posted December 3, 2021 (edited) In some programs, the class will change with every new window that get's created. What you could do instead is detect if the main window (Z-Datdump Restore) becomes unfocussed, something like this: While (True) ; Detect if the window gets unfocussed If Not WinActive("INSERT THE MAIN WINDOW HANDLE HERE") Then ; Check if it is the correct window by determening it's size. $aWinSize = WinGetClientSize("[ACTIVE]") If $aWinSize[0] == 233 And $aWinSize[1] == 149 Then ; Click the ok button. Using [ACTIVE] here since you said the title of the error window changes. ControlClick("[ACTIVE]", "", "Button1") EndIf EndIf WEnd Hope this helps Edited December 3, 2021 by Leendert-Jan
Wise Posted December 3, 2021 Author Posted December 3, 2021 Hi thanks. this does not work because the line... $aWinSize = WinGetClientSize("[ACTIVE]") set to the variable $aWinSize nothing i think; I tried that with the following code: While (True) ; Detect if the window gets unfocussed If Not WinActive("Z-DATdump") Then ; Check if it is the correct window by determening its size. $aWinSize = WinGetClientSize("[ACTIVE]") Msgbox(64,"getWinSize",$aWinSize) EndIf WEnd and if the error window apears I got the message box without any content. I tried that, too While (True) ; Detect if the window gets unfocussed If Not WinActive("Z-DATdump") Then WinClose("[ACTIVE]") EndIf WEnd But that doesn't work
Leendert-Jan Posted December 8, 2021 Posted December 8, 2021 (edited) First I want to apologize. I see I made a little mistake in the script. It is not WinActive("INSERT WINDOW HANDLE HERE") But WinActive(HWnd("INSERT WINDOW HANDLE HERE")) Sorry . Anyway, On 12/3/2021 at 1:45 PM, Wise said: and if the error window apears I got the message box without any content. WinGetClientSize returns an array. A messagebox cannot display an array. Try using _ArrayDisplay instead to get it's content: #include <Array.au3> ConsoleWrite("Make window active.") Sleep(2000) $aWinSize = WinGetClientSize("[ACTIVE]") _ArrayDisplay($aWinSize) On 12/3/2021 at 1:45 PM, Wise said: I tried that, too While (True) ; Detect if the window gets unfocussed If Not WinActive("Z-DATdump") Then WinClose("[ACTIVE]") EndIf WEnd But that doesn't work You are using "Z-DATdump" in WinActive. That is the title of the main window, so under normal circumstances that would be correct. But I saw in your screenshots that some error windows also have that title. Hence, the script will keep looping, because it still sees a window with that title. What I meant to say was that instead of using a title (which might bug because there can be multiple windows with the same title) you can use the Handle of the window. This script should detect that the main window get's unfocussed. While (True) ; Detect if the window gets unfocussed If WinActive(HWnd("INSERT THE MAIN WINDOW HANDLE HERE")) Then ConsoleWrite("Active" & @CRLF) Else ConsoleWrite("Inactive" & @CRLF) EndIf Sleep(1000) WEnd You can get the window handle by using the Window Info tool: >>>> Window <<<< Title: TestWindow Class: WindowsForms10.Window.8.app.0.378734a_r3_ad1 Position: 87, 85 Size: 433, 431 Style: 0x16CB0000 ExStyle: 0x00050100 Handle: 0x0000000000100BA8 At the bottom it says Handle. That is the value you want to use. Note: The Window Handle might be different every time the program starts. More info: _ArrayDisplay: https://www.autoitscript.com/autoit3/docs/libfunctions/_ArrayDisplay.htm HWnd: https://www.autoitscript.com/autoit3/docs/functions/HWnd.htm WinGetClientSize: https://www.autoitscript.com/autoit3/docs/functions/WinGetClientSize.htm Edited December 8, 2021 by Leendert-Jan Changed the window info to something different that the error window, it might be a bit confusing
Luke94 Posted December 8, 2021 Posted December 8, 2021 Hi Wise, Does this work? While 1 Local $hWnd = WinWait('[CLASS:#32770]', '', 1) If IsHWnd($hWnd) = 1 Then If WinActive($hWnd) = 0 Then WinActivate($hWnd) Local $iState = WinGetState($hWnd) If BitAND($iState, $WIN_STATE_EXISTS) And _ BitAND($iState, $WIN_STATE_VISIBLE) And _ BitAND($iState, $WIN_STATE_ENABLED) And _ BitAND($iState, $WIN_STATE_ACTIVE) Then ControlClick($hWnd, '', '[CLASS:Button; INSTANCE:1]') Else WinKill($hWnd) EndIf WinWaitClose($hWnd, '', 3) EndIf Sleep(1000) WEnd
water Posted December 8, 2021 Posted December 8, 2021 I once had a similar problem with a compiled script running on a server. In rare cases a MsgBox would pop up and bring the script to a permanent halt. Trancexx provided a solution: http://www.autoitscript.com/forum/topic/143250-grab-runtime-errors-when-script-is-run-from-a-service/ My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
ad777 Posted December 10, 2021 Posted December 10, 2021 (edited) try this code:(again i did little mistake i did fixed ihope it's works for ya) expandcollapse popupGlobal $aListe; Global $ADD Global $data Global $xw Global $sae = 1 ? 1;;true Global $st Global $Prev,$Preva; ;Z-DATdump Restore <- title of window ;MessageBox Text <- "autorun.inf:CRC 0<>4C4204CC" _NoMessage("Z-DATdump Restore","autorun.inf:CRC 0<>4C4204CC") ;this code made by Ad777 ;$TextIn; the text inside MessageBox ;$Window Title :the title of window(not MessageBox Title) Func _NoMessage($WindowTitle,$TextIn,$class = "Static") WinWaitActive($WindowTitle) While 1 ;if WinActive($WindowTitle) Then $aListe = WinList(); For $iae = 1 To $aListe[0][0] Step 1 If $aListe[$iae][0] <> "" And BitAND(WinGetState($aListe[$iae][1]), 2) Then if $aListe[$iae][0] = $WindowTitle Then $ADD &= $aListe[$iae-1][0] EndIf $Preva &= $aListe[$iae][0];; $xw =$ADD For $i = 0 To 15 Step 1 if ControlGetText($xw,"",$class&$i) = $TextIn And WinActive($xw) Then WinKill($xw) EndIf Next EndIf Next if $sae = 1 Then $Prev = $Preva ;;; $sae = 1 ? 0;false EndIf if _WindowIn($WindowTitle) = 1 Then if $Preva = $Prev Then ;;;if it's equal do stufff EndIf EndIf ; $state = "off" $iae = 0 $Preva = "" $ADD = "" if _WindowIn($WindowTitle) = 0 Then $Prev = ""; Local $aList = WinList() For $i = 1 To $aList[0][0] If $aList[$i][0] <> "" And BitAND(WinGetState($aList[$i][1]), 2) Then $Prev &= $aList[$i][0] EndIf Next EndIf ; EndIf WEnd EndFunc Func _WindowIn($MainGui) $PX = MouseGetPos()[0] $WX = WinGetPos($MainGui)[0] $PY = MouseGetPos()[1] $WY = WinGetPos($MainGui)[1] local $Wd = WinGetClientSize($MainGui)[0]+$WX+2 local $Wh = WinGetClientSize($MainGui)[1]+$WY+25 local $Wh2 = WinGetClientSize($MainGui)[1]-$Wh if $PX >= $WX and $PY >= $WY+26 and $PY < $Wh And $PY > $Wh2 and $PX <= $Wd then; And $WY <$PY Then Return 1 Else Return 0 EndIf EndFunc Edited December 18, 2021 by ad777 none
junkew Posted December 10, 2021 Posted December 10, 2021 Isn't there a cmdline for restoring (then I assume errors will be written to log and not shown in a popup) https://www.z-datdump.de/en/onlinehelp/index.html?context=130 FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets
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