abarth Posted June 6, 2007 Share Posted June 6, 2007 (edited) Hello I have 2 identical applications with different filename and gui name. The Script is this (little big): expandcollapse popup;_GUICtrlListView.au3 _126 #include <GuiConstants.au3> #include <GuiListView.au3> #include <misc.au3> #include <file.au3> #include <Process.au3> #Include <GuiTab.au3> #include <Constants.au3> #include <Date.au3> #Include <Array.au3> Global $Paused HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{ESC}", "Terminate") Func Terminate() Exit 0 EndFunc Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc ;;;;;;;;;;;;;; DIMS ;;;;;;;;;;;;;; dim $y,$t,$g dim $directories[8000][60][3][10],$x,$w,$z,$q dim $line,$temparray,$temparray2 dim $pair dim $ln,$r,$l dim $count dim $onoff dim $errors,$TextFileName dim $lines[1000],$file,$Button_4,$Button_5 dim $synclines[300][15][100] ; the sync lines ! aa/data/sync line # dim $startdir dim $searchid dim $createsubs dim $checksubs dim $log dim $splash dim $pathadd dim $scriptini dim $msg,$array dim $place dim $server dim $plays[10][100][100],$movies[10][100][100],$music[10][100][100] dim $buttons[300],$orders[500][10],$orders2[500][10] dim $filez[3000][500][7] ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;; READ THE ini FILE ;;;;;;;;;;;;;;;;; $scriptini=@ScriptName $scriptini=stringreplace($scriptini,".au3","") $scriptini=stringreplace($scriptini,".exe","") ;msgbox(0,$scriptini,@ScriptName) $TextFileName = $scriptini&".ini" if FileExists($TextFileName)=True Then ;GUICreate("Abarth: "&$scriptini,@DesktopWidth/2,@DesktopHeight/2) ; will create a dialog box that when displayed is centered ;GUISetBkColor(-1,0x00ff00) ;GUISetBkColor(0xaabbff) ;GUICtrlSetBkColor(-1,0x00ff00) ; Green ;Opt("GUICoordMode",2) ;$Button_4 = GUICtrlCreateButton ("Splash off", 1,1,100,20) ;$Button_5 = GUICtrlCreateButton ("Splash on", 0,-1,100,20) ;SplashTextOn("Timer","0 files",125,25,500,0) ;GUISetState () ; will display an dialog box with 2 button $file = FileOpen($TextFileName, 0) $server=0 $onoff=0 $place="" $errors=0 $x=0 $y=0 $count=0 If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit Else While 1 ;for $x=1 to 1000000 ;Next $line = FileReadLine($file) ;Success: Returns a line of text. ;Special: Sets @error to -1 if end-of-file is reached. ;Failure: Sets @error to 1 if file not opened in read mode or other error. If @error = -1 Then ExitLoop Else ;$line=stringtrimleft($line) ;$line=stringtrimright($line) if stringleft(($line),1)=";" or stringleft(($line),1)="#" or stringleft(($line),1)="'" or $line="" Then ;comment Else $ln=$ln+1 $lines[$ln]=$line $lines[$ln]=stringlower($line) ;$lines[$ln]=stringtrimleft($lines[$ln]) ;$lines[$ln]=stringtrimright($lines[$ln]) ;global values! if stringleft($lines[$ln],4)="wgui" then $synclines[$count][1][0]=stringreplace($lines[$ln],"wgui=","") if stringleft($lines[$ln],4)="hgui" then $synclines[$count][2][0]=stringreplace($lines[$ln],"hgui=","") if stringleft($lines[$ln],4)="cgui" then $synclines[$count][3][0]=stringreplace($lines[$ln],"cgui=","") if stringleft($lines[$ln],3)="spl" then $synclines[$count][4][0]=stringreplace($lines[$ln],"spl=","") if stringleft($lines[$ln],4)="splt" then $synclines[$count][5][0]=stringreplace($lines[$ln],"splt=","") if stringleft($lines[$ln],2)="ip" then $synclines[$count][6][0]=stringreplace($lines[$ln],"ip=","") if StringInStr($lines[$ln],"addtostartup=") then $count=$count+1 $synclines[1][0][1]=stringreplace($lines[$ln],"addtostartup=","") EndIf if StringInStr($lines[$ln],"startdir=") then $count=$count+1 $synclines[2][0][1]=stringreplace($lines[$ln],"startdir=","") EndIf if StringInStr($lines[$ln],"listsdir=") then $count=$count+1 $synclines[3][0][1]=stringreplace($lines[$ln],"listsdir=","") EndIf if StringInStr($lines[$ln],"fromdir#=") then $count=$count+1 $synclines[4][0][1]=stringreplace($lines[$ln],"fromdir#=","") EndIf if StringInStr($lines[$ln],"owndir=") then $count=$count+1 $synclines[5][0][1]=stringreplace($lines[$ln],"owndir=","") EndIf if StringInStr($lines[$ln],"deleteoldlists=") then $count=$count+1 $synclines[6][0][1]=stringreplace($lines[$ln],"deleteoldlists=","") EndIf if StringInStr($lines[$ln],"maximize=") then $count=$count+1 $synclines[7][0][1]=stringreplace($lines[$ln],"maximize=","") EndIf if StringInStr($lines[$ln],"guiwidth=") then $count=$count+1 $synclines[8][0][1]=stringreplace($lines[$ln],"guiwidth=","") EndIf if StringInStr($lines[$ln],"guiheight=") then $count=$count+1 $synclines[9][0][1]=stringreplace($lines[$ln],"guiheight=","") EndIf if StringInStr($lines[$ln],"application=") then $count=$count+1 $synclines[10][0][1]=stringreplace($lines[$ln],"application=","") EndIf if StringInStr($lines[$ln],"colorgui=") then $count=$count+1 $synclines[11][0][1]=stringreplace($lines[$ln],"colorgui=","") EndIf if StringInStr($lines[$ln],"splashtime=") then $count=$count+1 $synclines[12][0][1]=stringreplace($lines[$ln],"splashtime=","") EndIf if StringInStr($lines[$ln],"ip=") then $count=$count+1 $synclines[13][0][1]=stringreplace($lines[$ln],"ip=","") EndIf if StringInStr($lines[$ln],"sort=") then $count=$count+1 $synclines[14][0][1]=stringreplace($lines[$ln],"sort=","") EndIf if StringInStr($lines[$ln],"tags=") then $count=$count+1 $synclines[15][0][1]=stringreplace($lines[$ln],"tags=","") if $synclines[15][0][1]="" then $synclines[15][0][1]="." $synclines[15][0][1]=stringreplace($synclines[15][0][1],"*","") $synclines[15][0][1]=$synclines[15][0][1]&";" EndIf if StringInStr($lines[$ln],"lastlist=") then $count=$count+1 $synclines[16][0][1]=stringreplace($lines[$ln],"lastlist=","") EndIf #comments-start #startup for movies addtostartup=1 startdir=g:\music\ listsdir=g:\music\lists\ #fromdir#=0[own dir list], 1[from startdir], [-1]ownname for all --> give lists names fromdir#=2 owndir= deleteoldlists=1 maximize=1 guiwidth=500 guiheight=500 application=C:\Program Files\K-Lite Codec Pack\Media Player Classic\mplayerc.exe #wgui=@DesktopWidth #hgui=@DesktopHeight colorgui=0xaabbff splashtime=3000 ip=@IPAddress1 #comments-end ;msgbox(0,$place,$lines[$ln]) $synclines[0][0][1]=$count ;(global) ;msgbox(0,$place,$lines[$ln]&@crlf&$count&@crlf&$server) EndIf EndIf Wend FileClose($file) EndIf Else ;no text/ini file exists!!! EndIf if FileExists($synclines[2][0][1]) Then if $synclines[2][0][1]<>"" then $startdir=$synclines[2][0][1] $x=0 call("subs",$startdir,$searchid,$x,$z,$q) $filez[0][0][0]=0 $filez[0][0][1]=0 $files=stringsplit($array,"*") if $files[0]>0 Then dim $sarray[$files[0]+1][4] dim $filesizes[$files[0]+1][3] dim $filedates[$files[0]+1][3] dim $filenames[$files[0]+1][3] dim $filedirs[$files[0]+1][3] dim $filefullpath[$files[0]+1][3] dim $type,$maxlen ;type0 default, 1 random, 2 date, 3 size $type=$synclines[14][0][1] ;$array="" for $t=1 to $files[0] if $files[$t]<>"" Then ;msgbox(0,$place,$files[$t]) $temparray2="" $temparray2=StringSplit($files[$t],"\");X pieces (subfolders) if $temparray2[0]>0 Then $r=0 ;#fromdir#=0[own dir list], 1[from startdir], [-1]ownname for all --> give lists names ;if $synclines[4][0][1]=0 then own dir ;if $synclines[4][0][1]=1 then from startdir ;if $synclines[4][0][1]=-1 then from ownname for $r=1 to $temparray2[0]-1 if $temparray2[$r]<>"" then ;msgbox(0,$place,$temparray2[$r]) if $r=1 Then $directories[$t][0][0][1]=$temparray2[$r] Else $directories[$t][0][0][1]=$directories[$t][0][0][1]&"\"&$temparray2[$r] EndIf EndIf Next $directories[$t][0][0][1]=stringreplace($files[$t],$temparray2[$temparray2[0]],"");dir of file $directories[$t][0][0][4]=$files[$t];whole path & file if $directories[$t][0][0][1]=$directories[$t-1][0][0][1] then ;group it $x=$x Else $x=$x+1 EndIf $directories[$t][0][0][2]=$temparray2[$temparray2[0]];file $directories[$t][0][0][3]=$x;group $directories[0][0][0][2]=$x ;FileGetSize("AutoIt.exe") ;FileGetTime(@Windowsdir & "\Notepad.exe", 1) $filenames[$t][1]=$directories[$t][0][0][2] $filedirs[$t][1]=$directories[$t][0][0][1] $filesizes[$t][1]=round(FileGetSize($directories[$t][0][0][4]),0) $filedates[$t][1]=FileGetTime($directories[$t][0][0][4],0,1) ;msgbox(1,"test",$filedates[$t][1]) $filefullpath[$t][1]=$directories[$t][0][0][4] $filedirs[$t][2]=$t $filenames[$t][2]=$t $filesizes[$t][2]=$t $filedates[$t][2]=$t $filefullpath[$t][2]=$t $sarray[0][0]=$t $sarray[$t][2]=$t if $type=0 then ;sort by Default $sarray[$t][1]=$filenames[$t][1] endif if $type=1 then ;sort randomly $sarray[$t][1]=$filefullpath[$t][1] EndIf if $type=2 then ;sort by filedate $sarray[$t][1]=$filedates[$t][1] EndIf if $type=3 then ;sort by filesize $sarray[$t][1]=$filesizes[$t][1] EndIf if $type<0 or $type>3 Then ;sort by Default $sarray[$t][1]=$filenames[$t][1] EndIf if $type>3 Then dim $var dim $wholeasc $var=$sarray[$t][1] $wholeasc="" $w=stringlen($var)+1 dim $letters[$w] for $q=1 to stringlen($var) $letter=stringmid($var,$q,1) ;msgbox(0, "Test Binary", $letter) $letters[$q] = Asc($letter) $wholeasc=$wholeasc&$letters[$q] ;msgbox(0, "Test Binary", $var) next $sarray[$t][1]=$wholeasc ;msgbox(0, "Test Binary", $wholeasc) EndIf if $type>3 Then if $maxlen=0 then $maxlen=stringlen($sarray[$t][1]) if stringlen($sarray[$t][1])>$maxlen then $maxlen=stringlen($sarray[$t][1]) for $q=1 to $t if stringlen($sarray[$q][1])<$maxlen then for $z=1 to $maxlen $sarray[$q][1]=$sarray[$q][1]&"0" Next endif Next EndIf if stringlen($sarray[$t][1])<$maxlen then for $z=1 to $maxlen $sarray[$t][1]=$sarray[$t][1]&"0" Next EndIf EndIf EndIf $directories[0][0][0][0]=$files[0] ;msgbox(0,$files[0],$directories[$t][0][0][3]&@crlf&$directories[$t][0][0][1]) EndIf Next EndIf if $directories[0][0][0][0]>0 Then ;create the lists dir if needed DirCreate($synclines[3][0][1]) ; DELETE THE LISTS IF NEED if $synclines[6][0][1]=1 then ;delete all lists ;msgbox(0,$files[0],$synclines[6][0][1]&@crlf&$directories[$t][0][0][1]) $filelist=_FileListToArray($synclines[3][0][1],"*.*","1") ;msgbox(0,$files[0],$synclines[6][0][1]&@crlf&@error) if @error=1 or @error=3 or @error=4 or @error=2 Then ;error or no FileS $q=0 $directories[0][0][1][0]=0 Else ;there are FileS $q=0 $directories[0][0][1][0]=$filelist[0] ;msgbox(0,$q,$filelist[0]) if stringright($synclines[3][0][1],"1")="\" Then Else $synclines[3][0][1]=$synclines[3][0][1]&"\" EndIf $synclines[3][0][1]=stringreplace($synclines[3][0][1],"\\","\") for $q=1 to $filelist[0] ;msgbox(0,$q,$filelist[$q]) if FileExists($synclines[3][0][1]&$filelist[$q]) Then FileDelete($synclines[3][0][1]&$filelist[$q]) EndIf Next $q=$filelist[0] EndIf EndIf ; END DELETE THE LISTS IF NEED if stringright($synclines[3][0][1],"1")="\" Then Else $synclines[3][0][1]=$synclines[3][0][1]&"\" EndIf ;sorting dim $temp1,$tempmax,$tempmin,$temp2 $tempmax=0 $tempmin=0 $exits=False dim $changes,$exit,$total,$turns if $type>=2 Then $total=$sarray[0][0] $changes=0 $turns=0 while $exit=False $turns=$turns+1 for $x=1 to $sarray[0][0] if $x>=2 then $temp1=$sarray[$x-1][1] $temp2=$sarray[$x-1][2] if $tempmax<$sarray[$x][1] Then $tempmax=$sarray[$x][1] if $tempmin>=$sarray[$x-1][1] then $tempmin=$sarray[$x-1][1] if $type=2 or $type=3 Then if $sarray[$x][1]>$sarray[$x-1][1] then $sarray[$x-1][1]=$sarray[$x][1] $sarray[$x-1][2]=$sarray[$x][2] $sarray[$x][1]=$temp1 $sarray[$x][2]=$temp2 $changes=$changes+1 EndIf Else if $sarray[$x][1]<$sarray[$x-1][1] then $sarray[$x-1][1]=$sarray[$x][1] $sarray[$x-1][2]=$sarray[$x][2] $sarray[$x][1]=$temp1 $sarray[$x][2]=$temp2 $changes=$changes+1 EndIf EndIf Else $sarray[$x][1]=$sarray[$x][1] EndIf ;msgbox(1,"step",$changes&@crlf&$sarray[$x][1]&@crlf&$x) Next if $changes=$total*10 or $turns=100 then exitloop WEnd EndIf if $type=1555 then dim $exit dim $timer dim $randomnumber,$maxrandom,$filelistnumber,$filesselected $filesselected="" $randomnumber=random(1,$sarray[0][0],1) $maxrandom=$sarray[0][0] $exit=False $timer=0 While $exit=False $timer=$timer+1 $randomnumber=round(random(1,$maxrandom,1),0) if $sarray[$randomnumber][1]<>"" Then if stringinstr($filesselected,$sarray[$randomnumber][1]) Then Else $filelistnumber=$filelistnumber+1 if $filelistnumber=1 Then $filesselected=$sarray[$randomnumber][1] Else $filesselected=$filesselected&"*"&$sarray[$randomnumber][1] EndIf EndIf EndIf if $randomnumber=$maxrandom then $maxrandom=$maxrandom-1 if $randomnumber<$maxrandom then $sarray[$randomnumber][1]=$sarray[$maxrandom][1] $sarray[$randomnumber][2]=$sarray[$maxrandom][2] $maxrandom=$maxrandom-1 EndIf if $maxrandom=0 then $exit=True if $timer=$sarray[0][0]*100 then $exit=True wend EndIf if $type=1 then dim $exit dim $timer dim $randomnumber1,$randomnumber2,$maxrandom,$filelistnumber,$filesselected,$temp1,$temp2 $filesselected="" $randomnumber1=random(1,$sarray[0][0],1) $randomnumber2=random(1,$sarray[0][0],1) $maxrandom=$sarray[0][0] dim $turns $turns=0 $turns=round(random(round(($maxrandom/2),0),$maxrandom),0) $exit=False $timer=0 While $exit=False $timer=$timer+1 $randomnumber1=round(random(1,$maxrandom,1),0) $randomnumber2=round(random(1,$maxrandom,1),0) if $sarray[$randomnumber1][1]<>"" and $sarray[$randomnumber2][1]<>"" and $sarray[$randomnumber1][1]<>$sarray[$randomnumber2][1] Then $temp1=$sarray[$randomnumber1][1] $temp2=$sarray[$randomnumber1][2] $sarray[$randomnumber1][1]=$sarray[$randomnumber2][1] $sarray[$randomnumber2][1] =$temp1 $sarray[$randomnumber1][2]=$sarray[$randomnumber2][2] $sarray[$randomnumber2][2] =$temp2 EndIf if $timer=$sarray[0][0]*100 or $timer=$turns then $exit=True wend EndIf dim $dirs[$sarray[0][0]+1],$fils[$sarray[0][0]+1],$lists[$sarray[0][0]+1] for $x=1 to $sarray[0][0] ;msgbox(1,"step",$changes&@crlf&$sarray[$x][1]&@crlf&$x&@crlf&$sarray[$x][2]&@CRLF&$timer) if $synclines[4][0][1]=-1 then ;one list all ;ta bazume ola se mia lista me onoma pou exei dw8ei sto 'owndir=' $synclines[5][0][1] dim $listname dim $i $lists[$x]="" $t=$sarray[$x][2] $lists[$x]=$synclines[3][0][1]&$synclines[5][0][1]&".m3u" $array="" if $directories[$t][0][0][4]<>"" Then $FileContents = FileRead($lists[$x]) if stringinstr($FileContents,$directories[$t][0][0][4]) Then Else if $x=1 then DirCreate($synclines[3][0][1]) FileWriteLine($lists[$x],$directories[$t][0][0][4]) ;msgbox(1,"title",$lists[$x]&@CRLF&$x) EndIf EndIf EndIf if $synclines[4][0][1]=0 then ;own dir ;to ka8ena mpainei sth lista pou exei idio onoma me to DIR ths xwris to driveletter, xwris ta \ / kai xwris to filename dim $listname dim $i $lists[$x]="" $t=$sarray[$x][2] $lists[$x]=$directories[$t][0][0][1] $lists[$x]=stringreplace($lists[$x],$synclines[2][0][1],"") $lists[$x]=stringreplace($lists[$x],"\","_") $lists[$x]=stringreplace($lists[$x],"/","_") if stringright($lists[$x],1)="_" then $w=stringlen($lists[$x])-1 $lists[$x]=stringmid($lists[$x],1,$w) ;msgbox(1,"title",$lists[$x]&@CRLF&$w) EndIf $filelist=stringsplit($synclines[2][0][1],"\") for $w=1 to $filelist[0] if $filelist[$w]<>"" then $startdir=$filelist[$w] Next if $lists[$x]="" then $lists[$x]=$startdir $lists[$x]=$synclines[3][0][1]&$lists[$x]&".m3u" ;msgbox(1,"title",$lists[$x]&@CRLF&$directories[$t][0][0][1]) if $directories[$t][0][0][4]<>"" Then if $x=1 then DirCreate($synclines[3][0][1]) ;msgbox(1,"title",$listname&@CRLF&$directories[$t][0][0][4]) FileWriteLine($lists[$x],$directories[$t][0][0][4]) EndIf EndIf if $synclines[4][0][1]>0 then ;from startdir kai go on :) ;to ka8ena mpainei se lista pou ksekinaei meta to driveletter kai metraei apo to startdir kai meta (1=startdir) ... ean o ari8mos einai megalyteros apo ta dirs san max einai to last opws einai logiko ;prwta briskume to DIR to start XWRIS tpt allo (dld to last apo to array tou startdir) ;meta to prosartume sto ypoloipo ksekinwntas apo to 1 pou einai auto kai paei legontas.... dim $startdir,$restdir,$wholedir,$filelist2,$stophere,$exit,$dirtogo $lists[$x]="" $t=$sarray[$x][2] $filelist=stringsplit($synclines[2][0][1],"\") for $w=1 to $filelist[0] if $filelist[$w]<>"" then $startdir=$filelist[$w] ;msgbox(1,1,$startdir) Next ;msgbox(1,1,$startdir) $restdir=stringreplace($directories[$t][0][0][1],$synclines[2][0][1],"") $wholedir=$startdir&"\"&$restdir $wholedir=stringreplace($wholedir,"\\\","\") $wholedir=stringreplace($wholedir,"\\","\") $filelist2=stringsplit($wholedir,"\") $stophere="" ;msgbox(1,1,$filelist2[0]) for $w=1 to $filelist2[0] ;msgbox(1,1,$filelist2[0]) if $synclines[4][0][1]>$filelist2[0] then $synclines[4][0][1]=$filelist2[0] if $synclines[4][0][1]<=0 then $synclines[4][0][1]=1 if $w=$synclines[4][0][1] then;here we stop! $stophere=$filelist2[$w];to dir pou einai h 'arxh' gia tis listes ;msgbox(1,1,$stophere) EndIf Next ;msgbox(1,"title",$startdir) ;if $stophere="" then $stophere=$startdir $exit=False $filelist=stringsplit($directories[$t][0][0][1],"\") for $w=1 to $filelist[0] if $exit=false Then if $w=1 then $dirtogo=$filelist[$w] Else $dirtogo=$dirtogo&"\"&$filelist[$w] EndIf EndIf ;msgbox(1,1,$dirtogo) if $filelist[$w]=$stophere then $exit=True Next ;msgbox(1,1,$dirtogo) if $stophere="" then $stophere=$startdir ;msgbox(1,"title",$stophere) ;msgbox(1,1,$stophere) if $lists[$x]&"\"=$synclines[2][0][1] then $lists[$x]=$lists[$x]&"\" EndIf $lists[$x]=stringreplace($lists[$x],$synclines[2][0][1],"") $lists[$x]=stringreplace($lists[$x],"\","_") $lists[$x]=stringreplace($lists[$x],"/","_") if stringright($lists[$x],1)="_" then $w=stringlen($lists[$x])-1 $lists[$x]=stringmid($lists[$x],1,$w) ;msgbox(1,"title",$lists[$x]) ;msgbox(1,"title",$lists[$x]&@CRLF&$w) EndIf if $lists[$x]="" then $lists[$x]=$stophere ;msgbox(1,1,$lists[$x]) $lists[$x]=$synclines[3][0][1]&$lists[$x]&".m3u" ;msgbox(1,"title",$lists[$x]) ;msgbox(1,"title",$lists[$x]&@CRLF&$directories[$t][0][0][1]) if $directories[$t][0][0][4]<>"" and stringinstr($directories[$t][0][0][4],$dirtogo) Then if $x=1 then DirCreate($synclines[3][0][1]) ;msgbox(1,"title",$listname&@CRLF&$directories[$t][0][0][4]) FileWriteLine($lists[$x],$directories[$t][0][0][4]) ;dim $changename ;$changename=stringreplace($lists[$x],".m3u","("&$x&").m3u") ;FileMove($lists[$x], $changename) EndIf EndIf next ;_ArrayDisplay( $sarray, $type ) ;end sorting endif EndIf EndIf ;emfanish tou GUI ;check all lists ;msgbox(0,$files[0],$synclines[6][0][1]&@crlf&$directories[$t][0][0][1]) $filelist=_FileListToArray($synclines[3][0][1],"*.*","1") ;msgbox(0,$files[0],$synclines[6][0][1]&@crlf&@error) if @error=1 or @error=3 or @error=4 or @error=2 Then ;error or no FileS $q=0 $directories[0][0][1][0]=0 Else ;there are FileS $q=0 $directories[0][0][1][0]=$filelist[0] ;msgbox(0,$q,$filelist[0]) if stringright($synclines[3][0][1],"1")="\" Then Else $synclines[3][0][1]=$synclines[3][0][1]&"\" EndIf $synclines[3][0][1]=stringreplace($synclines[3][0][1],"\\","\") for $q=1 to $filelist[0] $w=0 ;msgbox(0,$q,$filelist[$q]) if FileExists($synclines[3][0][1]&$filelist[$q]) Then $lists[$q]=$synclines[3][0][1]&$filelist[$q] $lists[0]=$q if FileExists($lists[$q])=True Then $file = FileOpen($lists[$q], 0) ;filename Filename of the text file to open. ;mode Mode (read or write) to open the file in. ;Can be a combination of the following: ; 0 = Read mode ; 1 = Write mode (append to end of file) ; 2 = Write mode (erase previous contents) ; 4 = Read raw mode ; 8 = Create directory structure if it doesn't exist (See Remarks). ;Both write modes will create the file if it does not already exist. The folder path must already exist (except using mode '8' - See Remarks). ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ; Read in lines of text until the EOF is reached While 1 $line = FileReadLine($file) ; Return Value ;Success: Returns a line of text. ;Special: Sets @error to -1 if end-of-file is reached. ;Failure: Sets @error to 1 if file not opened in read mode or other error. If @error = -1 Then ExitLoop ;MsgBox(0, "Line read:", $line) $w=$w+1 ;edw mporei na elegxei to arxiko 'stigma' ths grammhs kai an einai px MusicList na to emfanizei stis music lists kai genika na kanei analogh diarry8mish Wend FileClose($file) if $w>0 Then dim $changename $changename=stringreplace($lists[$q],".m3u","("&$w&").m3u") FileMove($lists[$q], $changename) $lists[$q]=$changename EndIf EndIf EndIf Next $q=$filelist[0] EndIf dim $height,$dir $height=500+$q*20 dim $checklist[$q+1],$lista ;$var = FileSelectFolder("Choose a folder.", "") GUICreate($scriptini,400,$height,$synclines[8][0][1],$synclines[9][0][1]) ; will create a dialog box that when displayed is centered Opt("GUICoordMode",2) $title1=GUICtrlCreateLabel("Επιλέξτε κάποια/ες λίστα/ες για αναπαραγωγή",10,10,260) $metrhths=GUICtrlCreateLabel("Timer",0,-1,50) $posx=GUICtrlCreateLabel("X",0,-1,20) $pos=GUICtrlCreateLabel("x",0,-1,5) $posy=GUICtrlCreateLabel("Y",0,-1,20) $title1=GUICtrlCreateLabel("Λίστα/ες για αναπαραγωγή:",-355,10,260) for $w=1 to $q $lista=stringreplace($lists[$w],$synclines[3][0][1],"") $lista=stringreplace($lista,".m3u","") $checklist[$w]=GuiCtrlCreateCheckbox($lista, -1, 0,380) if stringinstr($synclines[16][0][1],"("&$w&")") then GuiCtrlSetState(-1, $GUI_CHECKED) EndIf ;GUICtrlCreateCheckbox(2,l,t,w,h) Next $title2=GUICtrlCreateLabel("Προσωποποιηση",-1,10,200,20) $title8=GUICtrlCreateLabel("Προσπέλαση",-1,10,110) $Combo_1 = GUICtrlCreateCombo("Κανονικά(0)", 0,-1,280) ; create first item for $w=0 to 3 if $synclines[14][0][1]=$w then if $w=0 then GUICtrlSetData(-1, "Κανονικά(0)", "Κανονικά(0)") if $w=1 then GUICtrlSetData(-1, "Τυχαία(1)", "Τυχαία(1)") if $w=2 then GUICtrlSetData(-1, "Ημερομηνιακά(2)", "Ημερομηνιακά(2)") if $w=3 then GUICtrlSetData(-1, "Μέγεθος(3)", "Μέγεθος(3)") Else if $w=0 then GUICtrlSetData(-1, "Κανονικά(0)") if $w=1 then GUICtrlSetData(-1, "Τυχαία(1)") if $w=2 then GUICtrlSetData(-1, "Ημερομηνιακά(2)") if $w=3 then GUICtrlSetData(-1, "Μέγεθος(3)") EndIf next ;$check1=GuiCtrlCreateCheckbox("Τυχαία προσπέλαση", -1, 0);$synclines[14][0][1] $check2=GuiCtrlCreateCheckbox("Διαγραφη παλαιών λιστών", -390, 0);$synclines[6][0][1] if $synclines[6][0][1]=1 then GuiCtrlSetState(-1, $GUI_CHECKED) EndIf $check3=GUICtrlCreateCheckbox("Ξεκίνημα στην αρχή",-1,0) ;$synclines[1][0][1] if $synclines[1][0][1]=1 then ;MsgBox(1,"start",$synclines[1][0][1]) GuiCtrlSetState(-1, $GUI_CHECKED) EndIf $title2=GUICtrlCreateLabel("Όνομα λίστας",-1,10,110) $check4=GUICtrlCreateInput($synclines[5][0][1],0,-1,280);owndir $title3=GUICtrlCreateLabel("Φάκελος Αρχικός",-390,10,110) $check5=GUICtrlCreateInput($synclines[2][0][1],0,-1,280);startdir $title4=GUICtrlCreateLabel("Φάκελος Λιστών",-390,10,110) $check6=GUICtrlCreateInput($synclines[3][0][1],0,-1,280);λιστδιρ $title5=GUICtrlCreateLabel("Πρόγραμμα(path)",-390,10,110) $check7=GUICtrlCreateInput($synclines[10][0][1],0,-1,280);application $title6=GUICtrlCreateLabel("Tags αναζητησης(;)",-390,10,110) $check8=GUICtrlCreateInput($synclines[15][0][1],0,-1,280);searchfor $title9=GUICtrlCreateLabel("Αυτοματη έναρξη(t)",-390,10,110) $check9=GUICtrlCreateInput($synclines[12][0][1],0,-1,280);searchfor $title7=GUICtrlCreateLabel("Πατρότητα φακέλων",-390,10,110) $Combo_2 = GUICtrlCreateCombo("-1", 0,-1,280) ; create first item for $w=-1 to 50 if $synclines[4][0][1]=$w then $x=$w EndIf GUICtrlSetData(-1, $w, $x) ; add more items, set a new default next $check10=GuiCtrlCreateCheckbox("Εκτέλεση προγράμματος", -390, 0);$synclines[6][0][1] if $synclines[12][0][1]>0 Then GuiCtrlSetState(-1, $GUI_CHECKED) EndIf $Button_1 = GUICtrlCreateButton("Έναρξη", -1, 20, 60, 30) ;$Label_1=GUICtrlCreateInput("0",0,-1) $mem= MemGetStats () $AllProcesses= ProcessList () GUISetBkColor($synclines[11][0][1]) if $synclines[12][0][1]>0 Then ;SplashTextOn("Timer","0 Seconds",80,20,1,1) EndIf GUISetState() dim $timert,$shown $timert=0 dim $size,$posx,$posy while 1 $size = WinGetPos("") GUIctrlSetData($posx,$size[0]) GUIctrlSetData($posy,$size[1]) ;MsgBox(0, "Active window stats (x,y,width,height):", $size[0] & " " & $size[1] & " " & $size[2] & " " & $size[3]) $timert=$timert+1 $msg = GUIGetMsg() if $synclines[12][0][1]>0 and $timert<=$synclines[12][0][1] Then ;ControlSetText("Timer", "", "Static1", $timert & " Seconds") GUICtrlSetData($metrhths, $timert) EndIf if $timert>$synclines[12][0][1] Then ;SplashOff() GUICtrlSetData($metrhths, "Timer") EndIf Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_1 or ($synclines[12][0][1]>0 and $timert>=$synclines[12][0][1] and $shown=0) $shown=1 ;path8hke to kumpi ;psaxnume tis listes poies epilex8hkan dim $lastselected $lastselected="" ;an epilex8hke/an kapoia/es tis katagrafume se ena array me ta paths tous, tis anoigume, tis kanume merge se ena neo ;playlist temporary kai meta anoigume to application na paiksei thn temporary for $w=1 to $q if GUICtrlRead($checklist[$w])=1 then ;MsgBox(0, "Error", $lists[$w]) ;this list is selected ;$lists[$w] if FileExists($lists[$w]) Then $file = FileOpen($lists[$w], 0) ;MsgBox(0, "Error", "Unable to open file.") ; Check if file opened for reading OK If $file = -1 Then ;MsgBox(0, "Error", "Unable to open file.") ;Exit Else While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop ;create temp list $dir=$synclines[3][0][1]&"\"&"templist_"&$scriptini&".m3u" $dir=stringreplace($dir,"\\\","\") $dir=stringreplace($dir,"\\","\") if $lastselected="" then if FileExists($dir) Then filedelete($dir) EndIf EndIf FileWriteLine($dir,$line) ;katagrafume sto last= tous ari8mus twn listwn mesa se paren8esh (#) if stringinstr($lastselected,"("&$w&")") Then Else $lastselected=$lastselected&"("&$w&")" EndIf Wend FileClose($file) EndIf EndIf EndIf Next ;an kamia proxwrame sto epomeno bhma (aplh katagrafh sto ini twn ypoloipwn) ;katagrafh olwn sto ini, an kati einai keno tote den allazume tpt ....ektos apo to onoma listas opou bazume ena default diko mas ;an ta tags einai kena bazume ena *.*; ;an h automath enarksh einai mh numeric bazume 0 ;;;;;;;;;;;;; READ THE ini FILE ;;;;;;;;;;;;;;;;; $scriptini=@ScriptName $scriptini=stringreplace($scriptini,".au3","") $scriptini=stringreplace($scriptini,".exe","") ;msgbox(0,$scriptini,@ScriptName) $TextFileName = $scriptini&".ini" if FileExists($TextFileName)=True Then $file = FileOpen($TextFileName, 0) $server=0 $onoff=0 $place="" $errors=0 $x=0 $y=0 $count=0 If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit Else While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop Else if stringleft(($line),1)=";" or stringleft(($line),1)="#" or stringleft(($line),1)="'" or $line="" Then ;comment Else $ln=$ln+1 $lines[$ln]=$line $lines[$ln]=stringlower($line) if StringInStr($lines[$ln],"addtostartup=") then $count=GUICtrlRead($check3) if $count<>1 then $count=0 $synclines[1][1][1]="addtostartup="&$count EndIf if StringInStr($lines[$ln],"startdir=") then $count=GUICtrlRead($check5) if $count<>"" Then $count=GUICtrlRead($check5) Else $count=@ScriptDir EndIf $synclines[2][1][1]="startdir="&$count EndIf if StringInStr($lines[$ln],"listsdir=") then $count=GUICtrlRead($check6) if $count<>"" Then $count=GUICtrlRead($check6) Else $count=@ScriptDir&"\lists\" $count=StringReplace($count,"\\","\") EndIf $synclines[3][1][1]="listsdir="&$count EndIf if StringInStr($lines[$ln],"fromdir#=") then $count=GUICtrlRead($Combo_2) ;msgbox(1,"fromdir",$count) $synclines[4][1][1]="fromdir#="&$count EndIf if StringInStr($lines[$ln],"owndir=") then $count=GUICtrlRead($check4) if $count<>"" Then $count=GUICtrlRead($check4) Else $count="abarthlist" EndIf $synclines[5][1][1]="owndir="&$count EndIf if StringInStr($lines[$ln],"deleteoldlists=") then $count=GUICtrlRead($check2) if $count<>1 then $count=0 $synclines[6][1][1]="deleteoldlists="&$count EndIf if StringInStr($lines[$ln],"maximize=") then $count=1 $synclines[7][1][1]="maximize="&$count EndIf if StringInStr($lines[$ln],"guiwidth=") then $count=$size[0] $synclines[8][1][1]="guiwidth="&$count EndIf if StringInStr($lines[$ln],"guiheight=") then $count=$size[1] $synclines[9][1][1]="guiheight="&$count EndIf if StringInStr($lines[$ln],"application=") then $count=GUICtrlRead($check7) if $count<>"" Then $count=GUICtrlRead($check7) Else $count=@ScriptDir $count=StringReplace($count,"\\","\") EndIf $synclines[10][1][1]="application="&$count EndIf if StringInStr($lines[$ln],"colorgui=") then $count="0xaabbff" $synclines[11][1][1]="colorgui="&$count EndIf if StringInStr($lines[$ln],"splashtime=") then $count=GUICtrlRead($check9) $synclines[12][1][1]="splashtime="&$count EndIf if StringInStr($lines[$ln],"ip=") then $count="@IPAddress1" $synclines[13][1][1]="ip="&$count EndIf if StringInStr($lines[$ln],"sort=") then for $r=0 to 3 if stringinstr(guictrlread($Combo_1),"("&$r&")") then $synclines[14][1][1]="sort="&$r EndIf next EndIf if StringInStr($lines[$ln],"tags=") then $count=GUICtrlRead($check8) if $count="" then $count="." $count=stringreplace($count,"*","") $count=$count&";" $count=stringreplace($count,";;;",";") $count=stringreplace($count,";;",";") $synclines[15][1][1]="tags="&$count EndIf if StringInStr($lines[$ln],"lastlist=") then $synclines[16][1][1]="lastlist="&$lastselected EndIf $synclines[0][1][1]=16 ;(global) EndIf EndIf Wend FileClose($file) $scriptini=@ScriptName $scriptini=stringreplace($scriptini,".au3","") $scriptini=stringreplace($scriptini,".exe","") ;msgbox(0,$scriptini,@ScriptName) $TextFileName = $scriptini&".ini" FileDelete($TextFileName) for $ln=1 to $synclines[0][1][1] FileWrite($TextFileName, $synclines[$ln][1][1]&@CRLF) ;msgbox(1,$TextFileName,$synclines[$ln][1][1]) Next EndIf Else ;no text/ini file exists!!! EndIf ;##############end read ini file ;to ksekinhma sthn arxh to kanume san service h san startup add ... if GUICtrlRead($check3)=1 then ;msgbox(1,"test",@scriptdir&"\"&@ScriptName&@CRLF&@StartupDir&"\"&@ScriptName) $scriptini=@ScriptName $scriptini=stringreplace($scriptini,".au3","") $scriptini=stringreplace($scriptini,".exe","") ;msgbox(0,$scriptini,@ScriptName) $TextFileName = $scriptini&".ini" FileCreateShortcut ( @scriptdir&"\"&@ScriptName, @StartupDir&"\"&@ScriptName,@scriptdir);shortcut gia to exe ;msgbox(1,"test",@scriptdir&"\"&@ScriptName&@CRLF&@StartupDir&"\"&@ScriptName) ;ksekinaei to application me to list !!! Else dim $ee dim $filelist3 $filelist3=_FileListToArray(@StartupDir,"*.*","1") ;msgbox(0,$files[0],$synclines[6][0][1]&@crlf&@error) if @error=1 or @error=3 or @error=4 or @error=2 Then ;error or no FileS ;$q=0 $ee=0 Else $ee=$filelist3[0] if $ee>0 then for $ee=1 to $filelist3[0] if stringinstr($filelist3[$ee],$scriptini) then if FileExists(@StartupDir&"\"&$filelist3[$ee]) Then filedelete(@StartupDir&"\"&$filelist3[$ee]) EndIf EndIf Next endif EndIf EndIf if GUICtrlRead($check10)=1 then Run(GUICtrlRead($check7)&" "&$dir) EndIf ;Run(@scriptdir&"\"&@ScriptName) ;ExitLoop ;exit EndSelect #comments-start; Sets a shortcut with ctrl+alt+t hotkey FileCreateShortcut(@WindowsDir & "\Explorer.exe",@DesktopDir & "\Shortcut Test.lnk",@WindowsDir,"/e,c:\", "This is an Explorer link;-)", @SystemDir & "\shell32.dll", "^!t", "15", @SW_MINIMIZE) #comments-end WEnd func lukk() exit EndFunc func en() mouseclick('right') endfunc Func subs($startdir,$searchid,$x,$z,$q) dim $tags1[100],$tags2[100],$r if stringright($startdir,1)="\" then $startdir=stringleft($startdir,(stringlen($startdir)-1)) $tags1=stringsplit($synclines[15][0][1],";") $r=0 for $w=1 to $tags1[0] if $tags1[$w]<>"" Then $r=$r+1 ;msgbox(1,"test",$r) $tags2[$r]=$tags1[$w] $tags2[0]=$r EndIf Next $search = FileFindFirstFile($startdir & "\*.*") If $search = -1 Then return -1 While 1 $y=$y+1 $file = FileFindNextFile($search) If @error Then FileClose($search) return Elseif $file = "." or $file = ".." Then ContinueLoop ElseIf stringinstr(FileGetAttrib($startdir & "\" & $file),"D") then $searchid=$searchid subs($startdir & "\" & $file,$searchid,$x,$z,$q) EndIf $found=0 #comments-start for $x=1 to $y if stringlower($searchdir)=stringlower($directories[$x][$w][$z][1]) Then $found=1 EndIf Next if $found=0 then $directories[$x][$w][$z]=$searchdir ;fileWriteLine("temp1.txt",$searchdir ) ;ConsoleWrite( $searchdir & "\" & @crlf ) EndIf if $file<>"" and stringinstr($file,".") and $t>=1 Then for $g=1 to $t if stringlower($searchdir & "\" & $file)=stringlower($directories[$t][$w][$z][1] & "\" & $directories[$t][$w][$z][2]) Then $found=1 EndIf Next EndIf #comments-end if $found=0 and $file<>"" and stringinstr($file,".") then if $q<=7999 then $q=$q+1 ;if $synclines[$x][6][$z]=1 and $q=1 then ;Else ; SplashOff() ;EndIf dim $foundfile,$foundfiles[100000] $foundfile=0 ;SplashTextOn($searchid&$synclines[$x][8][$z]&@crlf&"Timer",$q&" files"&@crlf&$startdir & "\" & $file ,625,55,400,0) ;what to look: .mp3, .mpg, .avi, .mpeg, .dat ;MsgBox(0, "Line read:", $synclines[15][0][1]) for $w=1 to $tags2[0] if stringinstr($file,$tags2[$w]) then $foundfile=$foundfile+1 EndIf Next if $foundfile>0 then ;SplashTextOn($synclines[$x][8][$z]&@crlf&"Timer",$q&" files"&@crlf&$startdir & "\" & $file ,625,55,400,0,1+2+16+32) ;ConsoleWrite( $startdir & "\" & $file & @crlf ) if $array="" then $array=$startdir & "\" & $file Else $array=$array&"*"&$startdir & "\" & $file EndIf EndIf ;$directories[$q][$w][$z][1]=$startdir ;$directories[$q][$w][$z][2]=$file ;$directories[$q][$w][$z][0]=$q ;Return $directories[$q][$w][$z][2] EndIf EndIf #comments-start While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop MsgBox(0, "Line read:", $line) Wend #comments-end ;ConsoleWrite( $searchdir & "\" & $file & @crlf ) WEnd Return $array EndFunc the are being followed by a .ini file that stores the 'data' addtostartup=1 startdir=d:\files\music\ listsdir=d:\files\music\lists\ fromdir#=1 owndir=abarthlist deleteoldlists=1 maximize=1 guiwidth=0 guiheight=0 application=c:\program files\winamp\winamp.exe colorgui=0xaabbff splashtime=1000 ip=@IPAddress1 sort=1 tags=.mp3;.wav;.ogg;.midi;.dat;.avi; lastlist= these appz sort the music files in my directory, create playlists and can be 'called' when the pc starts (using the startup folder) so that the pc starts and the playlists (i have chosen) start to play .... I have a 'function' that stores the X-Y coordinates of each application so that next time this application's gui will be at the same place as last time .... BUT the problem is that when the 2 guis are open the coordinates get mixed! (the focused gui 'gives' its coordinates to the other too!) What is the problem? I have one more question, how can I have vertical scrollbars in my gui ? I have tried the gui styles but I had no result. I have found some results in search in this forum, but the solutions where too complicated and I dont know if this is what I want or it is smth more 'specific' ... I just need vertical scrolling in my gui ... thnx in advance Edited June 6, 2007 by abarth Link to comment Share on other sites More sharing options...
smstroble Posted June 6, 2007 Share Posted June 6, 2007 I'm having trouble finding the exact spot where you are grabbing the GUI position data, however are you using the handle returned by GUICreate in your calls for the position data? If you don't then it will pull from the active (or last active) GUI window. MUHAHAHAHAHA Link to comment Share on other sites More sharing options...
abarth Posted June 7, 2007 Author Share Posted June 7, 2007 hi thnx this is where the GUI starts, and how it shows the coords and how they are stored: GUISetState() dim $timert,$shown $timert=0 dim $size,$posx,$posy while 1 $size = WinGetPos("") ;<------------------ i get the coordinates of the window GUIctrlSetData($posx,$size[0]);<------- i show the X coord in $posx (it's a label) GUIctrlSetData($posy,$size[1]);<------- i show the Y coord in $posy (it's a label) .. .. .. .. if StringInStr($lines[$ln],"guiwidth=") then $count=$size[0] $synclines[8][1][1]="guiwidth="&$count EndIf if StringInStr($lines[$ln],"guiheight=") then $count=$size[1] $synclines[9][1][1]="guiheight="&$count EndIf .... .. Link to comment Share on other sites More sharing options...
eltorro Posted June 8, 2007 Share Posted June 8, 2007 (edited) You might try using a the actual title. $size = WinGetPos($scriptini)oÝ÷ Ú)ìµæ¡ö®¶sbb33c·6¦RÒvävWE÷2gV÷C²gV÷C² Using "" for the title will get the active window. See the help file topic--> Window Titles and Text (Basic) Edited June 8, 2007 by eltorro Regards, [indent]ElTorro[/indent][font="Book"] Decide, Commit, Achieve[/font]_ConfigIO.au3Language Translation --uses Google(tm) MsgBox Move XML wrapper UDF XML2TreeView Zip functionality Split your GUI Save Print ScreenZipPluginEdit In Place listviewSome of my scripts on Google code Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now