koboltzz Posted April 15, 2016 Share Posted April 15, 2016 Hello, I have an idea (and partially already use it) for idling firefox on windows 10 if you minimize the firefox window (for saving a lot battery cause firefox has regulary spikes in cpu usage). For the moment I am using PsSuspend for 'firefox.exe' and 'plugin-container.exe' in a simple batch file that will execute if I do not move the mouse for some time. But now I want to go a step further: I want to create an autoit script that will check (loop) if there is a firefox window in foreground. If not, it will execute PsSuspend to suspend firefox. The tricky part is: It would be nice if the same script will notice when I try to get firefox back to foreground and unfreeze (same with PsSuspend) firefox. Any hint/help? Link to comment Share on other sites More sharing options...
AutoBert Posted April 15, 2016 Share Posted April 15, 2016 Have a look in AutoItHelpfile => WinActive. Link to comment Share on other sites More sharing options...
koboltzz Posted April 15, 2016 Author Share Posted April 15, 2016 Thank you, I tried that. What about? I need a negation somewhere there. At that moment it will only execute once firefox is launched. Local $tvHandle = 0 while True $tvHandle = WinWait("*-Nightly") ;I am using Firefox Nightly if Not ($tvHandle = 0) Then WinActivate ("*-Nightly") ;if there is none it activates the window sleep(20) ;some delay to prevent errors or something like that launch batch? EndIf WEnd Link to comment Share on other sites More sharing options...
Bert Posted April 17, 2016 Share Posted April 17, 2016 I have a different question - what are you running in the window in firefox? This seems to me you are watching a website. I have firefox up on my laptop all the time and I have no issue. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
koboltzz Posted April 17, 2016 Author Share Posted April 17, 2016 If you will look closer, you will see this (cpu spikes becomes higher the more tabs are opened due to javascript garbage collection) Picture Some Browser like IE11 complete freeze itself if you minimize them. But firefox don't do that and always 'works' even if unused. If you have a laptop battery that only lasts ~ 3h then you might be interested in optimizing it. Link to comment Share on other sites More sharing options...
Bert Posted April 18, 2016 Share Posted April 18, 2016 ok - have you tried using chrome to see if that solves your issue? The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
koboltzz Posted April 18, 2016 Author Share Posted April 18, 2016 (edited) Yes, but I don't like the tab management in chrome if you have more than 30 tabs opened. Basically it's not 'my' issue. It's how firefox is working, chrome is a little bit better in this regard and IE11 is best. The last both are not a good choice in my opinion. (Forced) idling firefox if mouse is not moved works perfectly but I thought it would be possible someone can help me detecting if firefox is not in foreground anymore. Edited April 18, 2016 by koboltzz Link to comment Share on other sites More sharing options...
MuffinMan Posted April 18, 2016 Share Posted April 18, 2016 You could use a loop with WinGetState to see if your firefox window is running minimized - if so, run your suspend command, and when it's not un-suspend it. Link to comment Share on other sites More sharing options...
Danp2 Posted April 18, 2016 Share Posted April 18, 2016 There are FF add-ons that will handle this for you... Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Trong Posted April 19, 2016 Share Posted April 19, 2016 Try to do this simple thing: Regards, Link to comment Share on other sites More sharing options...
JohnOne Posted April 19, 2016 Share Posted April 19, 2016 13 hours ago, MuffinMan said: You could use a loop with WinGetState to see if your firefox window is running minimized - if so, run your suspend command, and when it's not un-suspend it. ^^ This. Only keep track of whether It is already suspended or not, before you run your utility. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now