Rajat
Joined: 28 Mar 2004 Posts: 1717
|
Posted: Mon Jul 05, 2004 5:06 am Post subject: Auto GUI script updater |
|
|
The background:
Larry's Au3GUIXP is cool for almost all GUI needs, but its a pain to tweak the script to properly position the controls on the face of the GUI to make it look proper. Larry recognised it and created the GUIasst script that moved/resized controls and showed the new co-ordinates that should be put in the script.
I (being lazy) though that it'd be better if someone updated the script as well, so i made an ahk script that, once GUIasst changes the controls as reqd, updates the script automatically.
Firstly this script doesn't replace larry's GUIasst, it works with it.
Usage:
-Create the script with GUI that needs some control size/placement adjustment.
-Run this script, select your script (GUIasst will be run automatically, should be in same folder)
-When the GUI appears, before making any changes, press 'Show Control Position Data'
-Make all changes you need to.
-Press 'Show Control Position Data' again.
thats it. if all went well, the changes should be reflected in the script now.
and yeah, the original script is backed up before making any changes.
get Au3GUIXP and GUIasst at:
http://www.hiddensoft.com/fileman/users/Larry/
| Code: |
SetBatchLines, 10ms
FileSelectFile, file, 1, %a_scriptdir%, Select Script File`n
ifnotexist,%file%,exit
run,%comspec% /c "%file%",,hide
run, e:\dos\batch\guiasst.exe
winwait,AU3GUI Assistant,Move (Current Control) Resize
SplashTextOn, 350, 50, Getting original data,Press 'Show Control Position Data'
WinMove, Getting original data,, 200, 10
winwait,AU3GUI Assistant OBJ Info
SplashTextOff
;get original control data and write it to file in proper format
FileDelete, %a_scriptdir%\orig.txt
ControlGetText, controls, Edit1, AU3GUI Assistant OBJ Info
Loop, parse, controls, `n
{
StringReplace, LoopField, A_LoopField,`n,,all
StringReplace, LoopField, LoopField,`r,,all
StringGetPos, colonpos, LoopField, :
StringTrimLeft, LoopField, LoopField, %colonpos%
StringReplace, LoopField, LoopField,:,%a_space%,all
StringReplace, LoopField, LoopField, %a_tab%,,all
StringReplace, LoopField, LoopField,%a_space%,,all
IfNotInString, LoopField, `,,break
;proper formatting
StringReplace, LoopField, LoopField,`,,|y=
StringReplace, LoopField, LoopField,`,,|w=
StringReplace, LoopField, LoopField,`,,|h=
FileAppend, x=%LoopField%`n, %a_scriptdir%\orig.txt
}
;get updated control data and write it to file in proper format
winwaitclose,AU3GUI Assistant OBJ Info
winwait,AU3GUI Assistant OBJ Info
FileDelete, %a_scriptdir%\new.txt
ControlGetText, controls2, Edit1, AU3GUI Assistant OBJ Info
Loop, parse, controls2, `n
{
StringReplace, LoopField, A_LoopField,`n,,all
StringReplace, LoopField, LoopField,`r,,all
StringGetPos, colonpos, LoopField, :
StringTrimLeft, LoopField, LoopField, %colonpos%
StringReplace, LoopField, LoopField,:,%a_space%,all
StringReplace, LoopField, LoopField, %a_tab%,,all
StringReplace, LoopField, LoopField,%a_space%,,all
IfNotInString, LoopField, `,,break
;proper formatting
StringReplace, LoopField, LoopField,`,,|y=
StringReplace, LoopField, LoopField,`,,|w=
StringReplace, LoopField, LoopField,`,,|h=
FileAppend, x=%LoopField%`n, %a_scriptdir%\new.txt
}
;writing updates to new file.
FileDelete, %file%.bak
FileCopy, %file%, %file%.bak
setenv, newfile, %file%.new
loop:
envadd, currline, 1
FileReadline, line, %file%, %currline%
ifequal, errorlevel, 1, setenv, loopend, yes
Loop, Read, %a_scriptdir%\orig.txt
{
StringGetPos, pos, A_LoopReadLine, |w=
StringLeft, XY, A_LoopReadLine, %pos%
StringTrimLeft, WH, A_LoopReadLine, %pos%
FileReadline, newline, %a_scriptdir%\new.txt, %a_index%
StringLeft, nXY, newline, %pos%
StringTrimLeft, nWH, newline, %pos%
ifinstring,line,%XY%%WH%, FileReadline, newline, %a_scriptdir%\new.txt, %a_index%
ifinstring,line,%XY%%WH%, StringReplace, line, line, %XY%%WH%, %newline%
ifnotinstring,line,%XY%%WH%,ifinstring,line,%XY%, FileReadline, newline, %a_scriptdir%\new.txt, %a_index%
ifnotinstring,line,%XY%%WH%,ifinstring,line,%XY%, StringReplace, line, line, %XY%, %newline%
}
ifnotequal, loopend, yes, Fileappend, %line%`n, %newfile%
ifnotequal, loopend, yes, goto, loop
setenv, loopend, no
;cleanup
FileDelete, %a_scriptdir%\orig.txt
FileDelete, %a_scriptdir%\new.txt
FileMove, %newfile%, %file% ,1
Msgbox, 0, GUI Updater, GUI updated.
|
_________________
 |
|