Jump to content

Recommended Posts

Posted

In a previous topic, i asked for help with a window change name GUI. Ive updated it a bit, so you can restore the old title of a specific window. Ive done that by adding a line in an ini file, witch is writing the old and the new name to a key. At this time, it only supports one window to be restored, as ive only maked one key for it in the ini file.

I would like to make a do...until or something witch is creating keys depending how many windows has been added to the GUIctrllist.

I dont have the script here, but i can give you a small example:

The ini file

[Restore]
Restore1="old title","new title"

So if the Script find lets say five windows, the ini would look like:

The ini file updated

[Restore]
Restore1="old title","new title"
Restore2="old title","new title"
Restore3="old title","new title"
Restore4="old title","new title"
Restore5="old title","new title"
Posted

hehe o:)

ouhmm... here it goes, as specific as possible :lmao:

When i run my "Windows Change Title" gui, all open windows in windows are being listed in a GUICtrlCreateList in my gui..

From that GUI, you can push a button, and rename the selected window. Quite simple.

To expand the program, ive made a "Restore orgininal titel" button witch, as you might guess retores the orgininal titlle. Ive coded that by writing the the ORIGINAL and the NEW title in a ini file. Allso quite simple.

Currently in can only Restore the title of one window, as i only wrote one line for it in the ini file. Called Restore1

[Restore]

Restore1=

The problem is, that if i should be able to restore the title of all the windows, i would have to manualy make a line in the ini file for each window. I would like to do it automaticly, depending on how many windows were listed in the GUI.

So, i would have to make a script that some how changes the key "Restore1=" to +1, so it would be "Restore2=" if two windows are listed.

So if two windows were listed, the ini would look like:

[Restore]

Restore1=

Restore2=

And if tree was listed, it would look like

[Restore]

Restore1=

Restore2=

Restore3=

By that, it would be generated automaticly, depending how many windows are listed...

Posted (edited)

ahhhhh.. ok lemme think for a bit lol ..

can u post ur WindowChangeTitle script ? or are u keeping closed.?

Edited by burrup

qq

Posted

pm me if u wanna keep closed ... also ... when u right to the ini file... does it write when u get the windows ... ie ... say theres is 7 windows active it writes 7 thiny's or does it only right to the file when u change a window title ... eg. theres 7 windows .. u change 2 titles of the windows ... so in the ini theres 2 thing's?

qq

Posted

Just a thought, i dunno if this works in INI files:

You could name the INI-entry after the new window title, so it looks like

[Restore]

new title1="old title1"

new title2="old title2"

new title3="old title3"

So you just read out the new window title from the INI and get the old title.

Another solution which may be more accurate would be to take the window handles as value names.

Hope this helps :lmao:

Posted (edited)

pm me if u wanna keep closed ... also ... when u right to the ini file... does it write when u get the windows ... ie ... say theres is 7 windows active it writes 7 thiny's or does it only right to the file when u change a window title ... eg. theres 7 windows .. u change 2 titles of the windows ... so in the ini theres 2 thing's?

<{POST_SNAPBACK}>

Now heres the code..

Ini file, put it on C:\

[restore]

restore=

#include <GUIConstants.au3>

Fileinstall("c:\restore.ini",@tempdir & "\restore.ini")

GUICreate("Window Title Changer", 400, 400)
GUICtrlCreateLabel("Visible Windows", 10, 5, 100, 20)
$list = GUICtrlCreateList("", 10, 20, 350, 350)
$b_Rename = GUICtrlCreateButton("Rename selected Window", 10, 370, 150, 20)
$restore = GUICtrlCreateButton("Restore original title", 235, 370, 150, 20)
$update = GUICtrlCreateButton("Update", 168, 370, 60, 20)


Func windows()
$var = WinList()
Dim $x = -1
For $i = 1 To $var[0][0]
   If $var[$i][0] = "" Then ContinueLoop
   If IsVisible($var[$i][1]) Then
      $x = $x + 1
      GUICtrlSetData($list, $var[$i][0] & "|")
   EndIf
Next
Endfunc

Windows()


GUISetState(@SW_SHOW)

While 1
    Sleep(25)


    $msg = GUIGetMsg()
    Select
    case $msg = $GUI_EVENT_CLOSE
         Filedelete(@tempdir & "\restore.ini")
         ExitLoop
     
    case $msg = $b_Rename
         $sOldTitle = GUICtrlRead($list)
         If StringStripWS($sOldTitle, 3) <> "" Then
            $sNewTitle = InputBox("Rename selected Window", "Enter the new name for the selected window." &@lf& "Current Name:" &@lf& $sOldTitle)
            If @error = 0 And StringStripWS($sNewTitle, 3) <> "" Then
               iniwrite(@tempdir & "\restore.ini","restore","restore", $sNewTitle & "," & $sOldTitle)
               WinSetTitle($sOldTitle, "", $sNewTitle)
               GUICtrlSetData($list, "")
               Windows()
            EndIf
        Else
              MsgBox(4096, "Nothing selected", "Please select a window to rename.", 3)
        EndIf
   
    case $msg = $restore 
            $sOldTitle = GUICtrlRead($list)
        If StringStripWS($sOldTitle, 3) <> "" Then
            $oldtitle = iniread(@tempdir & "\restore.ini","restore","restore", "notfound")
            $split = StringSplit ( $oldtitle, ",")
            WinSetTitle(GUICtrlread($list),"", $split[2])
            GUICtrlSetData($list, "")
            Windows()
        Else
            MsgBox(4096, "Nothing selected", "Please select a window to restore.", 3)
        EndIf
      
    case $msg = $update
            GUICtrlSetData($list, "")
            Windows()
        
    EndSelect
WEnd


Func IsVisible($handle)
   If BitAND(WinGetState($handle), 2) Then
      Return 1
   Else
      Return 0
   EndIf
EndFunc

it wirtes the ini file when im changeing the title, as you can see in the ini, only one key is made...

Edited by Wb-FreeKill
Posted

well i figured out how to add a new "restore" for each one u change .. pretty easy

say u change "window 1" to "one" and window 2 to "two"

the ini will say

[restore]
restore1=one,window 1
restore2=two,window 2
etc

ands a new restore every time u change a window ... hard part is changin all the windows back at once lol

qq

Posted (edited)

i cant do it sorry =( ... u got a lot of debuggin to do lol

to do the above add

$p = 0

to the top of the script

then in the case $msg = $b_Rename statment change

If @error = 0 And StringStripWS($sNewTitle, 3) <> "" Then
               iniwrite(@tempdir & "\restore.ini","restore","restore", $sNewTitle & "," & $sOldTitle)

to

If @error = 0 And StringStripWS($sNewTitle, 3) <> "" Then
               $p = $p + 1
               iniwrite(@tempdir & "\restore.ini","restore","restore" & $p, $sNewTitle & "," & $sOldTitle)

simple

Edited by burrup

qq

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
×
×
  • Create New...