Jump to content

mLipok

MVPs
  • Posts

    11,663
  • 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,831 profile views

mLipok's Achievements

  1. Clean full example is here: https://github.com/ioa747/NetWebView2Lib/pull/41
  2. 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
  3. 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
  4. @jpm took everything into account (I have seen it I on SVN.) https://www.autoitscript.com/trac/autoit/ticket/4069#comment:2 Thanks @jpm
  5. 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)
  6. 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
  7. 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
  8. Please check out the _WinAPI_PrintWindow() function example in Windows 11. It doesn't work well for me.
  9. is'nt cdo.message end of life?
  10. 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
  11. Thanks for findings. Reported: https://www.autoitscript.com/trac/autoit/ticket/4067#ticket
  12. Today I was in need to study about _WinAPI_EnumWindow***() functions I stick with questions about _WinAPI_EnumWindowStations() Accordingly to https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-enumwindowstationsa : So I run this example _WinAPI_EnumWindowStations.au3 and nothing happens. Thus my questions: 1. What "window stations in the current session" means ? and 2. Why _WinAPI_EnumWindowStations() doesn't return any array in my case ? Regards mLipok
  13. I just worked on 4-FileViewerDemo.au3 and I hit AutoIt problem with GUI redrawing window. Here is my modified version of 4-FileViewerDemo.au3 : #AutoIt3Wrapper_UseX64=y #include <GUIConstantsEx.au3> #include <SendMessage.au3> #include <WinAPIGdi.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) $oWebV2M.LockWebView() GUISetState(@SW_LOCK, $hGUI) $s_PDF_FileFullPath = "file:///" & @ScriptDir & '/FileViewerDemo_2.pdf' _NetWebView2_Navigate($oWebV2M, $s_PDF_FileFullPath) Sleep(5000) GUISetState(@SW_UNLOCK, $hGUI) MsgBox($MB_TOPMOST, "LOCK/UNLOCK TEST #" & @ScriptLineNumber, $s_PDF_FileFullPath, 0, $hGUI) _SendMessage($hGUI, $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($hGUI, $WM_SETREDRAW, True, 0) ; Enables _WinAPI_RedrawWindow($hGUI, 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 To get this worked take a look here: https://github.com/ioa747/NetWebView2Lib Question 1: GUISetState(@SW_LOCK, $hGUI) ..... GUISetState(@SW_UNLOCK, $hGUI) It doesn't work as I would expect thus my question is: Why does the PDF content appear immediately and not after 5 seconds? GUISetState(@SW_LOCK, $hGUI) $s_PDF_FileFullPath = "file:///" & @ScriptDir & '/FileViewerDemo_2.pdf' _NetWebView2_Navigate($oWebV2M, $s_PDF_FileFullPath) Sleep(5000) GUISetState(@SW_UNLOCK, $hGUI) MsgBox($MB_TOPMOST, "LOCK/UNLOCK TEST #" & @ScriptLineNumber, $s_PDF_FileFullPath, 0, $hGUI) Question 2: In this part _SendMessage($hGUI, $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($hGUI, $WM_SETREDRAW, True, 0) ; Enables _WinAPI_RedrawWindow($hGUI, 0, 0, BitOR( $RDW_FRAME, $RDW_INVALIDATE, $RDW_ALLCHILDREN)) ; Repaints MsgBox($MB_TOPMOST, "$WM_SETREDRAW TEST #" & @ScriptLineNumber, $s_PDF_FileFullPath, 0, $hGUI) REDRAW is set to Falase on entire GUI window created by AutoIt How to stop REDRAWing only "Pane: WindowsForms10.Window.8.app.0.297b065_r18_ad1" ? AutoIt GUI with embeded WebView: UIASpy detect it this way: Queston 3: Why this following part hides the WebView2 embeded element instead only prevent to repaint them ? and Queston 4: Why I see FileViewerDemo_2.pdf on the Blue line/bar ? _SendMessage($hGUI, $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($hGUI, $WM_SETREDRAW, True, 0) ; Enables _WinAPI_RedrawWindow($hGUI, 0, 0, BitOR( $RDW_FRAME, $RDW_INVALIDATE, $RDW_ALLCHILDREN)) ; Repaints MsgBox($MB_TOPMOST, "$WM_SETREDRAW TEST #" & @ScriptLineNumber, $s_PDF_FileFullPath, 0, $hGUI)
  14. Thank you. My version was a case study of sorts, a proof of concept that it could be achieved this way. I'm curious if anyone can solve my list:
  15. Interesting Here is my variation. #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GuiEdit.au3> #include <WindowsConstants.au3> #include <String.au3> Global $idInput = -1 Test2() Exit Func Test2() Local $hgui = GUICreate("USPS thing", 300, 100) #forceref $hgui $idInput = GUICtrlCreateInput("", 20, 35, 260, 20) GUICtrlSetLimit(-1, 27) ; 22 digits + 5 spaces GUISetState() GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") While 1 If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit WEnd EndFunc ;==>Test2 Func _WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $lParam Local $iIDFrom = BitAND($wParam, 0xFFFF) Local $iCode = BitShift($wParam, 16) If $iIDFrom = $idInput And $iCode = $EN_CHANGE Then Local $aSel = _GUICtrlEdit_GetSel($idInput) Local $iPos = $aSel[0] Local $sCurrent = GUICtrlRead($idInput) ; 1. REGEX: Remove everything that is NOT a digit [^0-9] Local $sClean = StringRegExpReplace($sCurrent, "[^0-9]", "") Local Static $sEmptyMask = '*********************' $sClean = $sClean & StringLeft($sEmptyMask, 21 - StringLen($sClean)) ; 2. REGEX: Insert space every 4 digits ; Local $sFormatted = StringRegExpReplace($sClean, "(.{4})", "$1 ") Local $sFormatted = StringRegExpReplace($sClean, ".{4}", "$0.") $sFormatted = StringStripWS($sFormatted, 2) ; Remove trailing space If $sCurrent <> $sFormatted Then GUICtrlSetData($idInput, $sFormatted) ; 3. Adjust cursor position if text length changed If StringLen($sFormatted) > StringLen($sCurrent) Then $iPos += 1 If StringLen($sFormatted) < StringLen($sCurrent) Then $iPos -= 1 _GUICtrlEdit_SetSel($idInput, $iPos, $iPos) EndIf EndIf Return $GUI_RUNDEFMSG EndFunc ;==>_WM_COMMAND ISSUES / TODO : to use 22 * not 21 to see all * at start to works well when you type numbers to works well when you use delete/backspace key
×
×
  • Create New...