Jump to content

Winactivate Firefox.exe & Chrome.exe


 Share

Recommended Posts

Hey guys, I tried search but most of the topics are a bit too advanced for what I'm looking for, I'm just a simple hobbyist.

Anyway, basically my friend constantly leaves his browser open and it really drives me crazy so I'm writing a simple program that, after the computer is out of use for 30 minutes, activates each browser, creates a bookmark folder with everything open, then kills the process.

My problem is, the only way I know to activate a window is to use winactivate, but in order to use it properly I think I need to know the name of the window.. gmail, functions, etc etc etc.. and I just generally want to activate firefox or chrome and I don't really know how.

I'll link my code to give anyone interested an idea of what I'm doing.. also, I just realized that if multiple windows exist I'll need to just use WinClose and use processexist to see if I need to loop again... I'll work on that. I'll get to that later, shouldn't be an issue.

If you see any other problems with my code feel free, like I say I'm not a programmer by nature, mostly do engineering and physics sort of stuff so I apologize for my amateur writing.

;msgbox(0,"",$x[0],0)
;msgbox(0,"",$x[1],0)
Func bookmark()
    WinActivate("Firefox", "Firefox")
    Send("{CTRLDOWN}{LSHIFT}d")
    Sleep(1500)
    Send(@mon&"."&@mday&"."&@hour&"."&@min&"."&"sec"&"{ENTER}")
    Sleep(1500)
    ProcessClose("firefox.exe")
    WinActivate("Chrome", "Chrome")
    Send("{CTRLDOWN}{LSHIFT}d")
    Sleep(1500)
    Send(@mon&"."&@mday&"."&@hour&"."&@min&"."&@sec&"{ENTER}")
    Sleep(1500)
    ProcessClose("chrome.exe")
    MsgBox(262144,'Debug line ~' & @ScriptLineNumber,'Selection:' & @lf & ' ProcessClose("chrome.exe")' & @lf & @lf & 'Return:' & @lf &  ProcessClose("chrome.exe")) ;### Debug MSGBOX
    ProcessClose("chrome.exe")
EndFunc   ;==>bookmark
While 1
    $old = MouseGetPos()
    $y = 1
    While $y <> 2
        Sleep(60000 * 0.25)
        $new = MouseGetPos()
        If $new[0] == $old[0] And $new[1] == $old[1] Then
            bookmark()
        EndIf
    $y = 2
    WEnd
WEnd
Link to comment
Share on other sites

Have a look at the WinTitieMatchMode Option (Opt) <-helpfile

Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase

WinActivate("Mozilla Firefox")

;etc...

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

Have a look at the WinTitieMatchMode Option (Opt) <-helpfile

Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase

WinActivate("Mozilla Firefox")

;etc...

Thank you, I will look into it next chance I get to break from my work and work on my code :graduated:

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...