-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGoogle Search.ahk
50 lines (39 loc) · 1.07 KB
/
Google Search.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
TraySetIcon("ahk.ico")
#f2:: { ; <-- Regular Search Using Highlighted Text (Win + F2)
GoogleIt(1)
}
^#f2:: { ; <-- Images Search Using Highlighted Text (Win + Ctrl + F2)
GoogleIt(2)
}
!#f2:: { ; <-- Map Search Using Highlighted Text (Win + Alt + F2)
GoogleIt(3)
}
GoogleIt(SearchType) {
; Save clipboard
SavedClipboard := ClipboardAll()
A_Clipboard := ""
; Copy highlighted text to the clipboard
Send "^c"
If not ClipWait(.5) {
Box := InputBox("Enter the text to search:", "Google Search", "W200 H100")
If (Box.Result = "Cancel")
Return
Query := Box.Value
} Else {
Query := A_Clipboard
}
Query := Trim(Query)
If (Query = "")
Return
; Search
If (SearchType = 1)
Address := "http://www.google.com/search?hl=en&q=" Query ; Web Search
Else If (SearchType = 2)
Address := "http://www.google.com/search?site=imghp&tbm=isch&q=" Query ; Image Search
Else
Address := "http://www.google.com/maps/search/" Query ; Map Search
Run 'chrome.exe "' Address '"'
; Restore the clipboard
A_Clipboard := SavedClipboard
SavedClipboard := ""
}