Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

Windows 7 Task switcher

If you have a question or need help, this is the place to be.
Post Reply
ThaNerd
Posts: 1
Joined: Tue Aug 14, 2012 4:00 pm

Windows 7 Task switcher

Post by ThaNerd »

I have made a little script to use the Windows 7 aero asks switcher from a single button.
Here is what it takes:
Image

First, here is a reminder of required actions to use the task switcher in a normal environment (ie with a simple keyboard)
  • Press and hold the Windows key
    Press the Tab key and release it. (this must be done once for each window you want to skip, while still holding the Windows Key)
    Release the Windows key to activate selected window.
So i made it in two phases. First phase press and hold the Win Key, presses and releases the tab key. Then it waits for 2 seconds to see if you press the same key again.
If you do, it presses Win key again (for the system, it is already down, so it doesn't matter), and press the Tab key again.
If you don't, it will release the Windows key, and the system will activate the chosen window.

So in shorter version:
Press the event button as many times you want. When the right window is selected, wait for 2 seconds, and Windows will activate that window.

Here is the code:

Code: Select all

    <Folder Name="Win7 Task switcher" Expanded="True">
        <Folder Name="Init switcher" Expanded="True">
            <Macro Name="Script Python" id="852" Expanded="True">
                <Event Name="PS3.Button.PS" />
                <Action Name="Add your event here">
                    EventGhost.Comment()
                </Action>
                <Action>
                    EventGhost.PythonScript(u'import win32api\nwin32api.keybd_event(0x5b,0,0,0)\nwin32api.keybd_event(9,0,0,0)\nwin32api.keybd_event(9,0,2,0)\n')
                </Action>
                <Action>
                    EventGhost.JumpIfDoubleEvent(2.0, XmlIdLink(852))
                </Action>
                <Action>
                    EventGhost.TriggerEvent(u'TaskSwitch.end', 0.0)
                </Action>
            </Macro>
        </Folder>
        <Folder Name="End switcher" Expanded="True">
            <Macro Name="Script Python" Expanded="True">
                <Event Name="TaskSwitch.end" />
                <Action>
                    EventGhost.PythonScript(u'import win32api\nwin32api.keybd_event(0x5b,0,2,0)\n')
                </Action>
            </Macro>
        </Folder>
    </Folder>
Important Notes:
  • The second comment in the sceenshot say nothing. I removed it in code above.
  • PS3.Button.PS is the event i chose to use. Replace with whatever you want.
  • This whole script refer to an item with id 852. If your current config already use this ID, search and replace 852 with something else.
  • This will only work in one way, eg you can't go back to previous window with the approach i used. I guess it could be done, but it's beyond my current abilities (used EventGhost for about a week now)
  • French fries are actually Belgian, not French. Deal with it.
Post Reply