I run a batch file as part of Windows XP startup which executes continuously until Windows closes. It calls a VBScript file, which executes SendKeys "+{ESC}" (Shift+Esc). This gets picked up by 4t Tray Minimiser to send the CMD window to the system tray. Most times it works, but occasionally the CMD window stays visible.
Upon searching, various posts seem to suggest the .VBS file is losing focus or it's a timing problem. Some suggest AppActivate but I can't work out how to achieve what I want. Even the examples given for AppActivate seem like a lot of work.
Did you check the documentation? It's actually rather straightforward. You call AppActivate with the title (or part of the title) of the window you want to bring to the foreground, then run SendKeys to send keystrokes to the foreground window.
Set sh = CreateObject("WScript.Shell")
sh.AppActivate "window title"
sh.SendKeys "+{Esc}"
Related
ControlSend,, test, ahk_exe notepad.exe
The above works just fine but the following does not, it should englarge the text in notepad.
ControlSend,, ^{+}, ahk_exe notepad.exe
I have also, tried
ControlSend,, {Control down}+{Control up}, ahk_exe notepad.exe
I dont really care for notepad, I am just stuck with controlsend and I am trying understand it. Often it will lose focus to the target window after triggering the hotkey. Is there a special rule in Controlsend, that gets it to keep focus where it is, after triggering the command? For example sending the following to notepad, will activate it. I thought the whole point was to maintain focus where it is.
ControlSend,, ^s, ahk_exe notepad.exe
In the last example, A window is being created so it may be a bad example but many times this issues occurs when sending simple, standard hotkeys to programs
Thanks!
Using Notepad's Alt menu to trigger the zoom in command instead of trying to send a Control Plus lead me to this solution:
WinMenuSelectItem, ahk_exe notepad.exe, , View, Zoom, Zoom In
Many of the commands that you use shortcuts for (such as Zoom, save, and etc) can be triggered from this menu as well. This method also meets the requirement of not activating the Window when triggered.
I have a ruby script that displays it's progress via the cmd and completes in about 10 minutes. In the last few weeks the cmd seems to freeze and after 10 minutes when I click on the cmd window it then completes the script.
I have searched on forums and suggestions include: disable QuickEdit Mode & Insert Mode which I have done but this has not fixed the problem.
The platform is an azure windows server 2016 VM.
Could this problem be due to a recent windows update?
Thanks
If you are using the usual Windows Command Window, Ruby has no way of knowing that you have clicked into the Window, so it is unlikely that it is related to the code. However, Windows does block a command to write to the command window on certain circumstances, and if this happens, Ruby waits on, say, STDOUT.puts, until it is allowed to continue. Of course this applies not only to Ruby, but to any application writing to the command console.
The most typical situation, in which this occurs, is, if you (maybe accidentally) select with the mouse something in the console Window. The script running in the console is blocked. By clicking with the mouse inside the window, the selection is cancelled, and the program continues to run.
I'm trying to open a browser with vbs program on background. My program code is this:
CreateObject("Wscript.Shell").Run "firefox.exe",0,True
The problem is that the window that opens isn't hidden. Also if I open any other program this way it runs on background eg. if I replace firefox.exe with notepad.exe. what's wrong? Thanks
Browsers often have many processes for UI and pages. It's likely the first firefox.exe only serves as a launcher, and it opens subsequent instances of firefox.exe that actually provides the UI. So unfortunately you can't hide the window with your current implementation.
Is there a command on the Windows terminal to close the window of an active application without actually killing the task/process?
What I'm looking for is something similar to clicking the 'X' button on the application window's name bar, or hitting Alt+F4 on it.
Any help would be greatly appreciated. Thanks!
I don't want the taskkill command because it terminates the process. I don't want it to terminate, say I want to close a Skype window so that it pops up in my Notification Tray on my Taskbar.
I couldn't find a specific command on the Windows terminal to do what I wanted, but I found this VBScript code online that did the trick for me.
set shell = createobject("wscript.shell")
shell.appactivate("Skype for Business")
shell.sendkeys "%{F4}"
This simulated an Alt+F4 keypress to Skype, which effectively closed the window and sent it to my Notification Tray.
I am trying to write a program what will manage few console windows, my program will be able to CreateProcess() for new console windows, get a window main handle and the use that handle to resize, close, hide, change title etc. But I cannot find a reliable way to get a main window handle. The purpose is to have a tab bar and switch between created console windows with the click on the tab.
I have tried few ways:
1) use windows "cmd.exe" ability to set window title, and then FindWindow("tmp_title"...)
This has a problem, I do not need cmd.exe running, and also I need a processID for the target program not the cmd.exe. Maybe I should use this way but check for children subprocesses?
2) EnumWindows() then CreateProcess() then wait 40 ms, then EnumWindows() again and find the new window.
This is unreliable! I got two new windows sometimes for weird reasons.
3) use GetWindowThreadProcessId() + EnumWindows(). This worked the best on XP, but on win7 the found window seems to be the wrong one, it's GetWindowText() returns "DefaultIME" and hide/show of this window does nothing. So it is obviously a wrong one.
So any idea how to do it reliably and if possible cross-platform (Cross-windows, XP,Vista,7)