Sign in to follow this  
Followers 0
MilesAhead

Chrome Blanker

2 posts in this topic

#1 ·  Posted (edited)

If you start a chrome based browser using "about:blank" for the start page, you can end up with the caret in the Address Bar in front of "about:blank." This means to type in something new like a url or a search string, you have to hit some keystrokes to get it out of the way.

This little Windows hack automates that.

Run n the tray. Any time it sees a window with Title "about:blank" and text "about:blank" it sends F6, then Delete keys to get rid of it.

This is just an interim kludge. I'm hoping eventually somebody on Chromium team fixes it.

;  Chrome Blanker
;
;  For those who start a Chrome based browser
;  using about:blank to get a blank page.
;
;  This watches for "about:blank" in both the
;  window title and text(the address bar).
;
;  Removes about:blank from address bar.
;  This allows you to type in a url or
;  search string right away.
;
;  Author:  MilesAhead
;
TraySetToolTip("Chrome Blanker")
$title = "about:blank"
$text = "about:blank"

_EmptyWorkingSet()

While 1
    If WinGetTitle($title, $text) Then
        If WinActivate($title, $text) Then
            Send("{F6}")
            Send("{Del}")
            _EmptyWorkingSet()
            ContinueLoop
        EndIf
    EndIf
    Sleep(250)
WEnd

Func _EmptyWorkingSet()
    Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
    Return $ai_Return[0]
EndFunc   ;==>_EmptyWorkingSet
Edited by MilesAhead

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I added a couple of things such as protection against "already running" dialog, about box etc..

Also periodically it calls EmptyWorkingSet() to avoid accumulating memory while sitting in the tray.

;  Chrome Blanker
;
;  For those who start a Chrome based browser
;  using about:blank to get a blank page.
;
;  This watches for "about:blank" in both the
;  window title and text(the address bar).
;
;  Removes about:blank from address bar.
;  This allows you to type in a url or
;  search string right away.
;
;  Author:  MilesAhead
;
#include <Constants.au3>
#include <Misc.au3>

Const $ERROR_ALREADY_EXISTS = 183
If _Singleton("{C8C284F1-5247-4187-8D48-FD476E473C61}", 1) = 0 Then
    If @error = $ERROR_ALREADY_EXISTS Then Exit
EndIf
AutoItSetOption("TrayMenuMode", 3)
TraySetClick(8)
$aboutitem = TrayCreateItem("About Chrome Blanker")
TrayCreateItem("")
$exititem = TrayCreateItem("Quit")
TrayItemSetState($aboutitem, $TRAY_DEFAULT)
TraySetToolTip("Chrome Blanker")
TraySetState()

Const $LoopTrigger = 4096
Global $loopCount = 0
$title = "about:blank"
$text = "about:blank"

_EmptyWorkingSet()

While 1
    $msg = TrayGetMsg()
    Select
        Case $msg = 0
            If WinGetTitle($title, $text) Then
                If WinActivate($title, $text) Then
                    Send("{F6}")
                    Send("{Del}")
                    _TrimMemory()
                    ContinueLoop
                EndIf
            EndIf
            $loopCount += 1
            If $loopCount > $LoopTrigger Then _TrimMemory()

        Case $msg = $aboutitem
            _About()

        Case $msg = $exititem
            _Quit()

    EndSelect
WEnd

Func _TrimMemory()
    _EmptyWorkingSet()
    $loopCount = 0
EndFunc   ;==>_TrimMemory

Func _EmptyWorkingSet()
    Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
    Return $ai_Return[0]
EndFunc   ;==>_EmptyWorkingSet

Func _About()
    Local $mMsg = @CRLF & "Chrome Blanker is a Hack for Chrome based Browsers on Windows." & @CRLF & @CRLF
    $mMsg &= "It erases about:blank from the Adress Bar on Startup" & @CRLF & @CRLF
    $mMsg &= "          Author:  MilesAhead"
    MsgBox(0x1040, "Chrome Blanker", $mMsg)
EndFunc   ;==>_About

Func _Quit()
    Exit
EndFunc   ;==>_Quit
Edited by MilesAhead

Share this post


Link to post
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
Sign in to follow this  
Followers 0