Sign in to follow this  
Followers 0
Klexen

WindowSetTitle Help.

11 posts in this topic

I have a window change title, but then if I click a link within that window it changes back to default title. Is there a way to detect if the set title was changed to the original then set it back to what I want it?

Share this post


Link to post
Share on other sites



Global $hWatchHwnd = WinGetHandle('Title Of Window To Change')
Global $sChange = 'My Title That This SOB Keeps Changing!'
AdlibEnable('_WinWatchTitleByHwnd', 100)

While 1
    ;Rest of script
WEnd

Func _WinWatchTitleByHwnd()
    If WinGetTitle($hWatchHwnd) <> $sChange Then WinSetTitle($hWatchHwnd, '', $sChange)
    Return ''
EndFuncoÝ÷ ØêÚºÚ"µÍÚ[ÛYH Ø^K]LÉÝÂÛØ[   ÌÍÜÑVUÕØ]ÚH  ÌÎNÕÕ^IÌÎNÂÛØ[ ÌÍÜÐÚ[ÙHH ÌÎNÓ^H]H]ÈÓÐÙYÈÚ[Ú[ÉÌÌÎÉÌÎNÂYX[XJ ÌÎN×ÕÚ[Ø]Ú]PTQ   ÌÎNËL
BÚ[HBNÔÝÙØÜÑ[[ÈÕÚ[Ø]Ú]PTQ

BSØØ[ ÌÍØTHØÙÜÓÝ
    ÌÍÜÑVUÕØ]Ú
BSØØ[ ÌÍØUÓHÚ[Ý

BQÜ    ÌÍÚPÐÈHHÈPÝ[
    ÌÍØT
HHBBQÜ ÌÍÞÐÈHHÈPÝ[
    ÌÍØUÓ
HHBBBRYÚ[Ù]ØÙÜÊ   ÌÍØUÓÉÌÍÞÐ×VÌWJHH    ÌÍØTÉÌÍÚPÐ×VÌWH[ÂBBBP]S
Ú[Ù]Ý]J  ÌÍØUÓÉÌÍÞÐ×VÌWJKH[BBBRY  ÌÍØUÓÉÌÍÞÐ×VÌH   ÉÝÈ  ÌÍÜÐÚ[ÙH[Ú[Ù]]J ÌÍØUÓÉÌÍÞÐ×VÌWK  ÌÎNÉÌÎNË  ÌÍÜÐÚ[ÙJBBBQ[YBS^S^T] ÌÎNÉÌÎNÂ[[


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

WTF :whistle: ... disregard the #include <array.au3>... I tried to edit it, but the code came out all garbled.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

...I tried to edit it, but the code came out all garbled.

You can:

edit the post

cut all of the code and spaces between the autoit tags

submit the modified post

edit the post again

paste the code between the tags

edit the code as desired

submit the modified post

simple... :-(

I had never tried those "simple" steps on a post that had two blocks of code, but it worked in the test thread - just leave the other code block alone during those steps.


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Thanks Smoke... I was wondering, whats the different between using ' and " ?

The only problem is I need to have two windows with the same name given. One the function I have that launches the windows, I have it change the title. Under function one I have it change the name To Window #1 and the second function opens the same name window but changes the name to Window #2.

The reason I change the name is so that I can set a hotkey to activate the two seperate windows.

For instance.. I have Alt+1 Switch to Window #1 and Alt+2 switch to Window #2. Well when I'm using window number one, and open the link it changes back to the Default name, Well if I click a link in Window #2 the name changes to default as well. Now they both share the same default name and the hotkey no longer activates them.

I'm lost on how to make it so If Window #1 exits then Changes then change back to Window #1. Then if Window #2 changes then change back to Window #2. If they both change or one changes how will I know Which one to set back to Window #1 or Window #2 Since they both share default name?

Wow I hope this makes sense. Again thanks so much!

Is there a limit on how many times you use an adlibenable in a program? I already have one goin.. I don't think there is a problem, just double checking. I can't test till I get to work tomorrow or I would just test it now.

Edited by Klexen

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Thanks Smoke... I was wondering, whats the different between using ' and " ?

The only problem is I need to have two windows with the same name given. One the function I have that launches the windows, I have it change the title. Under function one I have it change the name To Window #1 and the second function opens the same name window but changes the name to Window #2.

The reason I change the name is so that I can set a hotkey to activate the two seperate windows.

For instance.. I have Alt+1 Switch to Window #1 and Alt+2 switch to Window #2. Well when I'm using window number one, and open the link it changes back to the Default name, Well if I click a link in Window #2 the name changes to default as well. Now they both share the same default name and the hotkey no longer activates them.

I'm lost on how to make it so If Window #1 exits then Changes then change back to Window #1. Then if Window #2 changes then change back to Window #2. If they both change or one changes how will I know Which one to set back to Window #1 or Window #2 Since they both share default name?

Wow I hope this makes sense. Again thanks so much!

Is there a limit on how many times you use an adlibenable in a program? I already have one goin.. I don't think there is a problem, just double checking. I can't test till I get to work tomorrow or I would just test it now.

Since you haven't shown any effort on your own of what you've attempted and failed at, I'll let you chew on this with "few" comments:
Global $hMainWinNotToChange, $hWinToWatch
Global $sMainTitle = 'I am a Title', $sChangeTitle = 'Change that SOB Now!!'
;Example seeing I don't know what program you are talking about
$hGUI = GUICreate('I am a Title', 200, 50, Random(1, 200), Random(200, 400))
$hButton = GUICtrlCreateButton('Push To Activate 2nd Window', 10, 10, 180, 30)
GUISetState()
;The above would not be in your script obviously
AdlibEnable('_AdlibManager', 100)
HotKeySet('!1', '_HotKeyManager')
HotKeySet('!2', '_HotKeyManager')

$hMainWinNotToChange = _WinGetByProcess('AutoIt3.exe', $sMainTitle);This would be under what you would launch right after you did the first window

While 1
    Switch GUIGetMsg()
        Case -3
            Exit
        Case $hButton
            If UBound(WinList($sMainTitle)) - 1 < 2 And UBound(WinList($sChangeTitle)) - 1 = 0 Then
                ;Launch 2nd Window
                Run('"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & @ScriptFullPath & '"', '', @SW_HIDE)
                ;You would delete the above and replace it with your own function, this is just a working example
                $hWinToWatch = _WinReturnSecondHandle($sMainTitle, $hMainWinNotToChange)
            EndIf
    EndSwitch
WEnd


Func _HotKeyManager()
    Switch @HotKeyPressed
        Case '!1'
            WinActivate($hMainWinNotToChange)
        Case '!2'
            WinActivate($hWinToWatch)
    EndSwitch
    Return
EndFunc

Func _AdlibManager()
    If $hWinToWatch And WinExists($hWinToWatch) = 0 Then $hWinToWatch = ''
    If $hWinToWatch Then
        If WinExists($hWinToWatch) And _
            WinGetTitle($hWinToWatch) <> $sChangeTitle Then
            WinSetTitle($hWinToWatch, '', $sChangeTitle)
        EndIf
    EndIf
    Return ''
EndFunc

Func _WinReturnSecondHandle($nTitle, $hMain)
    Local $aWL = WinList($nTitle)
    If UBound($aWL) - 1 < 2 Then
        Do
            $aWL = WinList($nTitle)
            Sleep(10)
        Until UBound($aWL) - 1 = 2
    EndIf
    For $iCC = 1 To UBound($aWL) - 1
        If BitAND(WinGetState($aWL[$iCC][1]), 2) And _
            $hMainWinNotToChange <> $aWL[$iCC][1] Then
            WinSetTitle($aWL[$iCC][1], '', $sChangeTitle)
            Return $aWL[$iCC][1]
        EndIf
    Next
EndFunc

Func _WinGetByProcess($sExe, $nTitle)
    Local $aPL = ProcessList($sExe)
    Local $aWL = WinList($nTitle)
    For $iCC = 1 To UBound($aWL) - 1
        For $xCC = 1 To UBound($aPL) - 1
            If WinGetProcess($aWL[$iCC][1]) = $aPL[$iCC][1] And _
                BitAND(WinGetState($aWL[$iCC][1]), 2) Then
                Return $aWL[$iCC][1]
            EndIf
        Next
    Next
EndFunc
You'll find using the handles, it doesn't matter what the title is :whistle:... I just did the above to humor you. Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

What im trying to do is open 2 IE windows with the title "DellServ 6.17" When I launch them I have each one change their name...

HotKeySet("!1", "ActiveDellServ1")
HotKeySet("!2", "ActiveDellServ2")
HotKeySet("!3", "ActiveDSN")
HotKeySet("!4", "ActiveNotepad")oÝ÷ ØèçîËb¢xZ½â!j÷ºÚ"µÍÌÍÜÕTH    ][ÝÚËÙY[ÙË[ÛÛKÙ[ÙÚÜÚ[^Ü   ][ÝÂIÌÍÛÒQHHÒQPÜX]J ÌÍÜÕT
BIÌÍÒÓHÒQTÜQÙ]
    ÌÍÛÒQK  ][ÝÚÛ    ][ÝÊBUÚ[Ù]Ý]J  ÌÍÒÓ    ][ÝÉ][ÝËÕ×ÓPVSRVJBWÒQPXÝ[Û    ÌÍÛÒQK  ][ÝÝÚXI][ÝÊBWÒQSØYØZ]
    ÌÍÛÒQJBSÜ
    ][ÝÕÚ[]SX]Ú[ÙI][ÝËJBUÚ[ØZ]XÝ]J    ][ÝÑ[Ù
MÉ][ÝÊBUÚ[XÝ]]J    ][ÝÑ[Ù][ÝÊBUÚ[Ù]]J   ][ÝÑ[Ù
MÉ][ÝË   ][ÝÉ][ÝË    ][ÝÑ[ÙÌI][ÝÊoÝ÷ Ù8^Ø^¢÷«~éܶ*'"¯y«­¢+ØÀÌØíÍUI0ôÅÕ½Ðí¡ÑÑÀè¼½±±ÍÉعÕ̹±°¹½´½±±ÍÉؽ©ÍÀ½¥¹à¹©ÍÀÅÕ½Ðì($ÀÌØí½%ô}%
ÉÑ ÀÌØíÍUI0°À°À°À¤($ÀÌØí!]9ô}%AɽÁÉÑåÐ ÀÌØí½%°ÅÕ½Ðí¡Ý¹ÅÕ½Ðì¤(%]¥¹MÑMÑÑ ÀÌØí!]9°ÅÕ½ÐìÅÕ½Ðì°M]}5a%5%i¤(%}%Ñ¥½¸ ÀÌØí½%°ÅÕ½Ðí٥ͥ±ÅÕ½Ðì¤(%}%1½]¥Ð ÀÌØí½%¤((%=ÁÐ ÅÕ½Ðí]¥¹Q¥Ñ±5Ñ¡5½ÅÕ½Ðì°Ä¤(%]¥¹]¥ÑÑ¥Ù ÅÕ½Ðí±±MÉØظÄÜÅÕ½Ðì¤((%]¥¹Ñ¥ÙÑ ÅÕ½Ðí±±MÉØÅÕ½Ðì¤(%]¥¹MÑQ¥Ñ± ÅÕ½Ðí±±MÉØظÄÜÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½Ðí±±MÉØÈÅÕ½ÐìoÝ÷ Ù*~׫¶­"¯{j¶¬jg§v,{¦Ûaz*çjg¢°7¥'«¿V§t7¥'«¿e¡Èb±Ê(l¡¢ÙÊÌ(®H+y«SéÈrX©bL"¶§
éeIêïÖÃzYRz»ö¶°whÃ¥ÈZ¢·l¶+ey¶Ú*ºCzYRz»ú׺®¢Û(-èh¶G²Â÷öÜ(®D¨"wvÚ!j÷~éܶ*'z0ðÞT®ýpjÇ!jxvØ^Ú©àzØZ¶Þm§$¶ÞT®ýb|7¥'«¿l±ÈZ¶§«Þ×!jxm§$¶ÞT®ýH|h¶¬jëh×6Global $hWatchHwnd = WinGetHandle('DellServ 6.17')
Global $sChange = 'DellServ #1' ; It doesn't know if DellServ #1 was changed or DellServ #2
AdlibEnable('_WinWatchTitleByHwnd', 100)

While 1
    ;Rest of script
WEnd

Func _WinWatchTitleByHwnd()
    If WinGetTitle($hWatchHwnd) <> $sChange Then WinSetTitle($hWatchHwnd, '', $sChange)
    Return ''
EndFunc

Does this make sense? Your other script would probably work, but it's a bit over my head. Heh, as I'm sure you knew that.

Edited by Klexen

Share this post


Link to post
Share on other sites

***BUMP FOR EDIT****

Share this post


Link to post
Share on other sites

As SmOke_N pointed out back in post #6, use the window handles instead of the titles. The handles never change no matter how many times the titles do...

:whistle:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

As SmOke_N pointed out back in post #6, use the window handles instead of the titles. The handles never change no matter how many times the titles do...

:whistle:

So would this work?

HotKeySet("!1", "ActiveDellServ1")
HotKeySet("!2", "ActiveDellServ2")

Global $DellServWindow1 = WinGetHandle("DellServ 6.17")
Global $DellServWindow2 = WinGetHandle("DellServ 6.17")

Func ActiveDellServ1()
    WinActivate($DellServWindow1)
EndFunc   ;==>ActiveDellServ1

Func ActiveDellServ2()
    WinActivate($DellServWindow2)
EndFunc   ;==>ActiveDellServ2
Edited by Klexen

Share this post


Link to post
Share on other sites

So would this work?

HotKeySet("!1", "ActiveDellServ1")
HotKeySet("!2", "ActiveDellServ2")

Global $DellServWindow1 = WinGetHandle("DellServ 6.17")
Global $DellServWindow2 = WinGetHandle("DellServ 6.17")

Func ActiveDellServ1()
    WinActivate($DellServWindow1)
EndFunc   ;==>ActiveDellServ1

Func ActiveDellServ2()
    WinActivate($DellServWindow2)
EndFunc   ;==>ActiveDellServ2oÝ÷ Ûú®¢×nëg¢Ú®×¢ØajwezÌ"VÞ¶¬jg¢éÞyÛhºÇªºVtâ¶Wj×!2^ªê-

:whistle:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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  
Followers 0