AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Search with Firefox from everywhere.

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
alexball



Joined: 04 Jun 2008
Posts: 5

PostPosted: Wed Jun 04, 2008 11:26 pm    Post subject: Search with Firefox from everywhere. Reply with quote

Hi there.

I love Autohotkey and I love the Firefox searchbox. I have Conquery installed in Firefox which lets me search in a new tab for every text I mark with any of my search engines from the search box. Conquery is truly amazing for people who search a lot with Firefox. Check it out:
https://addons.mozilla.org/de/firefox/addon/231

With Autohotkey I can use one of my many mouse buttons to search for any word with any of my engines both inside Firefox and outside of Firefox in any application of windows. I use my middle mouse button

Plus:

In Firefox I use middle click to open a link in a new tab in the background. Now I've modified the script so that it checks if I've selected a word in Firefox. If I've selected a word it lets me search for it. If I've not selected a word it assumes that I want to do a normal middle click and it does so.

So now you don't lose your normal middle click functionality in Firefox and you can still use my script to look up words.

Skript updated 23/07/08
Code:
IfWinActive, ahk_class MozillaUIWindowClass
{
clipboard = ;empty clipboard to be able to check for text selection
send ^c
if clipboard = ;this checks if you have selected some text
{
send {MButton}
exit
}
else
{
Sleep 100
Send {Shift down}{RButton}{Shift up}
KeyWait, LButton, D
Sleep 500
send ^v {Enter}
exit
}
}
else
send ^c
IfWinExist, ahk_class MozillaUIWindowClass
{
Winactivate
Sleep 100
Send {Shift down}{RButton}{Shift up}
KeyWait, LButton, D
Sleep 500
send ^v {Enter}
exit

}

else
msgbox, 262144,, You have pressed the search button but Firefox is not running. Please start Firefox first


Cheers
Alex

This was an old post. It took me some time to figure out how to do this. The script above is the most recent one. The posts beneath are posts that refer to my original post where I wanted to build this script.


Last edited by alexball on Wed Jul 23, 2008 1:05 pm; edited 4 times in total
Back to top
View user's profile Send private message
PurloinedHeart



Joined: 04 Apr 2008
Posts: 209
Location: Canada

PostPosted: Thu Jun 05, 2008 12:17 am    Post subject: Reply with quote

Isn't firefox's searchbox the same as Google's "I'm feeling lucky" button?

Quick edit:
Code:

Search = Search term here
run, http://www.google.ca/search?hl=en&q=%Search%&btnI=3564


I think using this is more friendly, it will open the page even if you don't have FF installed.
Back to top
View user's profile Send private message
Red Hat Dude
Guest





PostPosted: Thu Jun 05, 2008 3:56 am    Post subject: Reply with quote

Code:
IfWinExist, Winactivate, ahk_class MozillaUIWindowClass
Back to top
SoggyDog



Joined: 02 May 2006
Posts: 280
Location: Greeley, CO

PostPosted: Thu Jun 05, 2008 4:08 am    Post subject: Reply with quote

Not to derail your project, but why reinvent the wheel?
Have you seen this post?
Or this one?
_________________

SoggyDog
Download AutoHotKey Wallpaper
Does 'Fuzzy Logic' tickle?
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
alexball



Joined: 04 Jun 2008
Posts: 5

PostPosted: Thu Jun 05, 2008 9:06 am    Post subject: Reply with quote

Hi, thanks everybody for your quick answers.

@SoggyDog

Basically my script is quite similar to the one you mention.
SoggyDog wrote:
Not to derail your project, but why reinvent the wheel?
Have you seen this post?


Except that it is easier to add engines to my script because it uses the engines you have in Firefox. So if you want to add an engine, rather then looking up how the engine works and writing the code you just add the engine to your firefox search box. And my script also uses the icons of the engine.

Well since I use Firefox a lot and change my search engines a lot as well the "Look Up Selected Text... " SoggyDog suggested is less conveniant for me.

I work like this. I have a logitech mouse where I can customize every button using the uberOptions extension. Now in Firefox I use my MediaPlay button to have HotHotKey do

Code:
Send {Shift down}{RButton}{Shift up}


This tells conquery to do a popup showing all searchengines. Selecting one onpens search in a new tab.

Now porting this to Windows in general works so far like this:

Code:
Send ^c

IfWinExist, ahk_class MozillaUIWindowClass
{Winactivate

send ^k ^v !{Down}
Sleep 2500
send {Enter}

}
else
MsgBox, Der Suchknopf wurde gedrückt, aber Firefox ist nicht da. `nBitte Firefox starten! ;Please start Firefox


now I want to improve this part so that it waits until leftbutton is clicked and then waits 500 more before hitting enter

Code:
send ^k ^v !{Down}
Sleep 2500
send {Enter}


Thanks a lot
Alex


Last edited by alexball on Wed Jul 23, 2008 1:14 pm; edited 1 time in total
Back to top
View user's profile Send private message
alexball



Joined: 04 Jun 2008
Posts: 5

PostPosted: Thu Jun 05, 2008 3:26 pm    Post subject: Reply with quote

I did it. Yes Yes! Laughing

The problem was that Autohotkey is just too fast. If I launch the script via mouse key and I tell it KeyWait it recognizes the release of the key which launched the script. I added some delay and voila:

Code:
send ^c

IfWinActive, ahk_class MozillaUIWindowClass
{
Sleep 100
Send {Shift down}{RButton}{Shift up}
KeyWait, LButton, D
Sleep 500
send ^v {Enter}
exit
}
else

IfWinExist, ahk_class MozillaUIWindowClass
{
Winactivate
Sleep 100
Send {Shift down}{RButton}{Shift up}
KeyWait, LButton, D
Sleep 500
send ^v {Enter}
exit

}

else
msgbox, 262144,, You have pressed the search button but Firefox is not running. Please start Firefox first


Thanks for your help everybody.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group