WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Sending Keystrokes

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

SendKey Alt Tab on Windows 7 Ignored

 Keywords: SendKey Alt Tab Alt+Tab !Tab  

Question:

On Windows 7, I would like to create a one line script the send the keystroke Alt+Tab to switch windows. I would like to launch this script by double cliking on the .WBT in Windows Explorer.

Answer:

Here are some Windows-specific issues and hacks
  1. Alt+Tab may be intercepted (or effectively disabled) by means of a low-level keyboard hook. Such a technique is used by applications such as the Virtual Network Computing (VNC) viewer to pass Alt+Tab keystrokes to the remote desktop when the VNC window is active.
  2. If there is only one window on the system, Windows does not show a selector dialog at all when Alt+Tab is pressed; the key sequence will simply restore or give focus to that window in case it is minimized or not focused.
  3. Delay is adjustable by setting the LivePreview_ms value in HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\AltTab registry key.
  4. Some users report that the switcher dialog does not stay on top while it is displayed, but one can navigate through this dialog using mouse even if it is completely overlapped by some window. This bug is reported to be user profile specific. Some user profiles on the same machine may encounter this bug, some not. As discovered, the problem is caused by desktop gadgets system. After killing sidebar.exe process (which hosts the gadgets), the problem disappears. After restarting sidebar the problem appears again. This bug also happens when ipoint.exe, the Microsoft Intellipoint mouse driver, is running.
  5. Using Windows 7 the additional key combination Ctrl+Alt+Tab brings up the switcher dialog and it remains on screen after all the keys have been released. A user can move through the dialog in any direction using the arrow keys, or Tab through in a linear manner, wrapping at the end of the list back to the beginning. In this mode, the Enter key selects the desired window which gains the focus and the dialog is dismissed; Esc dismisses with no change of focus.
  6. Changes to Alt-Tab Z-order starting in Windows Vista ( this also applies to Windows 7 ) http://blogs.msdn.com/b/oldnewthing/archive/2008/07/01/8673981.aspx
Reference:

http://en.wikipedia.org/wiki/Alt-Tab
http://blogs.msdn.com/b/oldnewthing/archive/2008/07/01/8673981.aspx

Also, the developers stated that the behavior of "input focus" has changed on Windows 7. Apparently the Windows shell's threads now get the input focus on Windows 7 when a user clicks on icon in the windows shell (desktop or Windows Explorer). In short, the problem is that on Windows 7, the active window gets lost. When you run the script by double clicking, what happens is that is that one of the windows associated with one of the shell's many threads gets the input focus and that will change the z order. After that, the focus and z order top get passed around to different shell threads depending on what the target is. http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/Shortcut~Information+Use~a~Hotkey~to~Sendkeys~to~an~Active~Window.txt

It is these changes in the OS that will necessitate a modification to the script rather than any changes to WinBatch.

Here is one possible workaround based on the highlighted text above.

;Using Windows 7 the additional key combination Ctrl+Alt+Tab brings up the switcher dialog and it remains on screen after all the keys have been released. 
;A user can move through the dialog in any direction using the arrow keys, or Tab  through in a linear manner, wrapping at the end of the list back to the beginning. 
;In this mode, the Enter key selects the desired window which gains the focus and the dialog is dismissed
SendKey( '^!{TAB}~' )

Article ID:   W18272
Filename:   SendKey Alt Tab on Windows 7 Ignored.txt
File Created: 2014:07:18:09:51:40
Last Updated: 2014:07:18:09:51:40