Enter Firefox search phrase

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
stevethaw7
Posts: 9
Joined: 08 Feb 2018, 09:46

Enter Firefox search phrase

20 Mar 2018, 07:36

I would appreciate advice in developing a hotkey script to accomplish the following:
- open Firefox, or, if Firefox is already running add a new tab
- place the cursor in the address bar and enter the phrase "microsoft access" with a space after the phrase
- leave the cursor in the address bar ready for me to finish entering the search phrase

Here's what I have, but it does not work reliably, often executing the Run line and stopping.
^+6::
Run, https://firefox.com
Sleep 3000
Send ^t
Sleep 1200
Send ^l
Sleep 700
Send microsoft access
Sleep 600
Send {Esc}
Sleep 600
Send {Space}
Return

What can I do to make it work reliably?

Thanks.
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Enter Firefox search phrase

20 Mar 2018, 10:25

Code: Select all

!c::    ; press ALt+C to start script
   Send, ^c   ; this will copy a previously selected string to the clipboard
   Run,% "firefox.exe https://www.google.de/search?q=microsoft+access+" . ClipBoard  ; ... that will be added to the predefined command and start the search
   ClipBoard := ""
   Return
Not tested.
stevethaw7
Posts: 9
Joined: 08 Feb 2018, 09:46

Re: Enter Firefox search phrase

23 Mar 2018, 19:55

Thank you BoBo but that does not appear to do what I want. Or at least I do not see how it can do what I want. My goal is to have the script open Firefox, type "microsoft access " in the address bar and wait for me to enter the rest of the search term and press ENTER. I have configured Firefox to use the duckduckgo search engine.

Thank you.
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: Enter Firefox search phrase

23 Mar 2018, 21:11

Try this:

Code: Select all

#NoEnv
SetWorkingDir, %A_ScriptDir%

Title := "My Duck Duck Go Search"
Prompt := "Enter Text to Search"
DefaultSearchTerm := "microsoft access "

$1::
    SetTimer, setText, -1
    InputBox, SEARCHSTRING, % Title, % Prompt
    if (ErrorLevel = 0)    ; Searches using default browser:
        Run, % "https://duckduckgo.com/?q=" . StrReplace(SEARCHSTRING,A_Space,"+") . "&t=hy&ia=web"
return

; This is for setting the default text without highlighting which is inputbox default:
setText: 
    WinWait, %Title% ahk_class #32770
    ControlSetText, Edit1, % DefaultSearchTerm, %Title% ahk_class #32770
    ControlSend, Edit1, {Ctrl Down}{Right}{Right}{Ctrl Up}, %Title% ahk_class #32770
return
HTH

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: peter_ahk and 336 guests