Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Open File explorer with specified window size ?
#1
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
#2
Use dialog "Run program". Check "Get handle".
Then use that handle with siz or mov+.
#3
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
#4
Don't need to search help. Use the dialog from the floating toolbar, there is a check box "get handle".
#5
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 !
#6
Macro Macro2732
Trigger F10     Help - how to add the trigger to the macro
Code:
Copy      Help
spe 10
int w
run "$windows$\explorer.exe" ".\" "" "" 0x2800 win("" "CabinetWClass") w
siz 400 400 w
#7
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
#8
.exe command line arguments are in a special variable _command.

run "explorer" _command
#9
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
#10
Use function ExeParseCommandLine to split command line. Then use function val to convert array elements to numbers where need.
#11
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
#12
Click ExeParseCommandLine in this macro and press F1.
Use function val to convert a[...] to number.
#13
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
#14
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
#15
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
#16
Why to guess? Temporarily add out to see variable content.

out _command
out a.len
out a
#17
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
#18
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
Code:
Copy      Help
run "$windows$\explorer.exe" F"''{a[0]}''" "" "" 0x2800 win("" "CabinetWClass") w
siz val(a[1]) val(a[2]) w
#19
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)
#20
If the exe is console, and launched from Command Prompt (cmd.exe), you can use function ExeConsoleWrite.
#21
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 ?
#22
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
Code:
Copy      Help
str s="test"
str sFile.from(_qmdir "y.txt")
s.setfile(sFile)
#23
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 ?
#24
s.setfile closes file handle. Use full path. Now it depends on current directory.
#25
Hi
Is there documentation somewhere about ExeConsoleWrite ?
Th QM help has nothing about it
#26
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...".


Forum Jump:


Users browsing this thread: 1 Guest(s)