Jump to content
Sign in to follow this  
alexpere

ProcessWinGetTitles / ProcessWinSetTitle

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.

Share this post


Link to post
Share on other sites

I really needed it so I've coded in ProcessWinGetTitles() :) . I'm not sure if I'll get to ProcessWinSetTitle() though.

Code submission to Jon forthcoming...

Alex.

Share this post


Link to post
Share on other sites

:"> Are you able to give me a couple of examples of how to use it? I can't find anything in the docs of the latest unstable except for WinGetProcess.

Help much appreciated! :idiot:

Share this post


Link to post
Share on other sites

Thanks CyberSlug, I hadn't thought of that. Hopefully it works!

Jon e-mailed me to say he was putting it in but as I can't find it and unstable has code freeze I'm stressing a bit!! :idiot:

Share this post


Link to post
Share on other sites

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:

Share this post


Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...