Jump to content

mLipok

MVPs
  • Posts

    11,668
  • Joined

  • Last visited

  • Days Won

    63

mLipok last won the day on January 29

mLipok had the most liked content!

About mLipok

  • Birthday 07/19/1978

Profile Information

  • Member Title
    Sometimes... even usually I'm nitpicky.
  • Location
    Europe, Poland, Upper Silesia, Zabrze
  • Interests
    ¯\_(ツ)_/¯

Recent Profile Visitors

28,879 profile views

mLipok's Achievements

  1. The best one is to run service which will give you an oportunity to run different process on demand. But of course at first you must have Admin Rights to install and run such service.
  2. It is an options, but it will be fired at time, and not at demand.
  3. This is the normal Windows security behavior, when accessing the GUI using functions like: WinActivate("New Proprietary Program") MouseClick("left,xpos,ypos) Meaning, The controlled program and the controlling/automating program must have the same security level for the controlling/automating program to be able to access the controlled program. In your case Lower the security level/runtime environment of the controlled program. or Raise this level for the control/automation program. In your case as you showed to us, the #RequireAdmin did the trick
  4. With PDF I was just curious because I came across it while searching for solutions to other problems. With JSON I just wanted confirmation. By asking this directly, it will be easier for everyone to find it in search engines, even for me in the future when I need it. Now I'm focusing on WebView2 Anyway, Thanks for yours answer. mLipok
  5. oh... Nice Thanks So we can use this also for: https://learn.microsoft.com/en-us/uwp/api/windows.data.json?view=winrt-26100
  6. Clean full example is here: https://github.com/ioa747/NetWebView2Lib/pull/41
  7. is there a way to use Windows.Data.Pdf in AutoIt ? https://learn.microsoft.com/en-us/uwp/api/windows.data.pdf?view=winrt-26100
  8. and finally solved with a fruitful help from @argumentum and @Nine I mean help with _WinAPI_PrintWindow() issue Please focus on _WebView2_freezer() is my testing script: #AutoIt3Wrapper_UseX64=y #include <GUIConstantsEx.au3> #include <SendMessage.au3> #include <StaticConstants.au3> #include <WinAPIGdi.au3> #include <WinAPISysWin.au3> #include <WindowsConstants.au3> #include <WinAPIGdi.au3> #include <WinAPIGdiDC.au3> #include <WinAPIHObj.au3> #SciTE4AutoIt3_Dynamic_Include_Path=;..\NetWebView2Lib.au3 #SciTE4AutoIt3_Dynamic_Include=y ;dynamic.include=y/n #SciTE4AutoIt3_Dynamic_Include_whiletyping=y ;dynamic.include.whiletyping=y/n #SciTE4AutoIt3_Dynamic_Include_recursive_check=y ;dynamic.include.recursive.check=n/y #SciTE4AutoIt3_Dynamic_Include_use_local_cache=y ;dynamic.include.use.local.cache=n/y #SciTE4AutoIt3_Dynamic_Include_version=prod ;dynamic.include.version=prod/beta #SciTE4AutoIt3_Dynamic_Include_verboselevel=0 ;dynamic.include.verbose.level=0/1/2 ; 0=disabled; 1=Timing per Function; 2=1+Total timing #SciTE4AutoIt3_Dynamic_Include_Always_Update_Local_File=n ;dynamic.include.always.update.local.file=n/y #SciTE4AutoIt3_AutoItTools_debug=n ;debug.autoIttools=n/y #SciTE4AutoIt3_AutoItDynamicIncludes_debug=n ;debug.AutoItDynamicIncludes=n/y #SciTE4AutoIt3_AutoItAutocomplete_debug=n ;debug.autoitautocomplet=n/y #SciTE4AutoIt3_AutoItGotoDefinition_debug=n ;debug.autoitgotodefinition=n/y #SciTE4AutoIt3_AutoItIndentFix_debug=n ;debug.autoitindentfix=n/y #include "..\NetWebView2Lib.au3" ; ============================================================================== ; WebView2 Multi-Channel Presentation Script^ ; ============================================================================== ; Global objects ; GUI & Controls Global $hGUI, $idLabelStatus Main() Func Main() Local $oMyError = ObjEvent("AutoIt.Error", __NetWebView2_COMErrFunc) #forceref $oMyError ; Create the UI Local $iHeight = 800 $hGUI = GUICreate("WebView2 .NET Manager - Demo: " & @ScriptName, 1100, $iHeight, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPCHILDREN)) $idLabelStatus = GUICtrlCreateLabel("Status: Initializing Engine...", 10, $iHeight - 20, 880, 20) GUICtrlSetFont(-1, 9, 400, 0, "Segoe UI") ; Initialize WebView2 Manager and register events Local $oWebV2M = _NetWebView2_CreateManager("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36 Edg/144.0.0.0", "", "--mute-audio") $_g_oWeb = $oWebV2M If @error Then Return SetError(@error, @extended, $oWebV2M) ; Initialize JavaScript Bridge Local $oJSBridge = _NetWebView2_GetBridge($oWebV2M, "_BridgeMyEventsHandler_") If @error Then Return SetError(@error, @extended, $oWebV2M) Local $sProfileDirectory = @TempDir & "\NetWebView2Lib-UserDataFolder" _NetWebView2_Initialize($oWebV2M, $hGUI, $sProfileDirectory, 0, 0, 0, 0, True, True, True, 1.2, "0x2B2B2B") GUISetState(@SW_SHOW, $hGUI) WinSetOnTop($hGUI, '', True) ConsoleWrite("! ===" & @ScriptLineNumber & @CRLF) ;~ MsgBox($MB_TOPMOST, "TEST #" & @ScriptLineNumber, 0) Local $s_PDF_FileFullPath ;~ GUISetState(@SW_LOCK, $hGUI) $s_PDF_FileFullPath = "file:///" & @ScriptDir & '/FileViewerDemo_1.pdf' _NetWebView2_Navigate($oWebV2M, $s_PDF_FileFullPath) ;~ GUISetState(@SW_UNLOCK, $hGUI) MsgBox($MB_TOPMOST, "NORMAL TEST #" & @ScriptLineNumber, $s_PDF_FileFullPath, 0, $hGUI) Local $hWebView2_Window = _WinAPI_GetWindow($hGUI, $GW_CHILD) GUISetState(@SW_LOCK, ($hWebView2_Window)) $s_PDF_FileFullPath = "file:///" & @ScriptDir & '/FileViewerDemo_2.pdf' _NetWebView2_Navigate($oWebV2M, $s_PDF_FileFullPath) Sleep(1000) GUISetState(@SW_UNLOCK, ($hWebView2_Window)) MsgBox($MB_TOPMOST, "LOCK/UNLOCK TEST #" & @ScriptLineNumber, $s_PDF_FileFullPath, 0, $hGUI) _SendMessage($hWebView2_Window, $WM_SETREDRAW, False, 0) ; Disables ; https://www.autoitscript.com/forum/topic/199172-disable-gui-updating-repainting/ $s_PDF_FileFullPath = "file:///" & @ScriptDir & '/FileViewerDemo_1.pdf' _NetWebView2_Navigate($oWebV2M, $s_PDF_FileFullPath) Sleep(1000) _SendMessage($hWebView2_Window, $WM_SETREDRAW, True, 0) ; Enables _WinAPI_RedrawWindow($hWebView2_Window, 0, 0, BitOR($RDW_FRAME, $RDW_INVALIDATE, $RDW_ALLCHILDREN)) ; Repaints MsgBox($MB_TOPMOST, "$WM_SETREDRAW TEST #" & @ScriptLineNumber, $s_PDF_FileFullPath, 0, $hGUI) MsgBox($MB_TOPMOST, "TEST #" & @ScriptLineNumber, 'Freezzz 0') Local $idPic = _WebView2_freezer($hGUI) MsgBox($MB_TOPMOST, "TEST #" & @ScriptLineNumber, 'Freezzz 1') _SendMessage($hWebView2_Window, $WM_SETREDRAW, False, 0) ; Disables ; https://www.autoitscript.com/forum/topic/199172-disable-gui-updating-repainting/ MsgBox($MB_TOPMOST, "TEST #" & @ScriptLineNumber, 'Freezzz 2') $s_PDF_FileFullPath = "file:///" & @ScriptDir & '/FileViewerDemo_3.pdf' _NetWebView2_Navigate($oWebV2M, $s_PDF_FileFullPath) Sleep(1000) MsgBox($MB_TOPMOST, "TEST #" & @ScriptLineNumber, 'Freezzz 3') _SendMessage($hWebView2_Window, $WM_SETREDRAW, True, 0) ; Enables ;~ MsgBox($MB_TOPMOST, "TEST #" & @ScriptLineNumber, 'Freezzz 4') _WinAPI_RedrawWindow($hWebView2_Window, 0, 0, BitOR($RDW_FRAME, $RDW_INVALIDATE, $RDW_ALLCHILDREN)) ; Repaints ;~ MsgBox($MB_TOPMOST, "TEST #" & @ScriptLineNumber, 'Freezzz 5') GUICtrlDelete($idPic) ;~ MsgBox($MB_TOPMOST, "TEST #" & @ScriptLineNumber, 'Freezzz 6') ;~ _WinAPI_RedrawWindow($hWebView2_Window, 0, 0, BitOR($RDW_FRAME, $RDW_INVALIDATE, $RDW_ALLCHILDREN)) ; Repaints MsgBox($MB_TOPMOST, "$WM_SETREDRAW TEST #" & @ScriptLineNumber, $s_PDF_FileFullPath, 0, $hGUI) ; Main Loop While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete($hGUI) _NetWebView2_CleanUp($oWebV2M, $oJSBridge) EndFunc ;==>Main Func _GetFirstChildWindowHWND($hWnd) Local $aData = _WinAPI_EnumChildWindows($hWnd) ConsoleWrite("! $aData[1][0] = " & $aData[1][0] & @CRLF) ;~ _ArrayDisplay($aData, '_WinAPI_EnumChildWindows') If Not @error And UBound($aData) Then Return $aData[1][0] Return SetError(1, @extended, False) EndFunc ;==>_GetFirstChildWindowHWND Func _WebView2_freezer($hMainGUI_Window) Local $hWebView2_Window = _WinAPI_GetWindow($hMainGUI_Window, $GW_CHILD) Local $aPos = WinGetPos($hWebView2_Window) Local $hPrev = GUISwitch($hMainGUI_Window) ;~ Local $idPic = GUICtrlCreatePic('', $aPos[0], $aPos[1], $aPos[2], $aPos[3]) Local $idPic = GUICtrlCreatePic('', 0, 0, $aPos[2], $aPos[3]) Local $hPic = GUICtrlGetHandle($idPic) GUISwitch($hPrev) ; Create bitmap Local $hDC = _WinAPI_GetDC($hPic) Local $hDestDC = _WinAPI_CreateCompatibleDC($hDC) Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $aPos[2], $aPos[3]) Local $hDestSv = _WinAPI_SelectObject($hDestDC, $hBitmap) Local $hSrcDC = _WinAPI_CreateCompatibleDC($hDC) Local $hBmp = _WinAPI_CreateCompatibleBitmap($hDC, $aPos[2], $aPos[3]) Local $hSrcSv = _WinAPI_SelectObject($hSrcDC, $hBmp) _WinAPI_PrintWindow($hWebView2_Window, $hSrcDC, 2) _WinAPI_BitBlt($hDestDC, 0, 0, $aPos[2], $aPos[3], $hSrcDC, 0, 0, $MERGECOPY) _WinAPI_ReleaseDC($hPic, $hDC) _WinAPI_SelectObject($hDestDC, $hDestSv) _WinAPI_SelectObject($hSrcDC, $hSrcSv) _WinAPI_DeleteDC($hDestDC) _WinAPI_DeleteDC($hSrcDC) _WinAPI_DeleteObject($hBmp) ; Set bitmap to control _SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap) Local $hObj = _SendMessage($hPic, $STM_GETIMAGE) If $hObj <> $hBitmap Then _WinAPI_DeleteObject($hBitmap) EndIf Return $idPic EndFunc ;==>_WebView2_freezer
  9. @jpm took everything into account (I have seen it I on SVN.) https://www.autoitscript.com/trac/autoit/ticket/4069#comment:2 Thanks @jpm
  10. While I was in testing route for pre-release I hit issue Here is repro: #AutoIt3Wrapper_UseX64=y #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include "..\NetWebView2Lib.au3" ; Global objects Global $hGUI _Example() Func _Example() Local $oMyError = ObjEvent("AutoIt.Error", __NetWebView2_COMErrFunc) #forceref $oMyError #Region ; GUI CREATION ; Create the GUI $hGUI = GUICreate("WebView2 .NET Manager - Community Demo", 1000, 800) ; Initialize WebView2 Manager and register events ;~ Local $oWebV2M = _NetWebView2_CreateManager("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36 Edg/144.0.0.0", "", "--mute-audio") ;~ Local $oWebV2M = _NetWebView2_CreateManager("", "", "--mute-audio") Local $oWebV2M = ObjCreate("NetWebView2.Manager") ;~ ; Link Manager Events (Prefix + OnMessageReceived) ;~ ObjEvent($oManager, $sPrefix, "IWebViewEvents") ; 3. Link the JavaScript Bridge (Prefix + Bridge_OnMessageReceived) $_g_oWeb = $oWebV2M If @error Then Return SetError(@error, @extended, $oWebV2M) ; create JavaScript Bridge object ;~ Local $oJSBridge = _NetWebView2_GetBridge($oWebV2M, "") Local $oJSBridge = $oWebV2M.GetBridge() If @error Then Return SetError(@error, @extended, $oWebV2M) ; initialize browser - put it on the GUI Local $sProfileDirectory = @TempDir & "\NetWebView2Lib-UserDataFolder2" ;~ _NetWebView2_Initialize($oWebV2M, $hGUI, $sProfileDirectory, 0, 0, 0, 0, True, True, True, 1.2, "0x2B2B2B") $oWebV2M.Initialize($hGUI, $sProfileDirectory, 0, 0, 0, 0) ; show the GUI after browser was fully initialized GUISetState(@SW_SHOW) #EndRegion ; GUI CREATION #Region ; offline navigation ;~ $oWebV2M.Navigate("about:blank") Local $sHTML = _ "<!DOCTYPE html>" & @CRLF & _ "<html>" & @CRLF & _ "<body>" & @CRLF & _ "<h1>HELLO WORLD</h1>" & @CRLF & _ "</body>" & @CRLF & _ "</html>" & @CRLF & _ "" #forceref $sHTML ;~ _NetWebView2_NavigateToString($oWebV2M, $sHTML, False) #EndRegion ; offline navigation #Region ; navigate to the online web page $oWebV2M.Navigate("https://www.microsoft.com") ;~ _NetWebView2_Navigate($oWebV2M, "https://www.microsoft.com") ;~ _NetWebView2_Navigate($oWebV2M, "https://google.com") #EndRegion ; navigate to the online web page #Region ; GUI Loop ; Main Loop While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete($hGUI) #EndRegion ; GUI Loop _NetWebView2_CleanUp($oWebV2M, $oJSBridge) EndFunc ;==>_Example Issue description: I can't navigate to desired url. EDIT: I did: Unregister.au3 RegCleaner.au3 Register_web2.au3 tested with Version 1.4.3 - (2026-01-20)
  11. Done. Updated in HelpFile, also sleep added #include <GUIConstantsEx.au3> #include <SendMessage.au3> #include <StaticConstants.au3> #include <WinAPIGdi.au3> #include <WinAPIGdiDC.au3> #include <WinAPIHObj.au3> #include <WindowsConstants.au3> _Example() Func _Example() ShellExecute(@SystemDir & '\calc.exe') Local $hWnd = WinWaitActive("[REGEXPCLASS:CalcFrame|ApplicationFrameWindow]", '', 3) If Not $hWnd Then Exit EndIf Sleep(500) ; give it time to draw - let the window draw completely - skip the window animation ; Create GUI Local $aSize = WinGetPos($hWnd) GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), $aSize[2] + 80, $aSize[3] + 80) Local $idPic = GUICtrlCreatePic('', 40, 40, $aSize[2], $aSize[3]) Local $hPic = GUICtrlGetHandle($idPic) ; Create bitmap Local $hDC = _WinAPI_GetDC($hPic) Local $hDestDC = _WinAPI_CreateCompatibleDC($hDC) Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $aSize[2], $aSize[3]) Local $hDestSv = _WinAPI_SelectObject($hDestDC, $hBitmap) Local $hSrcDC = _WinAPI_CreateCompatibleDC($hDC) Local $hBmp = _WinAPI_CreateCompatibleBitmap($hDC, $aSize[2], $aSize[3]) Local $hSrcSv = _WinAPI_SelectObject($hSrcDC, $hBmp) Local Const $PW_RENDERFULLCONTENT = 0x2 ; this will go to where it should =) _WinAPI_PrintWindow($hWnd, $hSrcDC, $PW_RENDERFULLCONTENT) _WinAPI_BitBlt($hDestDC, 0, 0, $aSize[2], $aSize[3], $hSrcDC, 0, 0, $MERGECOPY) _WinAPI_ReleaseDC($hPic, $hDC) _WinAPI_SelectObject($hDestDC, $hDestSv) _WinAPI_SelectObject($hSrcDC, $hSrcSv) _WinAPI_DeleteDC($hDestDC) _WinAPI_DeleteDC($hSrcDC) _WinAPI_DeleteObject($hBmp) ; Set bitmap to control _SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap) Local $hObj = _SendMessage($hPic, $STM_GETIMAGE) If $hObj <> $hBitmap Then _WinAPI_DeleteObject($hBitmap) EndIf GUISetState(@SW_SHOW) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE WinClose($hWnd, "") EndFunc ;==>_Example EDIT: https://www.autoitscript.com/trac/autoit/ticket/4069
  12. https://learn.microsoft.com/en-us/answers/questions/1611498/clarification-on-the-nflags-parameter-default-valu https://learn.microsoft.com/en-us/answers/questions/801244/capturing-a-window minior fixes proposal: #include <GUIConstantsEx.au3> #include <SendMessage.au3> #include <StaticConstants.au3> #include <WinAPIGdi.au3> #include <WinAPIGdiDC.au3> #include <WinAPIHObj.au3> #include <WindowsConstants.au3> _Example() Func _Example() ShellExecute(@SystemDir & '\calc.exe') Local $hWnd = WinWaitActive("[REGEXPCLASS:CalcFrame|ApplicationFrameWindow]", '', 3) If Not $hWnd Then Exit EndIf Sleep(300) ; give it time to draw ; Create GUI Local $iSize = WinGetPos($hWnd) GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), $iSize[2] + 80, $iSize[3] + 80) Local $idPic = GUICtrlCreatePic('', 40, 40, $iSize[2], $iSize[3]) Local $hPic = GUICtrlGetHandle($idPic) ; Create bitmap Local $hDC = _WinAPI_GetDC($hPic) Local $hDestDC = _WinAPI_CreateCompatibleDC($hDC) Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $iSize[2], $iSize[3]) Local $hDestSv = _WinAPI_SelectObject($hDestDC, $hBitmap) Local $hSrcDC = _WinAPI_CreateCompatibleDC($hDC) Local $hBmp = _WinAPI_CreateCompatibleBitmap($hDC, $iSize[2], $iSize[3]) Local $hSrcSv = _WinAPI_SelectObject($hSrcDC, $hBmp) Local Const $PW_RENDERFULLCONTENT = 0x2 ; this will go to where it should =) _WinAPI_PrintWindow($hWnd, $hSrcDC, $PW_RENDERFULLCONTENT) _WinAPI_BitBlt($hDestDC, 0, 0, $iSize[2], $iSize[3], $hSrcDC, 0, 0, $MERGECOPY) _WinAPI_ReleaseDC($hPic, $hDC) _WinAPI_SelectObject($hDestDC, $hDestSv) _WinAPI_SelectObject($hSrcDC, $hSrcSv) _WinAPI_DeleteDC($hDestDC) _WinAPI_DeleteDC($hSrcDC) _WinAPI_DeleteObject($hBmp) ; Set bitmap to control _SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap) Local $hObj = _SendMessage($hPic, $STM_GETIMAGE) If $hObj <> $hBitmap Then _WinAPI_DeleteObject($hBitmap) EndIf GUISetState(@SW_SHOW) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE WinClose($hWnd, "") EndFunc ;==>_Example
  13. Please check out the _WinAPI_PrintWindow() function example in Windows 11. It doesn't work well for me.
  14. is'nt cdo.message end of life?
  15. Partially solved : #AutoIt3Wrapper_UseX64=y #include <GUIConstantsEx.au3> #include <SendMessage.au3> #include <WinAPIGdi.au3> #include <WinAPISysWin.au3> #include <WindowsConstants.au3> #SciTE4AutoIt3_Dynamic_Include_Path=;..\NetWebView2Lib.au3 #SciTE4AutoIt3_Dynamic_Include=y ;dynamic.include=y/n #SciTE4AutoIt3_Dynamic_Include_whiletyping=y ;dynamic.include.whiletyping=y/n #SciTE4AutoIt3_Dynamic_Include_recursive_check=y ;dynamic.include.recursive.check=n/y #SciTE4AutoIt3_Dynamic_Include_use_local_cache=y ;dynamic.include.use.local.cache=n/y #SciTE4AutoIt3_Dynamic_Include_version=prod ;dynamic.include.version=prod/beta #SciTE4AutoIt3_Dynamic_Include_verboselevel=0 ;dynamic.include.verbose.level=0/1/2 ; 0=disabled; 1=Timing per Function; 2=1+Total timing #SciTE4AutoIt3_Dynamic_Include_Always_Update_Local_File=n ;dynamic.include.always.update.local.file=n/y #SciTE4AutoIt3_AutoItTools_debug=n ;debug.autoIttools=n/y #SciTE4AutoIt3_AutoItDynamicIncludes_debug=n ;debug.AutoItDynamicIncludes=n/y #SciTE4AutoIt3_AutoItAutocomplete_debug=n ;debug.autoitautocomplet=n/y #SciTE4AutoIt3_AutoItGotoDefinition_debug=n ;debug.autoitgotodefinition=n/y #SciTE4AutoIt3_AutoItIndentFix_debug=n ;debug.autoitindentfix=n/y #include "..\NetWebView2Lib.au3" ; ============================================================================== ; WebView2 Multi-Channel Presentation Script^ ; ============================================================================== ; Global objects ; GUI & Controls Global $hGUI, $idLabelStatus Main() Func Main() Local $oMyError = ObjEvent("AutoIt.Error", __NetWebView2_COMErrFunc) #forceref $oMyError ; Create the UI Local $iHeight = 800 $hGUI = GUICreate("WebView2 .NET Manager - Demo: " & @ScriptName, 1100, $iHeight, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPCHILDREN)) $idLabelStatus = GUICtrlCreateLabel("Status: Initializing Engine...", 10, $iHeight -20 , 880, 20) GUICtrlSetFont(-1, 9, 400, 0, "Segoe UI") ; Initialize WebView2 Manager and register events Local $oWebV2M = _NetWebView2_CreateManager("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36 Edg/144.0.0.0", "", "--mute-audio") $_g_oWeb = $oWebV2M If @error Then Return SetError(@error, @extended, $oWebV2M) ; Initialize JavaScript Bridge Local $oJSBridge = _NetWebView2_GetBridge($oWebV2M, "_BridgeMyEventsHandler_") If @error Then Return SetError(@error, @extended, $oWebV2M) Local $sProfileDirectory = @TempDir & "\NetWebView2Lib-UserDataFolder" _NetWebView2_Initialize($oWebV2M, $hGUI, $sProfileDirectory, 0, 0, 0, 0, True, True, True, 1.2, "0x2B2B2B") GUISetState(@SW_SHOW, $hGUI) WinSetOnTop($hGUI, '', True) ConsoleWrite("! ===" & @ScriptLineNumber & @CRLF) ;~ MsgBox($MB_TOPMOST, "TEST #" & @ScriptLineNumber, 0) Local $s_PDF_FileFullPath ;~ GUISetState(@SW_LOCK, $hGUI) $s_PDF_FileFullPath = "file:///" & @ScriptDir & '/FileViewerDemo_1.pdf' _NetWebView2_Navigate($oWebV2M, $s_PDF_FileFullPath) ;~ GUISetState(@SW_UNLOCK, $hGUI) MsgBox($MB_TOPMOST, "NORMAL TEST #" & @ScriptLineNumber, $s_PDF_FileFullPath, 0, $hGUI) Local $hWebView2_Window = _EnumWindow($hGUI) GUISetState(@SW_LOCK, ($hWebView2_Window)) $s_PDF_FileFullPath = "file:///" & @ScriptDir & '/FileViewerDemo_2.pdf' _NetWebView2_Navigate($oWebV2M, $s_PDF_FileFullPath) Sleep(1000) GUISetState(@SW_UNLOCK, ($hWebView2_Window)) MsgBox($MB_TOPMOST, "LOCK/UNLOCK TEST #" & @ScriptLineNumber, $s_PDF_FileFullPath, 0, $hGUI) _SendMessage($hWebView2_Window, $WM_SETREDRAW, False, 0) ; Disables ; https://www.autoitscript.com/forum/topic/199172-disable-gui-updating-repainting/ $s_PDF_FileFullPath = "file:///" & @ScriptDir & '/FileViewerDemo_1.pdf' _NetWebView2_Navigate($oWebV2M, $s_PDF_FileFullPath) Sleep(1000) _SendMessage($hWebView2_Window, $WM_SETREDRAW, True, 0) ; Enables _WinAPI_RedrawWindow($hWebView2_Window, 0, 0, BitOR( $RDW_FRAME, $RDW_INVALIDATE, $RDW_ALLCHILDREN)) ; Repaints MsgBox($MB_TOPMOST, "$WM_SETREDRAW TEST #" & @ScriptLineNumber, $s_PDF_FileFullPath, 0, $hGUI) ; Main Loop While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete($hGUI) _NetWebView2_CleanUp($oWebV2M, $oJSBridge) EndFunc ;==>Main Func _EnumWindow($hWnd) Local $aData = _WinAPI_EnumChildWindows($hWnd) ConsoleWrite("! $aData[1][0] = " & $aData[1][0] & @CRLF) ;~ _ArrayDisplay($aData, '_WinAPI_EnumChildWindows') If Not @error And UBound($aData) Then Return $aData[1][0] Return SetError(1, @extended, False) EndFunc ;==>Example
×
×
  • Create New...