Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
string not recognized in command line
#1
Hi
I am trying to use 7zip with QM.I would like to zip selected files from file explorer. I created a string with the paths.

str ft

I checked the string during the process  , it looks good.
When i put the whole path in the command line the zip file is correct.

RunConsole2 "C:\7-Zip\7zg.exe a C:\Users\123\Downloads\test.7z C:\Users\123\Downloads\wn.txt"

When I  substitute the whole path with the string in the command line it is creating an empty zip file.

RunConsole2 "C:\7-Zip\7zg.exe a C:\Users\123\Downloads\test.7z ft"

I am attaching the macro.
Can somebody help me please?
Thanks
TNH

str ft
 find Windows Explorer window
int hwnd=win("" "ExploreWClass")
if(!hwnd) hwnd=win("" "CabinetWClass")
if(!hwnd) end "folder window not found"
 Get ShellBrowserWindow interface by enumerating shell windows
SHDocVw.ShellWindows sw._create
SHDocVw.ShellBrowserWindow b
foreach(b sw)
int hwnd2=b.HWND; err continue
if(hwnd=hwnd2) goto g1
ret
 g1
 get shell folder view document
Shell32.ShellFolderView sfw=b.Document
Shell32.FolderItem fi
 enumerate selected items
foreach fi sfw.SelectedItems
fi.Path
ft.addline(fi.Path)
out ft
RunConsole2 "C:\7-Zip\7zg.exe a C:\Users\123\Downloads\test.7z ft"
#2
something like this should work

need to format ft into other string
otherwise its just the letters ft
cant test dont have 7zip .
as an alternative you could just use qm and zip the files in regular zip format

Code:
Copy      Help
str ft
;find Windows Explorer window
int hwnd=win("" "ExploreWClass")
if(!hwnd) hwnd=win("" "CabinetWClass")
if(!hwnd) end "folder window not found"
;Get ShellBrowserWindow interface by enumerating shell windows
SHDocVw.ShellWindows sw._create
SHDocVw.ShellBrowserWindow b
foreach(b sw)
,int hwnd2=b.HWND
,err 
,,continue
,if(hwnd=hwnd2) 
,,goto g1
,;ret
;g1
;get shell folder view document
Shell32.ShellFolderView sfw=b.Document
Shell32.FolderItem fi
;enumerate selected items
foreach fi sfw.SelectedItems
,fi.Path
,ft.addline(fi.Path)
,out ft
str check.format("C:\7-Zip\7zg.exe a C:\Users\123\Downloads\test.7z %s" ft)
out check
out F"C:\7-Zip\7zg.exe a C:\Users\123\Downloads\test.7z {ft}"
;possible ways to run uncomment to test(to uncomment right click on the line number)
;RunConsole2 check
;RunConsole2 F"C:\7-Zip\7zg.exe a C:\Users\123\Downloads\test.7z {ft}"

also please have a look at these topics for help posting code to forum 
http://www.quickmacros.com/forum/showthr...56#pid2956
and 
http://www.quickmacros.com/forum/showthr...67#pid3267
#3
Thanks for your help.
I tried this

str check.format("C:\7-Zip\7zg.exe a C:\Users\123\Downloads\test.7z %s" ft)
out check
out F"C:\7-Zip\7zg.exe a C:\Users\123\Downloads\test.7z {ft}"
 possible ways to run uncomment to test
RunConsole2 check
RunConsole2 F"C:\7-Zip\7zg.exe a C:\Users\123\Downloads\test.7z {ft}"

I works with one file.
When i select a couple files it only zip the last one.

I am posting the screenshot of the output.

Any suggestion?


Attached Files Image(s)
   
#4
comment either one of the RunConsole2 lines and test again
   
   


here is an alternative using regular zip format that works



Code:
Copy      Help
str ft
;find Windows Explorer window
int hwnd=win("" "ExploreWClass")
if(!hwnd) hwnd=win("" "CabinetWClass")
if(!hwnd) end "folder window not found"
;Get ShellBrowserWindow interface by enumerating shell windows
SHDocVw.ShellWindows sw._create
SHDocVw.ShellBrowserWindow b
foreach(b sw)
,int hwnd2=b.HWND
,err 
,,continue
,if(hwnd=hwnd2) 
,,goto g1
,;ret
;g1
;get shell folder view document
Shell32.ShellFolderView sfw=b.Document
Shell32.FolderItem fi
;enumerate selected items
foreach fi sfw.SelectedItems
,fi.Path
,ft.addline(fi.Path)
out ft
str zf="$desktop$\test.zip";;; change to your desired directory and zip name
str fn
out "zip"
zip zf ft 0 fn
if(fn.len) out fn
#5
I tried 26 and 27 alone with the same result.
If it is good i assume it supposed to be like this

