It is independent with browsers. It also can work when copy something from CHM or other webpages.
Note: A perfect script for the same purpose is this Lexikos's script. Strongly recommended!
Requirement: Bin2Hex() (Thank PhiLho!)
$^v:: ; Use hook to avoid itself
Send, ^v
binClipData := ClipboardAll
Bin2Hex(hexClipData, binClipData) ; Covert raw data to a string of HEX
if (SubStr(hexClipData, 1, 8) <> "09C00000") ; Determine whether the Clipboard data come from a webpage
return
iFoundPos := RegExMatch(hexClipData, "0D0A536F7572636555524C3A(.+?)0D0A", Match) ;~ 0D0A536F7572636555524C3A ~ 0D0A (SourceURL:)
if (Match1 = "")
return
hexSource := Match1
sSource := ""
Loop ; Covert a string of HEX to raw data
{
sSource .= Chr("0x" SubStr(hexSource, A_Index * 2 - 1, 2))
if (A_Index * 2 > StrLen(hexSource))
break
}
;~ SendInput, `nSource: %sSource% ; It is better to Use clipboard.
Clipboard := "`nSource: " sSource
Sleep, 0
Send, ^v
Clipboard := binClipData ; Recover the clipboard.
return
;~ Source URL: http://www.autohotkey.com/community/viewtopic.php?t=7549
/*
// Convert raw bytes stored in a variable to a string of hexa digit pairs.
// Convert either byteNb bytes or, if null, the whole content of the variable.
//
// Return the number of converted bytes, or -1 if error (memory allocation)
*/
Bin2Hex(ByRef @hex, ByRef @bin, _byteNb=0)
{
local intFormat, dataSize, dataAddress, granted, x
; Save original integer format
intFormat = %A_FormatInteger%
; For converting bytes to hex
SetFormat Integer, Hex
; Get size of data
dataSize := VarSetCapacity(@bin)
If (_byteNb < 1 or _byteNb > dataSize)
{
_byteNb := dataSize
}
dataAddress := &@bin
; Make enough room (faster)
granted := VarSetCapacity(@hex, _byteNb * 2)
if (granted < _byteNb * 2)
{
; Cannot allocate enough memory
ErrorLevel = Mem=%granted%
Return -1
}
Loop %_byteNb%
{
; Get byte in hexa
x := *dataAddress + 0x100
StringRight x, x, 2 ; 2 hex digits
StringUpper x, x
@hex = %@hex%%x%
dataAddress++ ; Next byte
}
; Restore original integer format
SetFormat Integer, %intFormat%
Return _byteNb
}16-07-2012 Edit: Add the link to Lexikos's script.




