sadly regedit does not prompt the "how do you want to open" window anymore ...
RegWrite, REG_SZ, HKCU, Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice, ProgId, %browserName%
RegWrite, REG_SZ, HKCU, Software\Microsoft\Windows\Shell\Associations\UrlAssociations\https\UserChoice, ProgId, %browserName%
Code: Select all
;GUI search pro 2 by MedBooster
;reference https://www.autohotkey.com/boards/viewtopic.php?f=6&t=122359&p=543307#p543307
#NoEnv
#Warn
SendMode Input
SetWorkingDir %A_ScriptDir%
;this needs to be outside the Gui code
Return
GuiEscape:
Gui, Cancel
return
; Hotkey to activate the search engine selection GUI (Win+Ctrl+Shift+W)
!#W::
Send, ^c
Gui_Title := "Web search tool" ;you can rename this
Gui, Destroy
Sleep, 200 ; Wait for clipboard to capture the selected text
Gui, Add, Text, , Select a Search Engine:
Gui, Add, Button, x10 y30 w150 h30, Google
Gui, Add, Button, x170 y30 w150 h30, DuckDuckGo
Gui, Add, Button, x10 y70 w150 h30, Yandex
Gui, Add, Button, x170 y70 w150 h30, Bing
Gui, Add, Button, x10 y110 w150 h30, Yahoo
Gui, Add, Button, x170 y110 w150 h30, Swisscows
Gui, Add, Text, x10 y150, Select database:
Gui, Add, Button, x10 y170 w150 h30, UpToDate
Gui, Add, Button, x170 y170 w150 h30, DynaMed
Gui, Add, Button, x10 y210 w150 h30, Amboss
Gui, Add, Button, x170 y210 w150 h30, ClinicalKey
Gui, Add, Button, x10 y250 w150 h30, PubMed
Gui, Add, Button, x170 y250 w150 h30, MSDManuals
; Add buttons for YouTube and MerckManuals
Gui, Add, Button, x10 y290 w150 h30, YouTube
Gui, Add, Button, x170 y290 w150 h30, DailyMed
Gui, Add, Button, x10 y330 w310 h30, ChangeDefaultBrowser
Gui, Add, Text, x10 y370, Search text: ; title
Gui, Add, Text, x10 y370, Search text: ; title
Gui, Add, Text, , UserInput ;referring to the line below
Gui, Font, S16 c0078D7, UserInput
Gui, Add, Edit, x10 y390 w310 h30 vUserInput ;textbox
GuiControl, Focus, UserInput ;focus = input field active right away
Gui, Add, Text, CloseGUIpostsearchChecked ;referring to the line below
Gui, Font, S9 cBlack, CloseGUIpostsearchChecked
Gui, Add, Checkbox, x10 y430 vCloseGUIpostsearchChecked Checked, Close GUI after search if checked
Gui,+AlwaysOnTop
Gui, Add, Button, x240 y430 w80 h18 gClearInput, Clear
GuiControl, +g, UserInput ; Assign the default handler for the GUI
;Gui, Font, S9, Lucida Console
;---------GET CENTER OF CURRENT MONITOR---------
;get current monitor index
CurrentMonitorIndex:=GetCurrentMonitorIndex()
;get Hwnd of current GUI
DetectHiddenWindows On
Gui, +LastFound
Gui, Show, Hide
GUI_Hwnd := WinExist()
;Calculate size of GUI
GetClientSize(GUI_Hwnd,GUI_Width,GUI_Height)
DetectHiddenWindows Off
;Calculate where the GUI should be positioned
GUI_X:=CoordXCenterScreen(GUI_Width,CurrentMonitorIndex)
GUI_Y:=CoordYCenterScreen(GUI_Height,CurrentMonitorIndex)
;------- / GET CENTER OF CURRENT MONITOR---------
;SHOW GUI AT CENTER OF CURRENT SCREEN
Gui, Show, % "x" GUI_X " y" GUI_Y, %Gui_Title% ;title of window
Return
;place this outside of the GUI code
ClearInput:
GuiControl,, UserInput, ; Clear the UserInput field
GuiControl, Focus, UserInput ; Set focus on the UserInput field after clearing
Return
; Buttons to select the search engine
ButtonYahoo:
Gui, Submit, NoHide ; necessary for checkboxes
searchOrVisitFromClip("https://search.yahoo.com/search;_ylt=AwrNag_OGT5ljbgnQQdDDWVH;_ylc=X1MDMTE5NzgwNDg2NwRfcgMyBGZyAwRmcjIDcDpzLHY6c2ZwLG06c2ItdG9wBGdwcmlkA1V4T2ZWazdKUTJTZVkwZmYzZ0dYQUEEbl9yc2x0AzAEbl9zdWdnAzEwBG9yaWdpbgNzZWFyY2gueWFob28uY29tBHBvcwMwBHBxc3RyAwRwcXN0cmwDMARxc3RybAM0BHF1ZXJ5A3Rlc3QEdF9zdG1wAzE2OTg1Njg2NTY-?p=")
if (CloseGUIpostsearchChecked = 1) {
Gui,Destroy
}
Return
ButtonGoogle:
Gui, Submit, NoHide
searchOrVisitFromClip("https://www.google.com/search?q=")
if (CloseGUIpostsearchChecked = 1) {
Gui,Destroy
}
Return
ButtonDuckDuckGo:
Gui, Submit, NoHide
searchOrVisitFromClip("https://duckduckgo.com/?q=")
if (CloseGUIpostsearchChecked = 1) {
Gui,Destroy
}
Return
ButtonYandex:
Gui, Submit, NoHide
searchOrVisitFromClip("https://www.yandex.com/search/?text=")
if (CloseGUIpostsearchChecked = 1) {
Gui,Destroy
}
Return
ButtonBing:
Gui, Submit, NoHide
searchOrVisitFromClip("https://www.bing.com/search?q=")
if (CloseGUIpostsearchChecked = 1) {
Gui,Destroy
}
Return
ButtonUpToDate:
Gui, Submit, NoHide
searchOrVisitFromClip("https://www-uptodate-com/contents/search?search=")
if (CloseGUIpostsearchChecked = 1) {
Gui,Destroy
}
Return
ButtonDynaMed:
Gui, Submit, NoHide
searchOrVisitFromClip("https://www-dynamed-com/results?q=")
if (CloseGUIpostsearchChecked = 1) {
Gui,Destroy
}
Return
ButtonAmboss:
Gui, Submit, NoHide
searchOrVisitFromClip("https://next.amboss.com/us/search?q=")
if (CloseGUIpostsearchChecked = 1) {
Gui,Destroy
}
Return
ButtonSwisscows:
Gui, Submit, NoHide
searchOrVisitFromClip("https://swisscows.com/en/web?query=")
if (CloseGUIpostsearchChecked = 1) {
Gui,Destroy
}
Return
ButtonClinicalKey:
Gui, Submit, NoHide
searchOrVisitFromClip("https://www-clinicalkey-com/#!/search/")
if (CloseGUIpostsearchChecked = 1) {
Gui,Destroy
}
Return
ButtonMSDManuals:
Gui, Submit, NoHide
searchOrVisitFromClip("https://www.msdmanuals.com/professional/SearchResults?query=")
if (CloseGUIpostsearchChecked = 1) {
Gui,Destroy
}
Return
ButtonPubMed:
Gui, Submit, NoHide
searchOrVisitFromClip("https://pubmed.ncbi.nlm.nih.gov/?term=")
if (CloseGUIpostsearchChecked = 1) {
Gui,Destroy
}
Return
ButtonYouTube:
Gui, Submit, NoHide
searchOrVisitFromClip("https://www.youtube.com/results?search_query=")
if (CloseGUIpostsearchChecked = 1) {
Gui,Destroy
}
Return
ButtonDailyMed:
Gui, Submit, NoHide
searchOrVisitFromClip("https://dailymed.nlm.nih.gov/dailymed/search.cfm?labeltype=all&query=")
if (CloseGUIpostsearchChecked = 1) {
Gui,Destroy
}
Return
searchOrVisitFromClip(searchUrl) { ;for clipboard → button , or input (textbox) → button
GuiControlGet, UserInput, , UserInput ; Get the value from the UserInput GUI control
;check if textbox contains text
if (UserInput != "") {
Clipboard := UserInput
run, % searchUrl clipboard
}
;check if textbox is empty
if (UserInput = "") {
if (clipboard ~= "^https?://") {
run, % clipboard
} else {
run, % searchUrl clipboard
}
}
Return
}
;reference https://stackoverflow.com/questions/32354861/how-to-find-the-default-browser-via-the-registry-on-windows-10
;reference https://www.autohotkey.com/boards/viewtopic.php?t=5015
ButtonChangeDefaultBrowser:
Run ms-settings:defaultapps
Sleep 1500
Send {Tab 5}{Enter} ;Highlight Default Browser + Select
Sleep 1000
Send {Tab 2} ;Highlight Chrome + Select
TrayTip, Notification, Choose default browser in settings, 10
Return
;standard search script other
;Some improvements with the help of andreas@ESA:~$ sudo -i
#+w::searchOrVisitFromClipSimple("https://www.google.com/search?q=")
#w::searchOrVisitFromClipSimple("https://duckduckgo.com/?q=")
searchOrVisitFromClipSimple(searchUrl){
clip := clipboardAll
clip := ""
send, ^c
ClipWait, 0.5
if(ErrorLevel){
} else if (clipboard ~= "^https?:\/\/") { ; if clipboard content is an http or https protocol url
run, % clipboard
} else { ;search using the provided url
run, % searchUrl clipboard
}
clipboard := clip ;put the last copied thing back in the clipboard
}
;reference https://www.autohotkey.com/boards/viewtopic.php?t=31716
GetCurrentMonitorIndex(){
CoordMode, Mouse, Screen
MouseGetPos, mx, my
SysGet, monitorsCount, 80
Loop %monitorsCount%{
SysGet, monitor, Monitor, %A_Index%
if (monitorLeft <= mx && mx <= monitorRight && monitorTop <= my && my <= monitorBottom){
Return A_Index
}
}
Return 1
}
CoordXCenterScreen(WidthOfGUI,ScreenNumber)
{
SysGet, Mon1, Monitor, %ScreenNumber%
return (( Mon1Right-Mon1Left - WidthOfGUI ) / 2) + Mon1Left
}
CoordYCenterScreen(HeightofGUI,ScreenNumber){
SysGet, Mon1, Monitor, %ScreenNumber%
return ((Mon1Bottom-Mon1Top - 30 - HeightofGUI ) / 2) + Mon1Top
}
GetClientSize(hwnd, ByRef w, ByRef h)
{
VarSetCapacity(rc, 16)
DllCall("GetClientRect", "uint", hwnd, "uint", &rc)
w := NumGet(rc, 8, "int")
h := NumGet(rc, 12, "int")
}