Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

IfWinExist and Firefox Tabs


  • Please log in to reply
7 replies to this topic
Knowbodynow
  • Members
  • 43 posts
  • Last active: Apr 14 2009 03:38 PM
  • Joined: 26 Jun 2007
Hello, I have little experience with AutoHotKey or coding. I know how to check if Firefox has been launched so that I can switch to it rather than launching several instances. I would like a hotkey to launch POPfile. Currently I'm using:
+#p:: Run "http://localhost:8080/"
This will launch the default browser (Firefox) and create a tab entitled "POPfile Control Center". But if I press the key combination a second time I get two tabs. What I want to do is to be able to switch to the tab if it already exists. Is there a way to do this? I tried using IfWinExist but didn't get anywhere.

Thanks

CaH

Andy3
  • Guests
  • Last active:
  • Joined: --
Maybe a Firefox extension works for you? You can install iMacros inside Firefox and then open Firefox with

http://run.imacros.net/?m=yourmacro

"yourmacro" is a simple iMacros macro that switches the tabs ("TAB T=2").

Knowbodynow
  • Members
  • 43 posts
  • Last active: Apr 14 2009 03:38 PM
  • Joined: 26 Jun 2007
Thanks, but I'd like to avoid installing any additional extensions. Right now I have a custom button in Thunderbird that will bring up Firefox and launch an instance of POPfile. As long as I remember to close it I won't get two instances of POPfile running. So what I have is basically OK. I guess I'd like to know if it is possible to switch Firefox tabs using AutoHotKey

Cheers,

CaH

Andy3
  • Guests
  • Last active:
  • Joined: --
Maybe this post works for Firefox, too?

http://www.autohotke...topic25855.html

derRaphael
  • Members
  • 872 posts
  • Last active: Mar 19 2013 04:42 PM
  • Joined: 23 Nov 2007
hi

put this somewhere in autoexecute section of your script:
SetTitleMatchMode, RegEx

and this one in front of your hotkey
#IfWinActive, Mozilla Firefox$

first one will switch on RegularExpressions for setTitleMatchMode and the later will check if a window exist, where Mozilla Firefox are the last two words

greets
derRaphael

Knowbodynow
  • Members
  • 43 posts
  • Last active: Apr 14 2009 03:38 PM
  • Joined: 26 Jun 2007
Thanks for the reply, derRaphael. How will the code you suggested help me to check if Firefox has a tab of a particular name? Currently I'm using SetTitleMatchMode 2 to identify if Firefox is running. That seems to be working OK.

CaH

derRaphael
  • Members
  • 872 posts
  • Last active: Mar 19 2013 04:42 PM
  • Joined: 23 Nov 2007
sorry, misunderstood your question
the code i suggested only checks if a window is open and its title ends with mozilla firefox

to get informations about tabs...

there is an article which describes how msie tab and firefox tab information are retrieved, buts its not too simple. especially the firefox part invokes a custom plugin that allows communication with external apps

may you want to give it a try .... i'd do myself, but right now im focused on other things and dont have too much time for it

http://www.codeproje...t=2306648#ffExt

firefox is a multi os application and to have it look the same on multiple operating systems like linux, mac os or windows, the developers created own ways to display informations. so working with these structures requires somewhat special treatment.


probably a workaround for your problem would be to store in the script if the hotkey was pressed and check for that status when its pressed

something like:

firefoxtab := 0

+#p::
 if !(fireFoxTab) {
    Run "http://localhost:8080/"
    firefoxTab:=1
 }
return


but this only works once util you restarted the script, and there is no control about the tab thing

another solution might be to send ctrl+tab to firefox application, cycle this way through tabs and remember their names (due to changing fireox title bar)

when all names are gathered twice you've cycled through all and repeated a around - you can stop sending the ctrl tab then and check for your desired name

if this one's not in that name bunch open it again ...
this solution is not a real elegant one, but should work


greets
derRaphael

Knowbodynow
  • Members
  • 43 posts
  • Last active: Apr 14 2009 03:38 PM
  • Joined: 26 Jun 2007
Thank for the detailed reply, I appreciate it. The problem certainly doesn't warrant trying to use a plugin but I may have a go at one of the workaround methods you suggested.

Thanks again,

CaH