|
29 | 29 | Global $_g_bNetWebView2_DebugInfo = True |
30 | 30 | ;~ Global $_g_bNetWebView2_DebugDev = False |
31 | 31 | Global $_g_bNetWebView2_DebugDev = (@Compiled = 1) |
| 32 | +Global $_g_bNetWebView2_Sleep = Sleep ; Default to calling standard Sleep function |
32 | 33 |
|
33 | 34 | #Region ; === NetWebView2Lib UDF === ENUMS |
34 | 35 |
|
@@ -92,6 +93,7 @@ Global Enum _ ; $NETWEBVIEW2_MESSAGE__* are set by mainly by __NetWebView2_Event |
92 | 93 | $NETWEBVIEW2_MESSAGE__DOWNLOAD_COMPLETED, _ |
93 | 94 | $NETWEBVIEW2_MESSAGE__RESPONSE_RECEIVED, _ |
94 | 95 | $NETWEBVIEW2_MESSAGE__UNKNOWN_MESSAGE, _ |
| 96 | + $NETWEBVIEW2_MESSAGE__USER_ABORT, _ |
95 | 97 | $NETWEBVIEW2_MESSAGE___FAKE_COUNTER |
96 | 98 |
|
97 | 99 | Global Enum _ |
@@ -211,7 +213,7 @@ Func _NetWebView2_Initialize($oWebV2M, $hUserGUI, $s_ProfileDirectory, $i_Left = |
211 | 213 | Local $iTimeOut_ms = 10000 ; max 10 seconds for initialization |
212 | 214 | Local $iMessage |
213 | 215 | Do |
214 | | - Sleep(50) |
| 216 | + __NetWebView2_Sleep(10) |
215 | 217 | $iMessage = __NetWebView2_LastMessage_KEEPER($oWebV2M) |
216 | 218 | If $iMessage = $NETWEBVIEW2_MESSAGE__INIT_FAILED _ |
217 | 219 | Or $iMessage = $NETWEBVIEW2_MESSAGE__PROFILE_NOT_READY _ |
@@ -467,7 +469,7 @@ Func _NetWebView2_LoadWait($oWebV2M, $iWaitMessage = $NETWEBVIEW2_MESSAGE__TITLE |
467 | 469 |
|
468 | 470 | While 1 |
469 | 471 | ; Allow AutoIt to "breathe" and process the GUI messages |
470 | | - Sleep(10) |
| 472 | + __NetWebView2_Sleep(10) |
471 | 473 |
|
472 | 474 | ; RULE 1: If we reached the target status or higher |
473 | 475 | Local $bWebIsReady = $oWebV2M.IsReady |
@@ -769,7 +771,7 @@ Func _NetWebView2_NavigateToPDF($oWebV2M, $s_URL_or_FilePath, Const $s_Parameter |
769 | 771 | $oWebV2M.LockWebView() |
770 | 772 | If $bFreeze Then __NetWebView2_freezer($oWebV2M, $idPic) |
771 | 773 | _NetWebView2_Navigate($oWebV2M, $s_URL_or_FilePath, $iWaitMessage, $sExpectedTitle, $iTimeOut_ms) |
772 | | - If Not @error Then Sleep($iSleep_ms) |
| 774 | + If Not @error Then __NetWebView2_Sleep($iSleep_ms) |
773 | 775 | __NetWebView2_Log(@ScriptLineNumber, $s_Prefix, 1) |
774 | 776 | If $bFreeze And $idPic Then __NetWebView2_freezer($oWebV2M, $idPic) |
775 | 777 | $oWebV2M.UnLockWebView() |
@@ -1099,6 +1101,26 @@ EndFunc ;==>_NetJson_EncodeB64 |
1099 | 1101 | #EndRegion ; === NetWebView2Lib UDF === _NetJson_* functions |
1100 | 1102 |
|
1101 | 1103 | #Region ; === NetWebView2Lib UDF === #INTERNAL_USE_ONLY# |
| 1104 | +; #INTERNAL_USE_ONLY# =========================================================================================================== |
| 1105 | +; Name ..........: __NetWebView2_Sleep |
| 1106 | +; Description ...: Pause script execution for designated timeframe. |
| 1107 | +; Syntax ........: __NetWebView2_Sleep($iPause) |
| 1108 | +; Parameters ....: $iPause - Amount of time to pause (in milliseconds) |
| 1109 | +; Return values .: Success - None |
| 1110 | +; Failure - None and sets @error $NETWEBVIEW2_MESSAGE__USER_ABORT |
| 1111 | +; Author ........: @Danp2, mLipok |
| 1112 | +; Modified ......: |
| 1113 | +; Remarks .......: Calls standard Sleep() by default. This can be overridden by setting $_g_bNetWebView2_Sleep so that a user supplied function gets called instead. |
| 1114 | +; User's function can throw error which will lead to $NETWEBVIEW2_MESSAGE__USER_ABORT |
| 1115 | +; Related .......: |
| 1116 | +; Link ..........: |
| 1117 | +; Example .......: No |
| 1118 | +; =============================================================================================================================== |
| 1119 | +Func __NetWebView2_Sleep($iPause) |
| 1120 | + $_g_bNetWebView2_Sleep($iPause) |
| 1121 | + If @error Then Return SetError($NETWEBVIEW2_MESSAGE__USER_ABORT) |
| 1122 | +EndFunc ;==>__NetWebView2_Sleep |
| 1123 | + |
1102 | 1124 | ; #INTERNAL_USE_ONLY# =========================================================================================================== |
1103 | 1125 | ; Name ..........: __NetWebView2_WaitForReadyState |
1104 | 1126 | ; Description ...: Polls the browser until the document.readyState reaches 'complete'. |
@@ -1143,7 +1165,7 @@ Func __NetWebView2_WaitForReadyState($oWebV2M, $hTimer, $iTimeOut_ms = 5000) |
1143 | 1165 | __NetWebView2_Log(@ScriptLineNumber, $s_Prefix & " TIMEOUT: Document state is " & $sReadyState & " Timeout_ms: " & Round(TimerDiff($hTimer), 0), 1) |
1144 | 1166 | Return SetError(1, 0, False) |
1145 | 1167 | EndIf |
1146 | | - Sleep(50) |
| 1168 | + __NetWebView2_Sleep(50) |
1147 | 1169 | WEnd |
1148 | 1170 | EndFunc ;==>__NetWebView2_WaitForReadyState |
1149 | 1171 |
|
|
0 commit comments