Jump to content
Sign in to follow this  
alexpere

ProcessWinGetTitles / ProcessWinSetTitle

Recommended Posts

alexpere

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
alexpere

Thanks Jon, that sounds great!

Share this post


Link to post
Share on other sites
TheWulf

awesome, that will come in handy

Share this post


Link to post
Share on other sites
alexpere

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
alexpere

Hi Jon,

Any news on when this functionality will be added to unstable? I can't wait for it... :idiot:

Alex.

Share this post


Link to post
Share on other sites
this-is-me

Already there.


Who else would I be?

Share this post


Link to post
Share on other sites
alexpere

:"> 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
alexpere

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
alexpere

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  

×