rudi Posted November 4, 2013 Share Posted November 4, 2013 Hi. To automate MAK activation on different localization versions of Win7 and above I'd like to winwait for a set of possible window text strings. The script below works fine, when I have dedicated versions for each localisation's language. I currently can't see, how to wait for a set of possible text strings. Opt("WinTitleMatchMode", 3) seems to target *TITLES* only, not the text of a window? expandcollapse popup#RequireAdmin $WHS = "Windows Script Host" $Btn = "Button1" $MAK = "ABCDE-12345-ABCDE-12345-ABCDE" $LicVer= "Windows 7 Enterprise (MAK)" Dim $SlmgrParams[4][2] = [[3], _ ["/upk", "(?i)(Der Product Key wurde erfolgreich deinstalliert.|Uninstalled product key successfully|Error: product key not found)"], _ ["/ipk " & $MAK, "(?i)(Der Product Key " & $MAK & " wurde erfolgreich installiert|installed successfully)"], _ ["/ato", "(?i)(Das Produkt wurde erfolgreich aktiviert|activated successfully)"]] $msgtxt = $LicVer & ", install, activate:" & @CRLF & @CRLF $Problem=0 For $i = 1 To $SlmgrParams[0][0] ShellExecute("slmgr.vbs", $SlmgrParams[$i][0], @TempDir, "", @SW_SHOW) winget If WinWait($WHS, $SlmgrParams[$i][1], 30) Then ; < ------------------------- howto wait for window text using RegEx? ToolTip("") sleep(1000) ; damit man das kurz lesen kann... ControlClick($WHS, $SlmgrParams[$i][1], $Btn) Else $Problem+=1 ToolTip($SlmgrParams[$i][0], 30, 30, "WHS Result Window doesn't show up, waiting...") WinWait($WHS) While WinExists($WHS) ToolTip($SlmgrParams[$i][0], 30, 30, "check WHS Result Window, then continue!") Sleep(100) WEnd ToolTip("Trying to proceed", 30, 30, "Windows Aktivation") EndIf Next if $Problem Then MsgBox(48,$LicVer & " Aktivierung","Propably " & $Problem & " errors occured while trying to activate this installation!") Else MsgBox(0,$LicVer & " Aktivierung","This Windows installation should be activated now.",30) EndIf Any suggestion appreciated, Rudi. Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
mikell Posted November 4, 2013 Share Posted November 4, 2013 (edited) You can regex-check the content of a window, here is an example (try it using notepad) Dim $SlmgrParams[4][2] = [[3], _ ["/upk", "(?i)(deinstalliert|Uninstalled|Error)"], _ ["/ipk ", "(?i)( installiert|successfully)"], _ ["/ato", "(?i)(aktiviert|activated)"]] While 1 Local $var = WinList() For $i = 1 To $var[0][0] If $var[$i][0] <> "" And IsVisible($var[$i][1]) Then For $k = 1 To $SlmgrParams[0][0] $res = StringRegExp(WinGetText($var[$i][1]), $SlmgrParams[$k][1], 1) If IsArray($res) Then Exit MsgBox(0, "", $var[$i][0] &@crlf& $res[0]) Next EndIf Next Wend Func IsVisible($handle) If BitAND(WinGetState($handle), 2) Then Return 1 Else Return 0 EndIf EndFunc ;==>IsVisible This works for detection, for WinWait+timeout adding a timer inside the loop should to the trick Edited November 4, 2013 by mikell 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