AutoHotkey Community

It is currently May 27th, 2012, 12:22 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: June 4th, 2005, 12:21 pm 
Offline

Joined: June 4th, 2005, 11:56 am
Posts: 26
Location: Lokeren, Belgium
There seems to be a problem in detecting Mozilla Firefox:
Code:
RunFirefox:
  IfWinNotExist, Firefox
      Run "d:\ap\firefox\firefox.exe"
return

always fires a new Firefox window.

Using "ahk_class MozillaWindowClass" rather than "Firefox" does work, but Thunderbird uses the same windowclass, so that is no option either.

I have searched the forum for "firefox", with no hits. So I suppose this has not yet been reported, or nobody else has this problem.

Any suggestion to solve or avoid this problem would be highly appreciated.

PS.: I am a new user, walking around like a kid in a candy store.
Boy, AutoHotkey is an amazing piece of software!
Thanks Chris, and all people contributing know-how and scripts.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 4th, 2005, 12:37 pm 
Offline

Joined: April 5th, 2005, 10:50 pm
Posts: 133
Try to change this line
Quote:
IfWinNotExist, Firefox

to be
Code:
IfWinNotExist, Mozilla Firefox


Report this post
Top
 Profile  
Reply with quote  
PostPosted: June 4th, 2005, 1:15 pm 
Offline

Joined: June 4th, 2005, 11:56 am
Posts: 26
Location: Lokeren, Belgium
Anonymous wrote:
Try to change this line
Quote:
IfWinNotExist, Firefox

to be
Code:
IfWinNotExist, Mozilla Firefox

That gives the same problem.

Maybe I should mention how I really have it in my script. The above was just a short piece of code to demonstrate it.

I have this sub which I succesfully use to launch a.o. Emacs and EGB:
Code:
RunRestoreApp(title, app, dir="", windowtype="")
{
   DetectHiddenWindows, On
   If WinExist(title)
   {
         WinShow
    WinActivate
    return act
   }
   else
   {
      Run, %app%, %dir%, %windowtype%
      return ran
   }
}

;demosub
RunFirefox:
  IfWinNotExist, Mozilla Firefox
      Run "d:\ap\firefox\firefox.exe"
return



and the hotkey definition for emacs, firefox end EGB:

Code:
#e::RunRestoreApp("emacs", "d:\ap\gnuclientw.exe", "d:") ;;Emacs
#f::RunRestoreApp("Mozilla Firefox", "D:\ap\firefox\firefox.exe", "d:\ap\firefox", "max") ;;Firefox
#g::RunRestoreApp("Elektronisch Groene Boekje", "d:\ap\egb\egb.exe") ;;Groen boekske
!#f::RunRestoreApp("ahk_class MozillaWindowClass", "D:\ap\firefox\firefox.exe", "d:\ap\firefox", "max") ;;Firefox
^#f::gosub RunFirefox ;; Firefox with demosub


Works like a charm for emacs and egb.

#f -> firefox never is detected and thus always launches a new instance.
!#f -> if firefox is not top window, it gets detected and becomes top window
!#f -> if firefox is top window, a new instance is launched
^#f -> always launches a new instance, whether firefox is active top window or not


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 5th, 2005, 1:04 am 
Offline

Joined: November 13th, 2004, 4:08 am
Posts: 2951
Location: Minnesota
Put this code segment at the top of your script:

Code:
SetTitleMatchMode,2
return


The default title match mode only accepts an exact match. Setting it to '2' will allow it to be found anywhere in the title string. ("Firefox" or "Mozilla Firefox" will suffice, personally I use " - Mozilla Firefox" since it's guaranteed unique.)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 5th, 2005, 8:36 am 
Offline

Joined: June 4th, 2005, 11:56 am
Posts: 26
Location: Lokeren, Belgium
Thanks jonny, that explains why it didn't work: the 'Firefox' text doesn't start the title.

From the help file:
Quote:
SetTitleMatchMode, MatchMode

MatchMode : One of the following numbers:
1: A window's title must start with the specified WinTitle to be a match.
2: A window's title can contain WinTitle anywhere inside it to be a match.
3: A window's title must exactly match WinTitle to be a match.

If unspecified, TitleMatchMode defaults to 1 and fast.

Thanks again,
guivho.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 4 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group