Jump to content

ProcessWinGetTitles / ProcessWinSetTitle


alexpere
 Share

Recommended Posts

I have a proposal for two new functions...

ProcessWinGetTitles("process") - returns the titles of windows associated with a process in an array of strings

ProcessWinSetTitle("process", ???) - sets the title of a window associated with a process (not sure how the window would be specified)

I've already had a bit of a look at doing this myself using EnumWindows and GetWindowThreadProcessId but wanted other people's feedback first. :) I also haven't done any development on AutoIt before so not sure if there's a set way of getting approval and working on things.

Al.

Link to comment
Share on other sites

  • Administrators

There's been a WinGetTitles or WinList on the todo list for ages, just a matter of finding time to code it - I might do it next as it's a fairly big ommision. The process version would be a natural extension.

Link to comment
Share on other sites

  • 4 weeks later...
  • 4 weeks later...
  • 2 weeks later...

Just to close this out, here are my results which work great for simple programs with only one window (all I need):

Func _ProcessGetFirstWinTitle($process)
  ; Check given process actually exists
   $pid = ProcessExists($process)
   If Not $pid Then
      _Logthis("Given process does not exist: " & $process)
      Return 1
   EndIf
   
  ; Get window list
   $winList = WinList()
   
  ; Find which windows go with this process
   For $i = 0 To $winList[0][0] - 1
      $testPid = WinGetProcess($winList[$i][1])
      If $testPid = $pid Then
         Return $winList[$i][0]
      EndIf
   Next
   
   Return 0
EndFunc

Func _ProcessSetFirstWinTitle($process, $newTitle)
  ; Set window title as given by _ProcessGetFirstWinTitle()
   $title = _ProcessGetFirstWinTitle($process)
   WinSetTitle($title, "", $newTitle)
EndFunc

Thanks for pointing me in the right direction CyberSlug! :idiot:

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...