Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;#NoTrayIcon
- #Persistent
- #SingleInstance
- KeySequence := "^!s"
- ; chrome site local search
- ;
- ; usage:
- ;
- ; viewing some site,
- ; with chrome focused,
- ; input hotkey --
- ; default is ctrl+alt+s
- ;
- ; at dialog,
- ; enter query term,
- ; then press enter,
- ; or click ok
- ;
- ; confirm address field,
- ; press enter and
- ; wait for results...
- ; now it's time for manual scanning :)
- ;
- SiteLocalSearch()
- {
- ; XXX: test more?
- ;ControlFocus, Chrome_OmniboxView1, A
- ;If (ErrorLevel != 0)
- ;{
- ; OutputDebug, % "ControlFocus failed for Chrome_OmniboxView1"
- ; SoundBeep
- ; Return
- ;}
- ; XXX: hack to focus location field
- Send ^l
- ClipSaved := ClipboardAll
- Clipboard := ""
- ; XXX: hack to obtain content of location field
- Send ^c
- ClipWait
- Captured := Clipboard
- Clipboard := ClipSaved
- OutputDebug, % "Captured: " . Captured
- ;
- Pattern := "iO)^(https?://([^/]+))"
- FoundPos := RegExMatch(Captured, Pattern, MObj)
- If (ErrorLevel != 0)
- {
- OutputDebug, % "RegExMatch ErrorLevel: " . ErrorLevel
- SoundBeep
- Return
- }
- If (FoundPos == 0)
- {
- OutputDebug, % "RegExMatch did not parse: " . Captured
- SoundBeep
- Return
- }
- Prefix := MObj[1]
- OutputDebug, % "Matched: " . Prefix
- ;
- InputBox, QueryStr, % "Site Local Search", % "Search within: " . Prefix
- , , , 130
- If (ErrorLevel != 0)
- {
- OutputDebug, % "InputBox ErrorLevel: " . ErrorLevel
- Return
- }
- ClipSaved := ClipboardAll
- PasteStr := "site:" . Prefix . " " . QueryStr
- OutputDebug, % "About to paste: " . PasteStr
- ;
- Clipboard := PasteStr
- ; XXX: hack to edit location field
- Send ^v
- Clipboard := ClipSaved
- Return
- }
- #If WinActive("ahk_class Chrome_WidgetWin_0")
- Hotkey, % KeySequence, DoSiteLocalSearch
- Return
- DoSiteLocalSearch:
- {
- SiteLocalSearch()
- Return
- }
Add Comment
Please, Sign In to add comment