Jump to content

Microsoft Edge - WebView2, embed web code in your native application


mLipok
 Share

Recommended Posts

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

@LarsJ and others.
Is it good time to start separate GitHub project for this our project to have cohesive UDFs ?

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

1 hour ago, KaFu said:

Edit2:

Do you assume that "Shell.Explorer.2" will not work on Win11, or did you try it? I'm still on Win10, but search results indicate it still should work,

Try it:

#include <Clipboard.au3>
#include <IE.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
;Coded by UEZ 2011 - beta version

If @OSBuild < 6000 Then Exit MsgBox(16, "Error!", "Script is running only on Vista+ os properly!", 10)

;https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/general-info/ee330730(v=vs.85)
RegRead("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", @ScriptName)
If @error Then RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", @ScriptName, "REG_DWORD", 11001)


Global Const $hDwmApiDll = DllOpen("dwmapi.dll")
Global $sChkAero = DllStructCreate("int;")
DllCall($hDwmApiDll, "int", "DwmIsCompositionEnabled", "ptr", DllStructGetPtr($sChkAero))
Global $aero = DllStructGetData($sChkAero, 1)
DllClose($hDwmApiDll)
If Not $aero Then Exit MsgBox(16, "Error", "Aero must be enabled to grab web sites properly!", 20)
$sChkAero = 0

Global $URL, $btn, $msg, $hWnd, $input, $i
$hWnd = GUICreate("Save Web Page as an image", 320, 120)
$input = GUICtrlCreateInput("https://focus.de", 10, 5, 300, 20)
$btn = GUICtrlCreateButton("Ok", 40, 35, 240, 70)
ControlFocus($hWnd, "", $btn)
GUISetState()

While $msg <> -3
    $msg = GUIGetMsg()
    Select
        Case $msg = $btn
            Start()
        Case $msg = -3
            GUIDelete($hWnd)
            Exit
    EndSelect
WEnd

Func Start()
    $URL = GUICtrlRead($input)
    SplashTextOn("Screenshooting Web Site", "Please wait while taking screenshot", 300, 40, -1, -1, 1 + 2 + 4 + 32, "")
    AdlibRegister("Wait", 300)
    Web_Screenshot($URL)
    AdlibUnRegister("Wait")
    SplashOff()
    MsgBox(0, "Information", "Web Site Image copied to clipboard!", 10)
EndFunc

Func Web_Screenshot($url, $IEwidth = 1045)
    Local $oIE, $GUIActiveX, $oDocument,  $oBody, $BodyWidth, $BodyHeight, $oHtml
    Local $hGUI_WebGrab, $hWin, $aWin, $aMP
    Local Const $BrowserNavConstant = 2 + 256 + 2048 ;BrowserNavConstant -> http://msdn.microsoft.com/en-us/library/dd565688(v=vs.85).aspx
    $oIE = ObjCreate("Shell.Explorer.2") ;http://msdn.microsoft.com/en-us/library/aa752084(v=vs.85).aspx

    $hWin = WinGetHandle("Program Manager")
    $aWin = WinGetPos($hWin)

    #region render web site to get height
    $hGUI_WebGrab = GUICreate("",  0, 0, $aWin[0] - $BodyWidth + 1, $aWin[1] - $BodyHeight + 1, BitOR($WS_CLIPSIBLINGS, $WS_CLIPCHILDREN, $WS_POPUP),Default, WinGetHandle(AutoItWinGetTitle()))
;~  $hGUI_WebGrab = GUICreate("",  1024, 768, 0, 0, BitOR($WS_CLIPSIBLINGS, $WS_CLIPCHILDREN, $WS_POPUP),Default, WinGetHandle(AutoItWinGetTitle()))
    $GUIActiveX = GUICtrlCreateObj($oIE, 0, 0, $IEwidth, 256)
    GUISetState(@SW_MINIMIZE, $hGUI_WebGrab)
;~  GUISetState(@SW_SHOW, $hGUI_WebGrab)


    Local $timeout = 30 * 1000
    Local $timer = TimerInit()
    With $oIE
        .Silent = True
        .FullScreen = True
        .Resizable = False
        .Visible = False
        .StatusBar = False
        .AddressBar = False
        .Navigate($URL, $BrowserNavConstant, "_top")
        Do
            If TimerDiff($timer) > $timeout Then ExitLoop
            Sleep(100)
        Until $oIE.ReadyState = 4
        .Stop
        Sleep(500)
    EndWith
    $oDocument = $oIE.document
    $oBody = $oDocument.body
    $oBody.scroll = "no"
    $oBody.style.borderStyle = "none"
    $BodyWidth = $oBody.scrollWidth ;Min($oBody.scrollWidth, 4096)
    $BodyHeight = $oBody.scrollHeight ;Min($oBody.scrollHeight, 8192)
    GUIDelete($hGUI_WebGrab)
    $GUIActiveX = 0
    #endregion

    Local $IE_Ver = RegRead("HKLM\SOFTWARE\Microsoft\Internet Explorer", "Version"), $height
;~  If $IE_Ver > 8 Then $BodyHeight = Min($BodyHeight, 8192)

;~  ConsoleWrite($oIE.Path & @CRLF)