C:\Windows\System32\wsmprovhost.exe
C:\Windows\System32\wuapihost.exe
C:\7-Zip\7zg.exe a C:\Users\123\Downloads\test.7z C:\Windows\System32\wuapihost.exe C:\Windows\System32\wsmprovhost.exe

Thanks
#6
possibly cause your using a command line will need to reformat ft to not be multiline. that may be why its failing.
#7
I am new with QM.Can you help me with the reformatting please?
Thanks
#8
try this
Function Function66
Code:
Copy      Help
str ft ft2
;find Windows Explorer window
int hwnd=win("" "ExploreWClass")
if(!hwnd) hwnd=win("" "CabinetWClass")
if(!hwnd) end "folder window not found"
;Get ShellBrowserWindow interface by enumerating shell windows
SHDocVw.ShellWindows sw._create
SHDocVw.ShellBrowserWindow b
foreach(b sw)
,int hwnd2=b.HWND; err continue
,if(hwnd=hwnd2) goto g1
ret
;g1
;get shell folder view document
Shell32.ShellFolderView sfw=b.Document
Shell32.FolderItem fi
;enumerate selected items
int i
foreach fi sfw.SelectedItems
,if i=0
,,ft2=fi.Path
,,ft+ft2
,else
,,ft2=fi.Path
,,ft + ","
,,ft+ft2
,i + 1
;out ft
str check.format("C:\7-Zip\7zg.exe a C:\Users\123\Downloads\test.7z %s" ft)
;out check
;out F"C:\7-Zip\7zg.exe a C:\Users\123\Downloads\test.7z {ft}"
;possible ways to run uncomment to test(to uncomment right click on the line number)
;RunConsole2 check
;RunConsole2 F"C:\7-Zip\7zg.exe a C:\Users\123\Downloads\test.7z {ft}"
;RunConsole2 "C:\7-Zip\7zg.exe a C:\Users\123\Downloads\test.7z ft"
#9
Thanks for your help.
It is working with a small modification.
I changed the "," to " ".

int i
foreach fi sfw.SelectedItems
if i=0
ft2=fi.Path
ft+ft2
else
ft2=fi.Path
ft + " " <<<<<<<<
ft+ft2
i + 1
Thanks again
#10
yes i figured that out as well found 7zip on my old win7pc and tested
A couple of notes on this, 7zip has  trouble with filenames or folder names that have spaces in them. Also you should be using 7z.exe(Command line version) with RunConsole2 as you can see the output in qm and is alot faster .7zG.exe does work but is slower and if there is problems using 7zG.exe the qm macro or function will just hang and not end. updated function below


Code:
Copy      Help
str ft ft2 foldername filename archive
;find Windows Explorer window
int hwnd=win("" "ExploreWClass")
if(!hwnd) hwnd=win("" "CabinetWClass")
if(!hwnd) end "folder window not found"
;Get ShellBrowserWindow interface by enumerating shell windows
SHDocVw.ShellWindows sw._create
SHDocVw.ShellBrowserWindow b
foreach(b sw)
,int hwnd2=b.HWND; err continue
,if(hwnd=hwnd2) goto g1
ret
;g1
;get shell folder view document
Shell32.ShellFolderView sfw=b.Document
Shell32.FolderItem fi
;enumerate selected items
int i
foreach fi sfw.SelectedItems
,if i=0
,,ft2=fi.Path
,,ft+ft2
,else
,,ft2=fi.Path
,,ft + " "
,,ft+ft2
,i + 1
;out ft
foldername="C:\Users\123\Downloads\";;location of folder of saved archive
filename="test.7z";;possible formats 7z, XZ, BZIP2, GZIP, TAR, ZIP and WIM
archive.format("C:\7-Zip\7z.exe a %s%s %s" foldername filename ft)
RunConsole2 archive
out "done"
run foldername;; open folder where archive is created
#11
@Kevin
Thank you for sharing
Is the problem with space in the file name or folder name resolved?

It would be great to improve the following features as well:
1. For the files selected on the desktop, Reference code:
 
Code:
Copy      Help
Acc a=acc(mouse)
if a.Hwnd and GetWindowThreadProcessId(a.Hwnd 0)=GetWindowThreadProcessId(GetShellWindow 0)
,;out "desktop"

or:
 
Code:
Copy      Help
ARRAY(str) a
GetClipboardFiles(a)

2. During the compression process, OSD text is displayed: Compression is in progress, please wait ... 

3. At the end, when the compressed folder is opened, the destination file is in the selected state
I've seen this effect in other software

4. The name of the compressed file is the name of the folder where the selected file resides


Forum Jump:


Users browsing this thread: 1 Guest(s)