DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: Chrome "about:blank" hack for Windows  (Read 7,798 times)

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • Coding Snacks
Chrome "about:blank" hack for Windows
« on: June 11, 2011, 01:24 AM »
If you use "about:blank" in settings to get a chrome based browser to start with a blank page you may notice it comes up with "about:blank" in the Address Bar and the caret at the beginning of the line.  It forces you to delete about:blank before you can type in a url or search string.

This little AutoIt3 hack sits in the tray and watches for a window title starting with "about:blank" and window text that's also "about:blank"(the text in the Address Bar.)

If it gets a match it sends keys to remove about:blank allowing you to type stuff in right away.  The hack is an AutoIt3 script meaning it runs on Windows XP or later. You can get the AutoIt tools to run and/or compile the script here:
http://www.autoitscript.com/site/autoit/downloads/

This is just a hack until the Chromium guys get around to fixing it.


Code
;  Chrome Blanker for Windows XP or later
;
;  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
;
$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

« Last Edit: June 11, 2011, 03:24 AM by MilesAhead »

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • Coding Snacks
Re: Chrome "about:blank" hack for Windows
« Reply #1 on: June 11, 2011, 05:59 AM »
I added a few things. Protection against "already running" error dialog.  Memory trimmed periodically while running in the tray.  Plus your basic crappy About MsgBox!!



Code
;  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
« Last Edit: June 11, 2011, 07:41 AM by MilesAhead »

Original address: https://www.donationcoder.com/forum/index.php?topic=27010.0