Posts: 15
Threads: 3
Joined: Oct 2015
Hi
Is it possible to create a Qmacro that opens File Explorer
showing current directory
and with a specified windows size ?
C:\> explorer .\ is the command to open explorer in present directory
but it doesn’t have parameters to control window size
Thanks and best regards
BenOve
Posts: 12,097
Threads: 142
Joined: Dec 2002
Use dialog "Run program". Check "Get handle".
Then use that handle with siz or mov+.
Posts: 15
Threads: 3
Joined: Oct 2015
I guess that run explorer and open in current directory should look like this
run "explorer.exe" " " ".\"
But how do I get handle ?
I have search help documentation
for the word get and the word handle without result
and all menus in the program
Posts: 12,097
Threads: 142
Joined: Dec 2002
Don't need to search help. Use the dialog from the floating toolbar, there is a check box "get handle".
Posts: 15
Threads: 3
Joined: Oct 2015
Thanks, I found the floating menu
The exact location of explorer.exe can be different depending on OS, so I just wrote explorer.exe
Param .\
Directory *
The biggest problem is perhaps that a Window can't be specified as explorer.exe is opened in different locations I guess. Here it is not possible to select "Get Handle" if there is no valid Windows name
Can it be solved?
Anyway, The floating menu seem really smart !
Posts: 12,097
Threads: 142
Joined: Dec 2002
Macro
Macro2732
Trigger
F10
spe 10
int w
run "$windows$\explorer.exe" ".\" "" "" 0x2800 win("" "CabinetWClass") w
siz 400 400 w
Posts: 15
Threads: 3
Joined: Oct 2015
I am surprised how good it works !
Is it possible to take the parameter ".\ " from out side of the .exe?
That would give a much higher degree of flexibility - being able to specify any
drive and directory
Posts: 12,097
Threads: 142
Joined: Dec 2002
.exe command line arguments are in a special variable _command.
run "explorer" _command
Posts: 15
Threads: 3
Joined: Oct 2015
It works--Great,
How are 3 parameters handled ? Example:
C:\> e.exe e:\directory 400 600
to control directory AND also the size of explorer from outside ?
Present code with one parameter
spe 10
int w
run "$windows$\explorer.exe" _command "" "" 0x2800 win("" "CabinetWClass") w
siz 400 400 w
Posts: 12,097
Threads: 142
Joined: Dec 2002
Use function ExeParseCommandLine to split command line. Then use function val to convert array elements to numbers where need.
Posts: 15
Threads: 3
Joined: Oct 2015
I can't find any info how to use ExeParseCommandLine in the QM help documentation.
This is my wild guess how to solve it, but it doesn't work
spe 10
int w
ARRAY(str) a
ExeParseCommandLine(_command a)
run "$windows$\explorer.exe" a[1] "" "" 0x2800 win("" "CabinetWClass") w
siz a[2] a[3] w
Posts: 12,097
Threads: 142
Joined: Dec 2002
Click ExeParseCommandLine in this macro and press F1.
Use function val to convert a[...] to number.
Posts: 15
Threads: 3
Joined: Oct 2015
Sorry, changing last row to siz val(a[2]) val(a[3]) w and it works
But this challenge is probably impossible to solve !?
e.exe "C:\Program Files (x86)\Internet Explorer" 400 600
To open explorer it this directory with specified size
The QM will probably see a lot of parameters due to all the spaces
Posts: 12,097
Threads: 142
Joined: Dec 2002
What program is used to execute this:
e.exe "C:\Program Files (x86)\Internet Explorer" 400 600
and what is _command value in the macro?
out _command
Posts: 15
Threads: 3
Joined: Oct 2015
e.exe is supposed to be the resulting program from QuickMacros
It is executed with 3 parameters
1.The path to view in explorer
2,3 the size of file explorer window
I guess the _command array
will have 6 elements insted or expected 3 (= chaotic ) due to the spaces in the path name
1. "C:\program
2. Files
3. (x86)\Internet
4. Explorer"
5. 400
6. 600
Posts: 12,097
Threads: 142
Joined: Dec 2002
Why to guess? Temporarily add out to see variable content.
out _command
out a.len
out a
Posts: 15
Threads: 3
Joined: Oct 2015
I don't know how to debug the .exe
Maybe this code is close but it doesn't work
Final command line syntax
C:\> e.exe 400 700 "C:\Program Files (x86)\Internet Explorer\iexplore.exe"
spe 10
int w
ARRAY(str) a
ExeParseCommandLine(_command a)
str all=""
int i
for i 3 a.len
,all +" "+a[i]
run "$windows$\explorer.exe" all "" "" 0x2800 win("" "CabinetWClass") w
siz val(a[1]) val(a[2]) w
Posts: 12,097
Threads: 142
Joined: Dec 2002
C:\> e.exe "C:\Program Files (x86)\Internet Explorer\iexplore.exe" 400 700
If explorer does not like folder path with spaces, enclose it in "".
Macro
Macro2731
run "$windows$\explorer.exe" F"''{a[0]}''" "" "" 0x2800 win("" "CabinetWClass") w
siz val(a[1]) val(a[2]) w
Posts: 15
Threads: 3
Joined: Oct 2015
I debug the .exe by writing parameter array to file x.txt
It works.
A surprising thing is, that when I change and write to y.txt instead
and a new .exe is created , it continues to write to x.txt
I have even created a new macro, erased all old .exe
Whatever I do it still writes to x.txt as if it was a hidden memory somewhere
The code is the following
spe 10
int w
ARRAY(str) a
ExeParseCommandLine(_command a)
run "$windows$\explorer.exe" a[0] "" "" 0x2800 win("" "CabinetWClass") w
siz val(a[1]) val(a[2]) w
str s=""
s.setfile("R:\DEV_QuickMacros\explorer\y.txt" -1 -1 1)
s.timeformat("{D} {TT}")
s.setfile("R:\DEV_QuickMacros\explorer\y.txt" -1 -1 1)
int i
for i 0 a.len
_s=a[i]; _s.setfile("R:\DEV_QuickMacros\explorer\y.txt" -1 -1 1)
Posts: 12,097
Threads: 142
Joined: Dec 2002
If the exe is console, and launched from Command Prompt (cmd.exe), you can use function ExeConsoleWrite.
Posts: 15
Threads: 3
Joined: Oct 2015
How is ExeConsoleWrite used ? I can't find anything in the QM Help
The .exe is console and I just want to specify "y.txt"
and have the file written in the same local directory as where the .exe is
Why is s.setfile not working as expected ? Should it be closed within each session ?
Posts: 12,097
Threads: 142
Joined: Dec 2002
If cannot use ExeConsoleWrite, the easiest way to debug-output something (where QM is unavailable) is message box. Function mes.
A special variable _qmdir contains .exe directory.
Macro
Macro2732
str s="test"
str sFile.from(_qmdir "y.txt")
s.setfile(sFile)
Posts: 15
Threads: 3
Joined: Oct 2015
I cannot use ExeConsoleWrite until I know how to use it
At least an example is needed to see how it is intended.
Why is s.setfile("y.txt" -1 -1 1) not working ?
It seems to remain in the PC a file handle that doesn't close
also after the program is terminated.
Is there a command to close the file properly before termination ?
Posts: 12,097
Threads: 142
Joined: Dec 2002
s.setfile closes file handle. Use full path. Now it depends on current directory.
Posts: 15
Threads: 3
Joined: Oct 2015
Hi
Is there documentation somewhere about ExeConsoleWrite ?
Th QM help has nothing about it
Posts: 12,097
Threads: 142
Joined: Dec 2002
http://www.quickmacros.com/help/
There are links to Help topics about various ways how to find functions and show function help. Look in chapter "QM extensions...".