Jump to content

Recommended Posts

Posted

..in that regard, I was thinking of giving that a link like "AutoIt3chm://go+do+something.au3" and since is a link, the handler would take care of that. And that would mean that the .chm file would need the "AutoIt3Help.exe" to be the handler or load one.
Lack of time did not let me code it to present a proposal.

But maybe you can code a "SayYesAndSaveMeTheTime.au3" 😅

P.S.: I don't know of a way to configure for just that. :( 

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Posted
3 hours ago, argumentum said:

But maybe you can code a "SayYesAndSaveMeTheTime.au3"

Nah, not that cumbersome.  But what is very annoying is the MSDN external link.  I know it is off topic, but it is my thread after all :).  I am using this piece of code to get to an external MSDN link (until argy makes a no problem chm...)

Just right click the link and it will show in you default browser :

#include "Includes\CUIAutomation2.au3"
#include <WinAPIvkeysConstants.au3>
#include <Misc.au3>

HotKeySet("{F11}", Terminate)

While Sleep(10)
  If WinActive("AutoIt Help") And _IsPressed($VK_RBUTTON) Then RunLink()
WEnd

Func Terminate()
  Exit
EndFunc   ;==>Terminate

Func RunLink()
  Sleep(200)
  MouseClick("left", MouseGetPos(0) + 10, MouseGetPos(1) + 20, 1, 1)
  Sleep(500)
  If Not WinActive("Propriétés") Then Return

  ; Create UI Automation object
  Local Static $oUIAutomation = ObjCreateInterface($sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation)
  Local $pElement, $oElement, $oProp, $vValue, $pCondition

  ; Get element by handle
  $oUIAutomation.ElementFromHandle(WinGetHandle("[ACTIVE]"), $pElement)
  $oProp = ObjCreateInterface($pElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement)
  $oUIAutomation.CreatePropertyCondition($UIA_AutomationIdPropertyId, "_nameProp", $pCondition)
  $oProp.FindFirst($TreeScope_Descendants, $pCondition, $pElement)
  $oElement = ObjCreateInterface($pElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement)
  $oElement.GetCurrentPropertyValue($UIA_ValueValuePropertyId, $vValue)
  Send("{ESC}")
  ShellExecute("http://msdn.microsoft.com/query/" & $vValue)
EndFunc   ;==>RunLink

Not the greatest piece of code, but it does what I want.

Posted (edited)
4 hours ago, Nine said:

I am using this piece of code to get to an external MSDN link (until argy makes a no problem chm...)

My bad ( not kidding ).
Made a patch but no body looked at it.
And I'd have to get in a "Zen state of mind" to implement it in the SVN, but am doing a bunch of other things 😭

But yes, the "open in user's default browser" is no big deal.
I'll brainstorm the "run local file" in a "don't warn me, just do it" way. Maybe using the CSS file as the DB 🤔
But again, I'll have to have the peace of mind to look into it 🤷‍♂️

Edited by argumentum

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

  • 2 weeks later...
Posted (edited)

I just entered the club, of the windows11  😭

; https://www.autoitscript.com/forum/topic/213285-autoitchm-with-windows-11/#findComment-1547194
;----------------------------------------------------------------------------------------
; Title...........: Active_Help.au3
; Description.....: Inject a custom .CSS file into help (Dark theme)
;                   closes the annoying notification MsgBox
;                   opens MSDN links with right click (for quick Navigation)
;                   opens MSDN links with left click  (In case you forget)
; AutoIt Version..: 3.3.18.0   Author: ioa747           Script Version: 0.2
; Note............: Testet in Windows 11 Pro 24H2       Date:4/11/2025
;----------------------------------------------------------------------------------------
;~ #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7
#NoTrayIcon
#include <IE.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>

Global $g_ObjErr = ObjEvent("AutoIt.Error", "__ObjAutoItErrorEvent")
Global $oIE
Global $sMyCSS = FileRead(@ScriptDir & "\default.css") ; Your custom CSS file

