I want to share this function I've been working on for a while now.
Basically, it'll open your selected text either in your browser, in a new Explorer window or execute a Google search depending on the type of your selected text.
Example:
If you highlight those examples and run press the hotkey:
-> will open a new Explorer at the selected directoryC:\Program Files\AutoHotkey
-> will open the selected URL in the default browser
-> will open a new tab in your default browser and execute a google searchAutoHotKey
Code: Select all
OpenHighlighted()
{
MyClipboard := "" ; Clears variable
Send, {ctrl down}c{ctrl up} ; More secure way to Copy things
sleep, 50 ; Delay
MyClipboard := RegexReplace( clipboard, "^\s+|\s+$" ) ; Trim additional spaces and line return
sleep, 50
MyStripped := RegexReplace(MyClipboard, " ", "") ; Removes every spaces in the string.
StringLeft, OutputVarUrl, MyStripped, 8 ; Takes the 8 firsts characters
StringLeft, OutputVarLocal, MyStripped, 3 ; Takes the 3 first characters
sleep, 50
if (OutputVarUrl == "http://" || OutputVarUrl == "https://")
{
TrayTip,, URL: "%MyClipboard%" ;
Sleep,50
Run, "%MyStripped%"
Return
}
else if (OutputVarLocal == "C:/" || OutputVarLocal == "C:\" || OutputVarLocal == "Z:/" || OutputVarLocal == "Z:\" || OutputVarLocal == "R:/" || OutputVarLocal == "R:\" ||)
{
TrayTip,, Windows: "%MyClipboard%" ;
Sleep,50
Run, %MyClipboard%
Return
}
else
{
TrayTip,, GoogleSearch: "%MyClipboard%" ;
Sleep,50
Run, "http://www.google.com/search?q=%MyClipboard%"
Return
}
Return
}
Let me know if you have any comment/idea/improvement.
Enjoy!