Page 1 of 1

zip files with 7z.exe: How to select the created zip file?

Posted: 11 Jun 2016 18:04
by pulp
Hi,

i want to zip selected files with 7z.exe. I can not use zip_add() because it should also work with *.7z format and I need to set a password.
My problem is: after the zip file is created i want to select it. But this do not work reliable. Adding a litte timeout improves the situation but still sometimes the zip file is not selected.
It seems that the cmd windows which runs the 7z.exe mess up the focus.

Maybe someone knows a solution for this.

Thanks, pulp

Code: Select all

//zip all selected files
   
     //get selected files  
	 $current_files = "<selitems>";
	 End ("$current_files"==""),  "No files selected!"; //check if any file is selected

     //[additonal checks removed...]
	 
	 $zip_name_full="C:\temp\test.zip";
	 $zip_name="test.zip";
		 	 	 
     //create the zip with 7z.exe
	 run  """C:\Program Files\7-Zip\7z.exe"" a ""$zip_name_full"" $current_files",,2;
	      	 
	 //Trick1: Waiting for the zip file, do not help
	 /*while (1==1)
	 {
	   $zip_created=exists("$zip_name_full");
	   if ("$zip_created")=="1"
	   {
		 break;
	   }
	    wait(100);
	 }*/ 
	 
	 //Trick2: Wait a little bit, do not work reliable
	 wait(200);
	 focus;
	 wait(200);
	 
	 //Set the focus to the new created zip file
	 //do not work reliable
	 sel "[$zip_name]",,1;	

Re: zip files with 7z.exe: How to select the created zip fil

Posted: 11 Jun 2016 18:44
by highend
Try to refresh the list before you select the item.

#485;

Re: zip files with 7z.exe: How to select the created zip fil

Posted: 11 Jun 2016 19:23
by pulp
Thank for the hint, works now.