While 1
    InjectHelp()
    Sleep(300)
WEnd

;---------------------------------------------------------------------------------------
Func _CheckForMSDN_RB() ; opens MSDN links with right click (for quick Navigation)
    If Not WinActive("AutoIt Help") Then Return
    If MouseGetCursor() = 0 Then ; 0=Hand ; 2=Arrow
        If _IsPressed("02") Then ; 02=Right mouse button
            Local $aMPos = MouseGetPos()
            Sleep(200)
            Send("{ESC}")
            Sleep(200)

            ; SHIFT & Click
            Send("{SHIFTDOWN}")
            MouseClick("left", $aMPos[0], $aMPos[1])
            Sleep(200)
            Send("{SHIFTUP}")
        EndIf
    EndIf
EndFunc   ;==>_CheckForMSDN_RB
;---------------------------------------------------------------------------------------
Func _CheckForMSDN_LB($hWND) ; opens MSDN links with left click (In case you forget)
    Local $hMSDN = WinGetHandle("[TITLE:Script Error; CLASS:Internet Explorer_TridentDlgFrame]")
    If $hMSDN Then
        Local $aMPos = MouseGetPos()
        Local $aWPos = WinGetPos($hWND)
        Local $aCLPos = ControlGetPos($hWND, "", "Internet Explorer_Server1")
        Local $hGhostGUI = GhostGUI($hWND, $aCLPos[2], $aCLPos[3], $aWPos[0] + $aCLPos[0] + 6, $aWPos[1] + $aCLPos[1] + 46)
        WinActivate($hWND)
        Do
            ControlSend($hMSDN, "", "Internet Explorer_Server1", "n")
            Sleep(50)
            $hMSDN = WinGetHandle("[TITLE:Script Error; CLASS:Internet Explorer_TridentDlgFrame]")
            WinActivate($hWND)
        Until Not $hMSDN
        Sleep(50)
        Send("{ALTDOWN}")
        Send("{LEFT}")
        Send("{ALTUP}")
        Sleep(200)

        GUIDelete($hGhostGUI)

        ; SHIFT & Click
        Send("{SHIFTDOWN}")
        MouseClick("left", $aMPos[0], $aMPos[1])
        Sleep(200)
        Send("{SHIFTUP}")

    EndIf
EndFunc   ;==>_CheckForMSDN_LB
;---------------------------------------------------------------------------------------
Func GhostGUI($hWND, $iWidth, $iHeight, $iLeft, $iTop, $BackColor = 0x000000, $Transparency = 200)
    Local $hGUI = GUICreate('GhostGUI', $iWidth, $iHeight, $iLeft, $iTop, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TRANSPARENT, $WS_EX_TOPMOST), $hWND)
    GUISetBkColor($BackColor)
    WinSetTrans($hGUI, '', $Transparency)
    GUISetState(@SW_SHOW, $hGUI)
    Return $hGUI
EndFunc   ;==>GhostGUI
;---------------------------------------------------------------------------------------
Func _CheckForMsgBox() ; closes the annoying notification MsgBox
    Local $hMsgBox = WinGetHandle("[TITLE:Help; CLASS:#32770]", "Some content of this document has been blocked for your safety.")
    If $hMsgBox Then ControlClick($hMsgBox, "", "Button1")
