Jump to content

Func using Process?


Recommended Posts

Hello, I am fairly new to AutoIT I have been teaching myself and reading a few tutorials to get the hang of it all. Pretty much what I wanted to know if there is a variable for process'? Right now I am using $WindowName = "Window Name Here"

Now I want to make it run off a process as some programs such are Internet Browsers have a changing window name depending on what website you are on so is it possible to use firefox as a variable similar to $WindowName but $ProcessCommandHere = "Firefox.exe"

Thanks for the help

Link to comment
Share on other sites

Someone pointed me in the right direction this is what I have so far, but it only runs once. If I try to run it again it will not rename its self a second time. Any help?

$NEW_TITLE = "New name here"
     
    While 1
            If ProcessExists("firefox.exe") Then
                    $windows = WinList()
                    $number_of_windows = $windows[0][0]
     
                    For $i = 0 To $number_of_windows Step 1
                            If StringInStr($windows[$i][0], "firefox") > 1 Then
                                    WinSetTitle($windows[$i][0], "", $NEW_TITLE)
                            EndIf
                    Next
     
                    While 1
                            Sleep(1000)
                            If not ProcessExists("firefox.exe") Then
                                    ExitLoop
                            EndIf
                    WEnd
            EndIf
    Sleep(1000)
    WEnd
Edited by Traxex84
Link to comment
Share on other sites

Because the script enter in the second loop and keeps there until the process stop of existing.

Try this.

$NEW_TITLE = "New name here"

While 1
    If ProcessExists("firefox.exe") Then
        $windows = WinList()
        $number_of_windows = $windows[0][0]

        For $i = 0 To $number_of_windows Step 1
            If StringInStr($windows[$i][0], "firefox") > 1 Then
                WinSetTitle($windows[$i][0], "", $NEW_TITLE)
            EndIf
        Next

;~      While 1
;~          Sleep(1000)
;~          If Not ProcessExists("firefox.exe") Then
;~              ExitLoop
;~          EndIf
;~      WEnd
    EndIf
    Sleep(1000)

I only commented out the lines of the second loop.

A Tip: you can tidy your scripts using the tidy tool inside the SciTe(If you use SciTe as editor)

SciTE ---> Tools ----> Tidy AutoIt Source

Another Tip: You can use WinExists to look the window by his class and check any instance of this.

And Other tip: maybe you can put the existance of the window like the condition for the loop.

Example:

While WinExists("CLASS:MozillaUIWindowClass]")
;Script here
Wend
Edited by monoscout999
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...