Jump to content

mLipok

MVPs
  • Posts

    11,692
  • 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

29,120 profile views

mLipok's Achievements

  1. Thank you very much. I will have few questions. 1. Is this following part not required when the source and destination size will be the same ? ; Use HALFTONE for better quality when stretching/scaling during capture _WinAPI_SetStretchBltMode($hDC_Capture, $HALFTONE) 2. Why after using: Local Const $hObjectOld = _WinAPI_SelectObject($hMemDC, $hHBmp) there is a need to use it as a kind of revert _WinAPI_SelectObject($hMemDC, $hObjectOld) I understand it's about restoring/freeing/wiping, but reverting seems a bit odd to me. 3. about the cropping feature ; Optionally crop the bitmap to the visible window area, excluding shadow/frame margins If $bCrop Then Local $iLeft, $iTop, $iRight, $iBottom, $pX, $pY #forceref $pX, $pY ; Query the actual visible frame bounds via DWM to get the exact shadow margins Local $tRECT = _WinAPI_DwmGetWindowAttribute($hWnd, $DWMWA_EXTENDED_FRAME_BOUNDS) ; Calculate the margin on each side $iLeft = $tRECT.left - $aWinSize[0] $iTop = $tRECT.top - $aWinSize[1] $iRight = $aWinSize[0] + $aWinSize[2] - $tRECT.right $iBottom = $aWinSize[1] + $aWinSize[3] - $tRECT.bottom Local $hBitmap_Cropped = _GDIPlus_BitmapCloneArea($hBitmap, $iLeft, $iTop, $aWinSize[2] - $iLeft - $iRight, $aWinSize[3] - $iTop - $iBottom) _GDIPlus_BitmapDispose($hBitmap) $hBitmap = $hBitmap_Cropped EndIf If I have a window that contains an embedded IE control, WebView, DebenuViewer, or even simpler _WinAPI_CreateWindowEx(), that is, not the window created using GuiCreate() Then ... was it a case that the cropping is not needed ? I mean when will this be the case when user should to crop entire window ? btw. Question 1 and 3 are quite similar or even the same case.
  2. @UEZ Would you be so kind as to take a look at this code, perhaps improve it or add comments? Perhaps this will allow us to create a better example or improve the HelpFile. Anyway, thanks.
  3. _WinAPI_BitBlt HelpFile description for $iROP: do all these bold text fragments refer to: $hDestDC ?
  4. btw. Here is modified _WinAPI_PrintWindow.au3 example: #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 $hPicture_Control = GUICtrlGetHandle($idPic) Local $hPicture_DC = _WinAPI_GetDC($hPicture_Control) ; Create destination bitmap Local $hDestination_Bitmap = _WinAPI_CreateCompatibleBitmap($hPicture_DC, $aSize[2], $aSize[3]) Local $hDestination_DC = _WinAPI_CreateCompatibleDC($hPicture_DC) Local $hDestination_Sv = _WinAPI_SelectObject($hDestination_DC, $hDestination_Bitmap) ; Create source bitmap Local $hSource_Bitmap = _WinAPI_CreateCompatibleBitmap($hPicture_DC, $aSize[2], $aSize[3]) Local $hSource_DC = _WinAPI_CreateCompatibleDC($hPicture_DC) Local $hSource_Sv = _WinAPI_SelectObject($hSource_DC, $hSource_Bitmap) Local Const $PW_RENDERFULLCONTENT = 0x2 ; this will go to where it should =) _WinAPI_PrintWindow($hWnd, $hSource_DC, $PW_RENDERFULLCONTENT) _WinAPI_BitBlt($hDestination_DC, 0, 0, $aSize[2], $aSize[3], $hSource_DC, 0, 0, $MERGECOPY) _WinAPI_ReleaseDC($hPicture_Control, $hPicture_DC) #Region ; CleanUp _WinAPI_SelectObject($hDestination_DC, $hDestination_Sv) _WinAPI_DeleteDC($hDestination_DC) _WinAPI_SelectObject($hSource_DC, $hSource_Sv) _WinAPI_DeleteDC($hSource_DC) _WinAPI_DeleteObject($hSource_Bitmap) #EndRegion ; CleanUp ; Set bitmap to control _SendMessage($hPicture_Control, $STM_SETIMAGE, 0, $hDestination_Bitmap) Local $hObj = _SendMessage($hPicture_Control, $STM_GETIMAGE) If $hObj <> $hDestination_Bitmap Then _WinAPI_DeleteObject($hDestination_Bitmap) EndIf GUISetState(@SW_SHOW) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE WinClose($hWnd, "") EndFunc ;==>_Example
  5. It's almost like me Maybe the GDI master could answer... let's see if @UEZ knows the answers ?
  6. yeap btw. Why _WinAPI_BitBlt() was used - and in my scenario it is not needed ?
  7. In relation to: @argumentum and @Nine could you be so nice and check mine modification from: https://github.com/ioa747/NetWebView2Lib/pull/104/changes Func __NetWebView2_freezer($oWebV2M, ByRef $idPic) Local $hWindow_WebView2 = WinGetHandle($oWebV2M.BrowserWindowHandle) #Region ; if $idPic is given then it means you already have it and want to delete it - unfreeze - show WebView2 content If $idPic Then WinSetState($hWindow_WebView2, '', @SW_SHOW) GUICtrlDelete($idPic) $idPic = 0 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 $hWindow_WebView2 #Region ; add PIC to parent window Local $hWindow_Parent = WinGetHandle($oWebV2M.ParentWindowHandle) Local $aPos = WinGetPos($hWindow_WebView2) Local $hPrev = GUISwitch($hWindow_Parent) $idPic = GUICtrlCreatePic('', 0, 0, $aPos[2], $aPos[3]) Local $hPic = GUICtrlGetHandle($idPic) GUISwitch($hPrev) #EndRegion ; add PIC to parent window Local $hPictureDC = _WinAPI_GetDC($hPic) ; Create Dest bitmap Local $hDestination_DC = _WinAPI_CreateCompatibleDC($hPictureDC) ; Creates a memory device context compatible with the specified device Local $hDestination_Bitmap = _WinAPI_CreateCompatibleBitmap($hPictureDC, $aPos[2], $aPos[3]) ; Creates a bitmap compatible with the specified device context Local $hDestination_Sv = _WinAPI_SelectObject($hDestination_DC, $hDestination_Bitmap) ; Selects an object into the specified device context _WinAPI_PrintWindow($hWindow_WebView2, $hDestination_DC, 2) _WinAPI_ReleaseDC($hPic, $hPictureDC) _WinAPI_SelectObject($hDestination_DC, $hDestination_Sv) _WinAPI_DeleteDC($hDestination_DC) ; Set bitmap to control _SendMessage($hPic, $STM_SETIMAGE, 0, $hDestination_Bitmap) _WinAPI_DeleteObject($hDestination_Bitmap) WinSetState($hWindow_WebView2, '', @SW_HIDE) Return $idPic #EndRegion ; freeze $hWindow_WebView2 EndFunc ;==>__NetWebView2_freezer I reduced the code by 11 lines. I wonder why the earlier version uses two bitmaps? Can someone enlighten me? EDIT: Earlier version: #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
  8. not here... sorry
  9. finall version: Example() Func Example() ; Declare a map and assign with various keys value pairs. Local $mMap[] $mMap[1] = "Integer One" ; Integer value as a key. $mMap["2"] = "String Two" ; String value representing an integer as a key. This is a string not an integer. MapAppend($mMap, "Integer Two") ; Append a value using the next available integer, which is 2 in this case. $mMap.test = 'testing' ; Dot notation equivalent to $mMap["test"] = "testing" ; Retrieve the keys contained in the map. A zero-based one-dimensional array is returned. Local $aMapKeys = MapKeys($mMap) For $vKey In $aMapKeys ; Or a For loop can be used as well. ConsoleWrite(@CRLF & _ '> Key: ' & $vKey & @CRLF & _ ; The key. '> Key Type: ' & VarGetType($vKey) & @CRLF & _ ; Display the variable type of the key i.e. integer or string. '> Key Value: "' & $mMap[$vKey] & '"' & @CRLF & _ ; Use the array value of MapKeys() to display the value of the key. '') Next EndFunc ;==>Example
  10. #include <MsgBoxConstants.au3> Example() Func Example() ; Declare a map and assign with various keys value pairs. Local $mMap[] $mMap[1] = "Integer One" ; Integer value as a key. $mMap["2"] = "String Two" ; String value representing an integer as a key. This is a string not an integer. MapAppend($mMap, "Integer Two") ; Append a value using the next available integer, which is 2 in this case. $mMap.test = 'testing' ; ; Retrieve the keys contained in the map. A zero-based one-dimensional array is returned. Local $aMapKeys = MapKeys($mMap) For $vKey In $aMapKeys ; Or a For loop can be used as well. ConsoleWrite(@CRLF & _ '> Key: ' & $vKey & @CRLF & _ ; The key. '> Key Type: ' & VarGetType($vKey) & @CRLF & _ ; Display the variable type of the key i.e. integer or string. '> Key Value: "' & $mMap[$vKey] & '"' & @CRLF & _ ; Use the array value of MapKeys() to display the value of the key. '') Next EndFunc ;==>Example please suggest comment for: $mMap.test = 'testing' ;
  11. Original MapKeys() example: #include <MsgBoxConstants.au3> Example() Func Example() ; Declare a map and assign with various keys value pairs. Local $mMap[] $mMap[1] = "Integer One" ; Integer value as a key. $mMap["2"] = "String Two" ; String value representing an integer as a key. This is a string not an integer. MapAppend($mMap, "Integer Two") ; Append a value using the next available integer, which is 2 in this case. ; Retrieve the keys contained in the map. A zero-based one-dimensional array is returned. Local $aMapKeys = MapKeys($mMap) For $vKey In $aMapKeys ; Or a For loop can be used as well. MsgBox($MB_SYSTEMMODAL, "", "Key: " & $vKey & @CRLF & _ ; The key. "Value: " & $mMap[$vKey] & @CRLF & _ ; Use the array value of MapKeys() to display the value of the key. "Variable Type: " & VarGetType($vKey) & @CRLF) ; Display the variable type of the key i.e. integer or string. Next EndFunc ;==>Example proposal: #include <MsgBoxConstants.au3> Example() Func Example() ; Declare a map and assign with various keys value pairs. Local $mMap[] $mMap[1] = "Integer One" ; Integer value as a key. $mMap["2"] = "String Two" ; String value representing an integer as a key. This is a string not an integer. MapAppend($mMap, "Integer Two") ; Append a value using the next available integer, which is 2 in this case. $mMap.test = 'testing' ; ; Retrieve the keys contained in the map. A zero-based one-dimensional array is returned. Local $aMapKeys = MapKeys($mMap) For $vKey In $aMapKeys ; Or a For loop can be used as well. MsgBox($MB_SYSTEMMODAL, "", _ "Key: " & $vKey & @CRLF & _ ; The key. "Key Type: " & VarGetType($vKey) & @CRLF & _ ; Display the variable type of the key i.e. integer or string. "Key Value: " & $mMap[$vKey] & @CRLF & _ ; Use the array value of MapKeys() to display the value of the key. "") Next EndFunc ;==>Example please suggest comments for: $mMap.test = 'testing' ; Any comments are welcome.
  12. https://github.com/ioa747/NetWebView2Lib/issues/91
  13. Not knowing how. You can think as this is not supported yet, but this is only a matter of time to get knowing how to do it.
  14. Hello my friends Please take a look here: https://www.autoitscript.com/trac/autoit/ticket/4070 What do you think ?
  15. Today thanks to @ioa747 I hit something new to me. You can create many Event Handlers for the same Object. Did you know that ? Here is modified example: ObjEvent.au3 #include <MsgBoxConstants.au3> Example() Func Example() ; Error monitoring. This will trap all COM errors while alive. ; This particular object is declared as local, meaning after the function returns it will not exist. Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") ; Create Internet Explorer object Local $oIE = ObjCreate("InternetExplorer.Application") ; Check for errors If @error Then Return $oIE.Visible = True ; set visibility ; Custom sink object Local $oIEEvents_1 = ObjEvent($oIE, "_IEEvent_1_", "DWebBrowserEvents2") Local $oIEEvents_2 = ObjEvent($oIE, "_IEEvent_2_", "DWebBrowserEvents2") ; Navigate somewhere $oIE.navigate("http://www.google.com/") ; Check for errors while loading If @error Then $oIE.Quit() Return EndIf ; Wait for page to load While 1 If $oIE.readyState = "complete" Or $oIE.readyState = 4 Then ExitLoop Sleep(10) WEnd ; Deliberately cause error by calling non-existing method $oIE.PlayMeARockAndRollSong() ; Check for errors If @error Then MsgBox($MB_SYSTEMMODAL, "COM Error", "@error is set to COM error number." & @CRLF & "@error = 0x" & Hex(@error)) ; Wait few seconds to see if more events will be fired Sleep(3000) ; Nothing more to do. Close IE and return from the function $oIE.Quit() #forceref $oErrorHandler, $oIEEvents_1, $oIEEvents_2 EndFunc ;==>Example ; BeforeNavigate2 method definition Func _IEEvent_1_BeforeNavigate2($oIEpDisp, $sIEURL, $iIEFlags, $sIETargetFrameName, $sIEPostData, $iIEHeaders, $bIECancel) ConsoleWrite("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!--_IEEvent_1_BeforeNavigate2() fired--!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " & @CRLF & _ "$oIEpDisp = " & $oIEpDisp() & " - " & ObjName($oIEpDisp) & @CRLF & _ ; e.g. default property and name for the object "$sIEURL = " & $sIEURL & @CRLF & _ "$iIEFlags = " & $iIEFlags & @CRLF & _ "$sIETargetFrameName = " & $sIETargetFrameName & @CRLF & _ "$sIEPostData = " & $sIEPostData & @CRLF & _ "$iIEHeaders = " & $iIEHeaders & @CRLF & _ "$bIECancel = " & $bIECancel & @CRLF & _ "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " & @CRLF & @CRLF) EndFunc ;==>_IEEvent_BeforeNavigate2 Func _IEEvent_2_BeforeNavigate2($oIEpDisp, $sIEURL, $iIEFlags, $sIETargetFrameName, $sIEPostData, $iIEHeaders, $bIECancel) ConsoleWrite("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!--_IEEvent_2_BeforeNavigate2() fired--!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " & @CRLF & _ "$oIEpDisp = " & $oIEpDisp() & " - " & ObjName($oIEpDisp) & @CRLF & _ ; e.g. default property and name for the object "$sIEURL = " & $sIEURL & @CRLF & _ "$iIEFlags = " & $iIEFlags & @CRLF & _ "$sIETargetFrameName = " & $sIETargetFrameName & @CRLF & _ "$sIEPostData = " & $sIEPostData & @CRLF & _ "$iIEHeaders = " & $iIEHeaders & @CRLF & _ "$bIECancel = " & $bIECancel & @CRLF & _ "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " & @CRLF & @CRLF) EndFunc ;==>_IEEvent_BeforeNavigate2 ; User's COM error function. Will be called if COM error occurs Func _ErrFunc($oError) ; Do anything here. ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_ErrFunc
×
×
  • Create New...