;-- TIME_STAMP 2020-11-19 16:13:36 v 0.1 #include-once #include #include ; Opera@USB für Windows v12.18 ; DL: https://www.netzwelt.de/software-download/26792-opera-usb.html ; only 1 embedded window is possible ; ".\Opera\profile\operaprefs.ini" - if something fails with the view: delete the profile folder, a new one will created ; and disable all bars and menus in config menu (right click in opened opera window) Opt('MustDeclareVars', 1) OnAutoItExitRegister('_OperaEmbedded_Exit') Global Const $gc_PathBrowser = @ScriptDir & '\Opera\Opera.exe' Global $g_PathTempHtml = @TempDir & '\OperaEmbeddedTemp.html' Global $g_hOperaEmbedded, $g_hMain, $g_PID = Null Func _OperaEmbedded_Exit() If $g_PID = Null Then Exit FileDelete($g_PathTempHtml) WinClose($g_hOperaEmbedded) ProcessClose($g_PID) EndFunc ; negative values (width/height) treated as: difference of client.width/height minus value Func _OperaEmbedded_Create($_hParent, $_x, $_y, $_w=Default, $_h=Default, $_bBorder=False) Local Static $bActive = False If $bActive Then Return SetError(1,0,0) ; only one instance possible Else $bActive = True EndIf $g_hMain = $_hParent $g_PID = @AutoItPID _OperaEmbedded_CreateHtml('', '', False) ; empty file for start __OperaEmbedded_StartHidden() Local $iStyle = $_bBorder ? (BitOr($WS_CHILD,$WS_BORDER)) : $WS_CHILD _WinAPI_SetParent($g_hOperaEmbedded, $g_hMain) ; set style fails sometimes (don't know why) - do it in a loop until successfully Do Sleep(10) Until _WinAPI_SetWindowLong($g_hOperaEmbedded, $GWL_STYLE, $iStyle) <> 0 _WinAPI_SetWindowLong($g_hOperaEmbedded, $GWL_EXSTYLE, $WS_EX_MDICHILD) Local $clientWidth = _WinAPI_GetClientWidth($g_hMain) Local $clientHeight = _WinAPI_GetClientHeight($g_hMain) If $_w < 0 Then $_w = $clientWidth - Abs($_w) ElseIf $_w > $clientWidth Or $_w = Default Then $_w = $clientWidth EndIf If $_h < 0 Then $_h = $clientHeight - Abs($_h) ElseIf $_h > $clientHeight Or $_h = Default Then $_h = $clientHeight EndIf WinMove($g_hOperaEmbedded, '', $_x, $_y, $_w, $_h) EndFunc Func _OperaEmbedded_CreateHtml($_Body='', $_Style=-1, $_JS=-1, $_bRefresh=True) Local Static $sStyle = '', $sJS = '' If $_Style <> -1 Then $sStyle = $_Style If $_JS <> -1 Then $sJS = $_JS Local $sHtml = '' & _ '' & _ 'OperaEmbeddedWindow' & _ ; title is invisible but fix for window detection '' & _ '' & _ '' & $_Body & '' & @CRLF Local $fH = FileOpen($g_PathTempHtml, 8+2) FileWrite($fH, $sHtml) FileClose($fH) If $_bRefresh Then _OperaEmbedded_RefreshView() EndFunc Func _OperaEmbedded_HtmlFromFile($_sFileHtml, $_aReplaces=Null) Local $sHtml = FileRead($_sFileHtml) $sHtml = StringRegExpReplace($sHtml, '[^<]+<', '<title>OperaEmbeddedWindow<', 1) If IsArray($_aReplaces) Then For $i = 0 To UBound($_aReplaces) -1 $sHtml = StringReplace($sHtml, $_aReplaces[$i][0], $_aReplaces[$i][1]) Next EndIf Local $fH = FileOpen($g_PathTempHtml, 8+2+512) ; ANSI mode FileWrite($fH, $sHtml) FileClose($fH) EndFunc Func _OperaEmbedded_Show($_iState=@SW_SHOWNA) _WinAPI_ShowWindow($g_hOperaEmbedded, $_iState) EndFunc Func _OperaEmbedded_RefreshView() WinActivate($g_hOperaEmbedded) WinWaitActive($g_hOperaEmbedded, 5) Send("{F5}") WinSetState($g_hOperaEmbedded, '', @SW_SHOWNA) WinActivate($g_hMain) EndFunc Func __OperaEmbedded_StartHidden() ShellExecute($gc_PathBrowser, $g_PathTempHtml, @TempDir, '', @SW_HIDE) Local $optOld = Opt('WinTitleMatchMode', 2) $g_hOperaEmbedded = WinWait('OperaEmbeddedWindow') Opt('WinTitleMatchMode', $optOld) EndFunc