;~  $hGUI_WebGrab = GUICreate("",  $BodyWidth,  $BodyHeight, $aWin[0] - $BodyWidth + 10, $aWin[1] - $BodyHeight + 10, BitOR($WS_CLIPSIBLINGS, $WS_CLIPCHILDREN, $WS_POPUP), Default, WinGetHandle(AutoItWinGetTitle()))
    $hGUI_WebGrab = GUICreate("",  $BodyWidth,  $BodyHeight, -1, -1, $WS_POPUP, $WS_EX_TOPMOST)
    GUISetState(@SW_SHOW, $hGUI_WebGrab) ;Show GUI for some milli seconds to make a screenshot
    $GUIActiveX = GUICtrlCreateObj ($oIE, 0, 0, $BodyWidth,  $BodyHeight)

    $timer = TimerInit()
    With $oIE
        .Silent = True
        .FullScreen = True
        .Resizable = False
        .Visible = False
        .StatusBar = False
        .AddressBar = False
        .Navigate($URL, $BrowserNavConstant, "_top")
        Do
            If TimerDiff($timer) > $timeout Then ExitLoop
            Sleep(100)
        Until $oIE.ReadyState = 4
        .Stop
        Sleep(1000)
    EndWith

    $oDocument = $oIE.document
    $oBody =$oDocument.body
    $oHtml = $oDocument.documentElement
    $oBody.scroll = "no"
    $oBody.style.borderStyle = "none"
    $oBody.style.border = "0px"
    $oHtml.style.overflow = 'hidden'

    GUISetState(@SW_SHOW, $hGUI_WebGrab)      ;Show GUI

    Local $hDC = _WinAPI_GetWindowDC($hGUI_WebGrab)
    Local $hDC_Dummy = _WinAPI_GetWindowDC(0)
    Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC_Dummy)
    Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC_Dummy, $BodyWidth, $BodyHeight)

;~  Local $tBIV5HDR = DllStructCreate($tagBITMAPINFOHEADER)
;~  DllStructSetData($tBIV5HDR, 'biSize', DllStructGetSize($tBIV5HDR))
;~  DllStructSetData($tBIV5HDR, 'biWidth', $BodyWidth)
;~  DllStructSetData($tBIV5HDR, 'biHeight', -$BodyHeight)
;~  DllStructSetData($tBIV5HDR, 'biPlanes', 1)
;~  DllStructSetData($tBIV5HDR, 'biBitCount', 32)
;~  DllStructSetData($tBIV5HDR, 'biCompression', $BI_RGB)
;~  Local $pBits
;~  Local $hBitmap = _WinAPI_CreateDIBSection(0, $tBIV5HDR, $DIB_RGB_COLORS, $pBits)

    _WinAPI_SelectObject($hMemDC, $hBitmap)
    _WinAPI_BitBlt($hMemDC, 0, 0, $BodyWidth, $BodyHeight, $hDC, 0, 0, $SRCCOPY)
    ;ConsoleWrite(_WinAPI_StretchDIBits($hMemDC, 0, 0, $BodyWidth, $BodyHeight, 0, 0, $BodyWidth, $BodyHeight, $tBIV5HDR, $DIB_RGB_COLORS, $pBits, $SRCCOPY) & @CRLF)

    _WinAPI_DeleteDC($hMemDC)
    _WinAPI_ReleaseDC($hGUI_WebGrab, $hDC)
    _WinAPI_ReleaseDC(0, $hDC_Dummy)
    _WinAPI_ReleaseDC(0, $hDC)

    _ClipBoard_Open(0)
    _ClipBoard_Empty()
    _ClipBoard_SetDataEx($hBitmap, $CF_BITMAP)
    _ClipBoard_Close()
    _WinAPI_DeleteObject ($hBitmap)

    $GUIActiveX = 0
    $oIE = 0
    GUIDelete($hGUI_WebGrab)
    _ReduceMemory()
EndFunc

Func Min($a, $b)
    If $a < $b Then Return $a
    Return $b
EndFunc

Func Wait()
    Switch Mod($i, 4)
        Case 0
            ControlSetText("Screenshooting Web Site", "", "Static1", "Please wait while taking screenshot")
        Case 1
            ControlSetText("Screenshooting Web Site", "", "Static1", "Please wait while taking screenshot .")
        Case 2
            ControlSetText("Screenshooting Web Site", "", "Static1", "Please wait while taking screenshot ..")
        Case 3
            ControlSetText("Screenshooting Web Site", "", "Static1", "Please wait while taking screenshot ...")
    EndSwitch
    $i += 1
EndFunc

Func _ReduceMemory($ProcID = 0)
    If $ProcID = 0 or ProcessExists($ProcID) = 0 Then ; No process id specified or process doesn't exist - use current process instead.
        Local $ai_GetCurrentProcess = DllCall('kernel32.dll', 'ptr', 'GetCurrentProcess')
        Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'ptr', $ai_GetCurrentProcess[0])
        Return $ai_Return[0]
    EndIf
    Local $ai_Handle = DllCall("kernel32.dll", 'ptr', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $ProcID)
    Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'ptr', $ai_Handle[0])
    DllCall('kernel32.dll', 'int', 'CloseHandle', 'ptr', $ai_Handle[0])
    Return $ai_Return[0]
EndFunc

It works but result is not good because based on IE engine.

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Related interesting YouTube channel:

https://www.youtube.com/@MSFTEdge

for example:

 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

Too bad all of that is locked behind Microsoft's downstream Edge browser filled with trackers 🤬.

This is why we need copyleft licenses like GPL, so that companies can't just leech off of good open-source work, make a few improvements and sell that off as their own product :angry:

Also the JSON viewer is a joke, Firefox has had a much better viewer since forever and you don't even need to enable it with a flag :P

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...