AutoHotkey Community

It is currently May 26th, 2012, 3:54 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: Keeping the Fox quiet...
PostPosted: April 23rd, 2008, 6:08 pm 
Offline

Joined: March 3rd, 2008, 11:09 pm
Posts: 34
Hello.

I recently created a handy script that launches websites in firefox with a delay of some seconds. For the first site, I used (here I put google for the url)

Run, firefox.exe -new-window www.google.com

How on earth do I minimize that window? I tried Run, blah blah, , Min... Tries to minimize but the Fox pops up again. I tried WinMinimize, it goes down and then reopens... I need two WinMinimize to really keep the Fox down... What should I do?

Also, the next links go

Run, firefox.exe www.google.com

1. How can I make absolutely sure that this link opens in the same window (session) as the first one, and not in the Firefox window (different session) that I might be using?

2. How on earth do I make it go to the site without maximizing?

Thanks a lot in advance :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 23rd, 2008, 9:59 pm 
Offline

Joined: December 11th, 2006, 4:11 pm
Posts: 242
Location: Orlando, FL
Because I slighty crazy, I'm gonna answer your second question first.

Instead of using the "Run" command, try this:

Code:
WinWait, Firefox   
WinActivate, Firefox
SLEEP 300
SEND, ^o
Clipboard = "Your next website here"
WinWait, Open
SLEEP 100
SEND, ^v{ENTER}


Secondly (or firstly, whatever), you can minimize the window as soon as it comes up by using the "WinHide" command. So, using your example, your new code would look something like this:

Code:
Run, firefox.exe  www.google.com
WinWaitActive, Firefox
WinHide, A
SLEEP 300
;Random stuffus, aka crap you didn't tell us about
SEND, ^o
Clipboard = "Your next website here"
WinWait, Open
SLEEP 100
SEND, ^v{ENTER}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 24th, 2008, 4:36 pm 
Offline

Joined: March 3rd, 2008, 11:09 pm
Posts: 34
Hi and thanks for the reply. However, how would "Ctrl - O" (OPEN) help me? I got the part about minimizing it with winhide , and I'll try that. (Even though I think it will fail just like WinMinimize). But could you explain the first part of your answer please?

Also, I don't really see how that would keep the sites in the same session - firefox window. I guess you meant ctrl + c (COPY), and then paste the url maybe?? But that does not necessarily tell the script to send that command to that specific FF window.... Kinda confused here..


Thanks


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 26th, 2008, 3:24 pm 
Offline

Joined: March 3rd, 2008, 11:09 pm
Posts: 34
No more ideas on this? I would really appreciate some help :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 26th, 2008, 5:47 pm 
Offline

Joined: June 27th, 2006, 2:38 pm
Posts: 385
Location: Canada
Code:
QuietFoxLaunch:
Run, firefox.exe  http://www.google.ca ,,Hide UseErrorLevel
If ErrorLevel
   return ; Script failed to launch the browser/site
Else
   goto QuietFoxControl
return

QuietFoxControl:
; You need to use control send, send message, etc. to control the hidden firefox window
return


Hope that helped.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 28th, 2008, 4:43 pm 
Offline

Joined: March 3rd, 2008, 11:09 pm
Posts: 34
Unfortunately that does not seem to work... Firefox is simply ignoring the "Hide" or "Min" command. Try it for yourself.

The idea is good though: I will "try" to control the window with controlsend...

Any idea why the fox is ignoring the above commands?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 28th, 2008, 6:44 pm 
Try this

Msgbox, Minimize the Firefox Window then Click OK to Continue


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: April 28th, 2008, 10:49 pm 
Offline

Joined: June 27th, 2006, 2:38 pm
Posts: 385
Location: Canada
ggwwtt, you are ruining his evil plan with your user-aware "code". :P :lol: 8)

Anyways, I tried to improve the code:

(Failed attempt):
Code:
#Singleinstance,force
#Persistent

FoxPath = %A_ProgramFiles%\Mozilla Firefox\firefox.exe

gosub QuietFoxLaunch
return

QuietFoxLaunch:
IfExist, %FoxPath%
  Run, "%FoxPath%",,UseErrorLevel Min Hide,FoxID
If ErrorLevel
{
  Msgbox, Firefox could not be launched. FAIL.
  exitapp
}
Else IfNotExist %FoxPath%
{
  Msgbox, Firefox could not be found. FAIL.
  ExitApp
}
If FoxID
  goto Target
Else
{
  Msgbox, Failed to get Firefox's PID. FAIL.
  ExitApp
}
return

Target:
DetectHiddenWindows,On
Loop
{
  If A_Index > 500
  {
    Msgbox, There must've been a problem detecting Firefox's PID.
    ExitApp
  }
  IfWinNotExist, ahk_pid %FoxID%
  {
    Sleep 20
    continue
  }
  IfWinExist, ahk_pid %FoxID%
  {
    WinHide, ahk_pid %FoxID%
    Msgbox Press OK to terminate the script & hidden browser.
    WinKill, ahk_pid %FoxID%
    ExitApp
  }
}
return


But, it appears the PID of the newly launched Firefox can't be detected nor operated on. :cry:

Sorry, I tried.


PS. Launched Firefox with the "Min" switch actually works, compared to the "Hide" switch.

It would be possible to make a script that launches firefox then has a loop using WinHide to hide all "Mozilla Firefox" containing windows, but I don't think it would be of much use as:
1. If the user was already running firefox, his browser is going to disappear and he's gonna be pissssed.
2. You might operate on any previous opened browsers, which is also a fail.
3. The newly launched browser's PID doesn't seem to want to co-operate, so I don't think you could control it very well, anyways.

Hope this helped.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 29th, 2008, 1:29 am 
Use Firefox extensions instead:
iMacros + Minimize 2 Tray can do what want.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 1st, 2008, 6:45 pm 
Offline

Joined: March 3rd, 2008, 11:09 pm
Posts: 34
@Conquer:
haha, not really an evil plan =) just a commodity to have the fox out of the way while it's visiting the sites it should visit. I'll try Min again, but I think I tried and failed... :P

@TimFlash:
maybe that's the only alternative... But it's strange that AHK can't do something so simple :P


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Exabot [Bot] and 26 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