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

Discuss and share scripts and script files...
Post Reply
pulp
Posts: 34
Joined: 24 May 2016 20:52

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

Post 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;	

highend
Posts: 13313
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

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

Post by highend »

Try to refresh the list before you select the item.

#485;
One of my scripts helped you out? Please donate via Paypal

pulp
Posts: 34
Joined: 24 May 2016 20:52

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

Post by pulp »

Thank for the hint, works now.

Post Reply