Efficient programmer tips (1): Use autohotkey to quickly switch windows

Source: Internet
Author: User
Tags ultraedit microsoft outlook

After opening the computer, there will be several opened applications in the taskbar.ProgramAnd switch between them. Most people use the following two methods:

1. Use the tab key

2. Find the target window in the taskbar and click The first method is more efficient, especially when switching between the current window and the previous window, there should be no better way than using the tab key. During our work, there will always be several fixed applications, such as IDE, browser, text editor, mailbox client, instant messaging tools, and help documentation. If we can directly press a shortcut key to switch to the target window, and open the corresponding application when the window does not exist, this is also a good way to quickly open the application.
You can use autohotkey to achieve this goal. At the beginning, you need to adapt for a period of time. You need to familiarize yourself with the shortcut keys corresponding to the application. Opening or switching the window in the future is an instinctive reaction.
It is helpful for improving work efficiency. Autohotkey is a Windows hotkey script language with powerful functions. I just used it, for example, to quickly complete words and switch windows, if you are interested, please take a closer look. First, you need to download autohotkey, address is http://dl.pconline.com.cn/html_2/1/65/id=39876%26pn=0.html After the installation is complete, we have an executable environment. To quickly switch the window, you must use the autohotkey script language to write a script. The following is the script content:  

# Noenv ;  Recommended for performance and compatibility with future autohotkey releases.  
Sendmode Input ; Recommended for new scripts due to its superior speed and reliability.
Setworkingdir % a_scriptdir % ; Ensures a consistent starting directory.
Settitlematchmode 2

Activate (t)
{
Ifwinactive, % T %
{
Winminimize
Return
}
Settitlematchmode 2
Detecthiddenwindows, on
Ifwinexist, % T %
{
Winshow
Winactivate
Return 1
}
Return0
}

Activateandopen (T, P)
{
If activate (t) = 0
{
Run % P %
Winactivate
Return
}
}

# A: : Activateandopen ( " Microsoft Outlook " , " Outlook.exe " )
# B: : Activateandopen ( " Ultraedit " , " C: \ Program Files \ ultraedit \ ultraedit.exe " )
# C: : Activate ( " Ultraedit " )


here, we will briefly describe the initialization statements at the beginning, then, two functions are defined: activie and activeandopen, which call the former. Activie is used to activate a window with a specified title (transmitted through the t parameter or a part of the title, as long as the window can be uniquely identified, if the current window is a window to be activated, hide it. If the window does not exist, the corresponding application is not opened, that is, nothing is done, activieandopen opens the corresponding application if the specified window does not exist. Its first parameter is the window title, and the second parameter is the full path of the application. The three statements after the two function definitions are the call example. Each row is the callback function call. The first letter # indicates that the Windows key is used as the basic key for the shortcut key, because the key itself has fewer associated shortcut keys, we recommend that you use this key. The second letter is the key to be combined with the Windows key, for example, # A represents
win + A as the shortcut key. The two colons define what to do with this shortcut key. Here, we aim to call one of the two functions defined above, for example, in the first line, use win + A to open the outlook mailbox. If the mailbox is not opened yet, it will be started. Copy the script content to notepad and save it as a file with the suffix Ahk. Then, click the file and you will see a green icon with the letter H in the tray, we can switch the window through the predefined shortcut key. to modify the script content, right-click the hmap of the tray and select edit this script, save the edited script, and then select reload this scept from the right-click menu to make the modified script take effect.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.