Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

How to? Windows Key-Left and Windows Key-Right

Apr
4
0
I've got a .btm file to load a number of applications using the START command with the specification of which monitor to use and some of them to be maximized on that particular monitor such as
Code:
START /MONITOR=2 /MAX /PGM "C:\Program Files (x86)\Intuit\QuickBooks 2020\QBW32.EXE"

Included in the .btm, I launch two instances of File Explorer (Windows Explorer before Win10) starting in different drives. I would like to have one launch on the left half of the screen and the other on the right half of the screen similar to how Windows Key-Left and Windows Key_Right work.

Is there some switch to the START, or ACTIVATE or some other command that will do this? Or do I have to use %_xpixels, %_ypixels, do the math to figure out the /POS values needed to give similar effect?
 
I doubt you're going to get START or ACTIVATE to do that. I am not aware of any Windows shortcuts that treat the left and right Windows keys differently. How are you using them to get different results?

If you can do what you want with keystrokes, you might use KEYSTACK in your BTM (instead of START or ACTIVATE) ...

KEYSTACK LWin-...

vs.

KEYSTACK RWin-...
 
Try these for starters;
Code:
start explorer.exe & keystack /w54 lwin-left

start explorer.exe & keystack /w54 lwin-right

Adjust your wait time accordingly.

Also, maybe the /I option of keystack can provide more accuracy.

Joe
 
Heehee, I had that back-asswards!
Code:
start explorer.exe & keystack /w54 lwin-left

start explorer.exe & keystack /w54 lwin-right

It took a while but I eventually figured out that those only work if you have window "snapping" enabled. I don't like "snapping" but I had to try it. Those work nicely, Joe. A one second delay (/w18) was sufficient here.
 
Try these for starters;
Code:
start explorer.exe & keystack /w54 lwin-left

start explorer.exe & keystack /w54 lwin-right

Adjust your wait time accordingly.

Also, maybe the /I option of keystack can provide more accuracy.

Joe

I didn't think of keystack. Other than the timing, that does the trick. I have just found that keystack returns to the prompt (or the batch file moves on to the next statement) before the delay with /w is finished. It does delay the keystroke but the next command in the .btm could be running. I found I had to try the following.
Code:
START /MONITOR=2 /PGM explorer.exe /e,/root,Z:\
DELAY 5
KEYSTACK LWin-Left
DELAY 5
START /MONITOR=2 /PGM explorer.exe /e,/root,Y:\
DELAY 5
KEYSTACK LWin-Right
DELAY 5

I still have to tweak the delay length. Five seconds might be a bit excessive but something needs to let the keystroke occur while the appropriate window is active and not be changed before it occurs. Human delay in typing it in at the command prompt would be sufficient but that's not happening in a batch file.

Thanks for the help.

Heehee, I had that back-asswards!


It took a while but I eventually figured out that those only work if you have window "snapping" enabled. I don't like "snapping" but I had to try it. Those work nicely, Joe. A one second delay (/w18) was sufficient here.

Maybe I wasn't clear enough and should have typed Windows Key-Left Arrow and Windows Key-Right Arrow but then you wouldn't have laughed.

As for the left or right Windows key... I haven't run into anything that makes a differentiation with that particular key but I recall an old MS-DOS pinball game where the shift keys were for the flippers, left shift for the left flipper and right shift for the right flipper. Programatically, it's possible with shift, ctrl, alt, and the Windows key but rarely used.
 
If you want to speed things up ... instead of

Code:
START /MONITOR=2 /PGM explorer.exe /e,/root,Z:\
DELAY 5
KEYSTACK LWin-Left

you might try something like this (below). It's the first one I came up with. It works, but here may be more elegant ways to do the same thing.

Code:
START /MONITOR=2 /PGM explorer.exe /e,/root,Z:\
do while not isvisible Z:\ ( delay 1 )
KEYSTACK LWin-Left
 
What about the /I option of KEYSTACK;
Code:
/I Wait for an input idle or the specified number of milliseconds. 

/I=pid,milliseconds                Look for the specified process ID
/I"Title",milliseconds                Look for the specified window title

I have not tried this, but might be useful.

Joe
 
What about the /I option of KEYSTACK;
Code:
/I Wait for an input idle or the specified number of milliseconds.

/I=pid,milliseconds                Look for the specified process ID
/I"Title",milliseconds                Look for the specified window title

I have not tried this, but might be useful.

Joe
Any idea how it's supposed to work? This spits out "foo" immediately.

Code:
keystack /I"xxxxxxxx",100000 foo

I don't even know what "Wait for an input idle" means.
 
OK, I get it. Thanks, Charles. Either of these works to cause W32TMPARAMETERS.BTM to be selected when the Explorer "v:\" window opens.

Code:
START /PGM explorer.exe /e,/root,v:\ & keystack /I=%_start_pid,10000 "w32tmp"

START /PGM explorer.exe /e,/root,v:\ & keystack /I"v:\",10000 "w32tmp"

So DrNumbers might try something like this:

Code:
START /MONITOR=2 /PGM explorer.exe /e,/root,Z:\
KEYSTACK /I=%_startpid,5000 LWin-Left

or
Code:
START /MONITOR=2 /PGM explorer.exe /e,/root,Z:\
KEYSTACK /I"Z:\",5000 LWin-Left
 
Back
Top
[FOX] Ultimate Translator
Translate