Jump to content

mLipok

MVPs
  • Posts

    11,669
  • Joined

  • Last visited

  • Days Won

    63

mLipok last won the day on January 29

mLipok had the most liked content!

About mLipok

Profile Information

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

Recent Profile Visitors

28,891 profile views

mLipok's Achievements

  1. I just review my code of PDF Viewing. The following code shows in a loop PDF taken from directory #AutoIt3Wrapper_UseX64=y #include <File.au3> #include <GUIConstantsEx.au3> #include <SendMessage.au3> #include <StaticConstants.au3> #include <WinAPIGdi.au3> #include <WinAPIGdiDC.au3> #include <WinAPIHObj.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" Main() Func Main() Local $oMyError = ObjEvent("AutoIt.Error", __NetWebView2_COMErrFunc) #forceref $oMyError ; Create the UI Local $iHeight = 800 Local $hGUI = GUICreate("WebView2 .NET Manager - Demo: " & @ScriptName, 1100, $iHeight, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPCHILDREN)) Local $idLabelStatus = GUICtrlCreateLabel("Status: Initializing Engine...", 10, $iHeight - 20, 880, 20) #forceref $idLabelStatus 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") Local $i_ProcessID = @extended #forceref $i_ProcessID GUISetState(@SW_SHOW, $hGUI) ConsoleWrite("! ===" & @ScriptLineNumber & @CRLF) ;~ MsgBox($MB_TOPMOST, "TEST #" & @ScriptLineNumber, 0) Local $s_PDF_FileFullPath Local $s_PDF_Directory = FileSelectFolder('Choose folder with PDF','') Local $a_Files = _FileListToArrayRec($s_PDF_Directory, '*.pdf', $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH) Local Static $hWebView2_Window = _WinAPI_GetWindow($hGUI, $GW_CHILD) For $IDX_File = 1 To $a_Files[0] $s_PDF_FileFullPath = $a_Files[$IDX_File] _NetWebView2_NavigateToPDF($oWebV2M, $s_PDF_FileFullPath, $hWebView2_Window, '#view=FitH', 1000) ConsoleWrite("! === @SLN=" & @ScriptLineNumber & ' ' & $s_PDF_FileFullPath & @CRLF) Next ; 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 Func __NetWebView2_freezer($hWebView2_Window, $idPic = 0) #Region ; if $idPic is given then it means you already have it and want to delete it - unfreeze - show WebView2 content If $idPic Then _SendMessage($hWebView2_Window, $WM_SETREDRAW, True, 0) ; Enables _WinAPI_RedrawWindow($hWebView2_Window, 0, 0, BitOR($RDW_FRAME, $RDW_INVALIDATE, $RDW_ALLCHILDREN)) ; Repaints GUICtrlDelete($idPic) Return EndIf #EndRegion ; if $idPic is given then it means you already have it and want to delete it - unfreeze - show WebView2 content #Region ; freeze $hWebView2_Window #Region ; add PIC to parent window Local $hMainGUI_Window = _WinAPI_GetWindow($hWebView2_Window, $GW_HWNDPREV) Local $aPos = WinGetPos($hWebView2_Window) Local $hPrev = GUISwitch($hMainGUI_Window) $idPic = GUICtrlCreatePic('', 0, 0, $aPos[2], $aPos[3]) Local $hPic = GUICtrlGetHandle($idPic) GUISwitch($hPrev) #EndRegion ; add PIC to parent window ; 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 _SendMessage($hWebView2_Window, $WM_SETREDRAW, False, 0) ; Disables ; https://www.autoitscript.com/forum/topic/199172-disable-gui-updating-repainting/ Return $idPic #EndRegion ; freeze $hWebView2_Window EndFunc ;==>__NetWebView2_freezer Func _NetWebView2_NavigateToPDF(ByRef $oWebV2M, $s_URL_or_FileFullPath, $hWebView2_Window = 0, $s_Parameters = '', $iSleep_ms = 1000) Local $idPic If FileExists($s_URL_or_FileFullPath) Then $s_URL_or_FileFullPath = StringReplace($s_URL_or_FileFullPath, ' ', '%20') $s_URL_or_FileFullPath = "file:///" & $s_URL_or_FileFullPath If $iSleep_ms Then $iSleep_ms -= 400 If $iSleep_ms < 600 Then $iSleep_ms = 600 EndIf EndIf If $s_Parameters Then $s_URL_or_FileFullPath &= $s_Parameters #TIP: FitToPage: https://stackoverflow.com/questions/78820187/how-to-change-webview2-fit-to-page-button-on-pdf-toolbar-default-to-fit-to-width#comment138971950_78821231 #TIP: Open desired PAGE: https://stackoverflow.com/questions/68500164/cycle-pdf-pages-in-wpf-webview2#comment135402565_68566860 EndIf If $hWebView2_Window Then $idPic = __NetWebView2_freezer($hWebView2_Window) _NetWebView2_Navigate($oWebV2M, $s_URL_or_FileFullPath) Sleep($iSleep_ms) If $hWebView2_Window Then __NetWebView2_freezer($hWebView2_Window, $idPic) EndIf EndFunc ;==>_NetWebView2_NavigateToPDF There is $iSleep_ms parameter which in case of local file should have shorter time in relation to showing online pdf file. Please check if you see any flickering/gliches with opening PDF Files so fast.
  2. 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.
  3. It is an options, but it will be fired at time, and not at demand.
  4. 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
  5. 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
  6. oh... Nice Thanks So we can use this also for: https://learn.microsoft.com/en-us/uwp/api/windows.data.json?view=winrt-26100
  7. Clean full example is here: https://github.com/ioa747/NetWebView2Lib/pull/41
  8. 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
  9. 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
  10. @jpm took everything into account (I have seen it I on SVN.) https://www.autoitscript.com/trac/autoit/ticket/4069#comment:2 Thanks @jpm
  11. 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)
  12. 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
  13. 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
  14. Please check out the _WinAPI_PrintWindow() function example in Windows 11. It doesn't work well for me.
  15. is'nt cdo.message end of life?
×
×
  • Create New...