EndFunc   ;==>_CheckForMsgBox
;---------------------------------------------------------------------------------------
Func InjectHelp() ; Inject a custom .CSS file into help (Dark theme)
    ; by @Gianni ; https://www.autoitscript.com/forum/topic/211640-autoit-help-file-for-dark-environment/?do=findComment&comment=1531446
    Local $hWND = WinGetHandle("AutoIt Help") ; handle of the AutoIt Help window
    If Not WinExists($hWND) Then Return ; MsgBox(0, 'Help not found', "no AutoIt Help running", 3)

    $oIE = _IEAttach($hWND, "embedded") ; get reference to the BrowserControl embedded in the Help
    If @error Then Return ; MsgBox(0, 'Browser Control error', "problems on attaching Browser Control", 3)

    ; Set your custom CSS settings
    _WebBrowser_CSS_Inject($oIE, $sMyCSS)

    ; get a reference to the browser's window (for event management purpose)
    Local $oWindow = $oIE.document.parentwindow

    ; setup an event management
    Local $Event = ObjEvent($oWindow, "IEEvent_", 'HTMLWindowEvents')
    If @error Then Return

    While WinExists($hWND) ; stay alive only while the help is running
        GUIGetMsg() ; just to delay the CPU load

        _CheckForMsgBox()
        _CheckForMSDN_LB($hWND)
        _CheckForMSDN_RB()
    WEnd
    Return ;MsgBox(0, '', "AutoIt Help closed", 3)
EndFunc   ;==>InjectHelp
;---------------------------------------------------------------------------------------
Volatile Func IEEvent_onload($oEvent) ; following function is fired each time the Help page changes
    ;ConsoleWrite("Debug: onload event" & @crlf)
    _WebBrowser_CSS_Inject($oIE, $sMyCSS)     ; ; apply your custom CSS setting to the loaded page
EndFunc   ;==>IEEvent_onload

; #FUNCTION# ====================================================================================================================
; Name ..........: _WebBrowser_CSS_Inject
; Description ...: this function creates into the html document a CSS node element with embedded the passed CSS or a link to a CSS
; Syntax ........: _WebBrowser_CSS_Inject(Byref $oIE_Server, $sStylesheet[, $bIsUrl = False])
; Parameters ....: $oIE_Server          - a Webbrowser object reference.
;                  $sStylesheet         - CSS source to be injected into the page (either, a CSS or an URL (a link to a CSS)
;                  $bIsUrl              - [optional] True if above parameter is an URL (a link to a CSS source). Default is False.
; Return values .: A Node Object reference, representing the appended node
; Author ........: Gianni
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......:
; ===============================================================================================================================
Func _WebBrowser_CSS_Inject(ByRef $oIE_Server, $sStylesheet, $bIsUrl = False)
    ; Inject css
    Local $oStyleNode
    Local $objDocument = $oIE_Server.document
    ;
    If $bIsUrl Then     ; use the link to load a stylesheet
        $oStyleNode = $objDocument.createElement('link')     ; // Creates <link    />
        $oStyleNode.type = "text/css"
        $oStyleNode.rel = 'stylesheet'
        $oStyleNode.href = $sStylesheet
    Else     ; inject the stylesheet directly
        $oStyleNode = $objDocument.createElement('style')     ; // Creates <style></style>
        $oStyleNode.type = 'text/css'
        $oStyleNode.styleSheet.cssText = $sStylesheet     ; // Syntax for IE
    EndIf
    ;
    Local $oNode = $objDocument.getElementsByTagName('head').item(0).appendChild($oStyleNode)

    If $bIsUrl Then     ; wait till css has been downloaded
        Do
            Sleep(250)
            ; ConsoleWrite('css: ' & $oNode.ReadyState & @CRLF) ; debug purpose
        Until $oNode.ReadyState = "loaded" Or $oNode.ReadyState = "complete"
    EndIf

    Return $oNode
EndFunc   ;==>_WebBrowser_CSS_Inject
;---------------------------------------------------------------------------------------
Func __ObjAutoItErrorEvent() ; reset Obj error
    If IsObj($g_ObjErr) Then
        ; Clear the properties of ObjEvent
        $g_ObjErr.Description = ""
        $g_ObjErr.Number = 0
    EndIf
EndFunc   ;==>__ObjAutoItErrorEvent
;---------------------------------------------------------------------------------------

default.css

Edited by ioa747
added information

I know that I know nothing

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...