is there anyway i can emulate pressing Home + D with a batch file?
I need it to minimize a IE window that is in full screen without loosing the full screen attribute.
Thanks
is there anyway i can emulate pressing Home + D with a batch file?
I need it to minimize a IE window that is in full screen without loosing the full screen attribute.
Thanks
There is another way to do the trick with vb script c:\Windows\System32\cscript.exe //H:CScript
yourscript.vbs
the script file consist of two commands only
set objShell = CreateObject("shell.application")
objShell.ToggleDesktop
And also other way is to invoke AutoHotkey.exe winD.ahk
the script file WinD.ahk consist of one row
Send, #d
It appears that you mean +D. WshShell.SendKeys can emulate keypresses. Unfortunately, SendKeys can't send the
key. However, you can try to send Alt+Space, then N to minimize the active window. You'll need a slight pause between Alt+Space and N to give the titlebar icon menu a chance to render -- otherwise, N will be sent to the main window and not to the menu.
Save this as a .bat
file and run it for a demonstration.
@if (@a==@b) @end /* JScript multiline comment
:: begin batch portion
@echo off
setlocal
for /f "tokens=2" %%I in ('tasklist /v /fi "imagename eq iexplore.exe" ^| find "Internet Explorer"') do set "PID=%%I"
if defined PID goto minimize
:: apparently IE is not running. Launch, then wait for it to appear.
start "" "%programfiles%\Internet Explorer\iexplore.exe"
:ie
ping -n 2 0.0.0.0 >NUL
for /f "tokens=2" %%I in ('tasklist /v /fi "imagename eq iexplore.exe" ^| find "Internet Explorer"') do set "PID=%%I"
if not defined PID goto ie
:minimize
cscript /nologo /e:Jscript "%~f0" "%PID%"
goto :EOF
:: end batch portion / begin JScript */
var oShell = WSH.CreateObject('wscript.shell');
WSH.Echo('Activating window with PID ' + WSH.Arguments(0));
oShell.AppActivate(WSH.Arguments(0));
WSH.Sleep(100);
WSH.Echo('Making full screen');
oShell.SendKeys('{F11}');
WSH.Sleep(1000);
WSH.Echo('Activating titlebar icon menu');
oShell.SendKeys('% ');
WSH.Sleep(100);
WSH.Echo('Minimizing');
oShell.SendKeys('n');
WSH.Sleep(100);
Edit: For what it's worth, Alt+Esc will also minimize most windows. It doesn't work with F11-mode IE though. Fullscreen IE gets pushed to the back of all windows rather than being minimized. But anyone else coming across this answer from a Google Search, try sending Alt+Esc. This is especially useful for minimizing a cmd
window, as Alt+Space doesn't work on those.
Edit 2: To have your script minimize its own window, then minimize IE, then re-launch itself, try the following modifications:
@if (@a==@b) @end /* JScript multiline comment
:: begin batch portion
@echo off
setlocal
for /f "tokens=2" %%I in ('tasklist /v /fi "imagename eq iexplore.exe" ^| find "Internet Explorer"') do set "PID=%%I"
if defined PID goto minimize
:: apparently IE is not running. Launch, then wait for it to appear.
start "" "%programfiles%\Internet Explorer\iexplore.exe"
:ie
ping -n 2 0.0.0.0 >NUL
for /f "tokens=2" %%I in ('tasklist /v /fi "imagename eq iexplore.exe" ^| find "Internet Explorer"') do set "PID=%%I"
if not defined PID goto ie
:minimize
cscript /nologo /e:Jscript "%~f0" "%PID%"
goto :EOF
:: end batch portion / begin JScript */
var oShell = WSH.CreateObject('wscript.shell');
if (WSH.Arguments.length == 1) {
WSH.Echo('Activating window with PID ' + WSH.Arguments(0));
oShell.SendKeys('%{ESC}')
oShell.AppActivate(WSH.Arguments(0));
WSH.Sleep(100);
WSH.Echo('Making full screen');
oShell.SendKeys('{F11}');
WSH.Sleep(1000);
WSH.Echo('Minimizing');
oShell.SendKeys('% ');
WSH.Sleep(100)
oShell.SendKeys('n');
oShell.Run('cscript /nologo /e:JScript ' + WSH.ScriptFullName + ' ' + WSH.Arguments(0) + ' ' + '1', 1, false);
WSH.Sleep(100);
WSH.Quit(0);
}
else {
WSH.Echo('Done. Hit ENTER to exit.');
WSH.StdIn.ReadLine();
}