Use autoit3 in a small language to write a small tool for nodejs to enable and disable the nodejs server.

Source: Internet
Author: User
I recently studied nodejs and tried to write a gadget. However, during each debugging process, I need to tap the node command on the CMD interface, for example, "node D: \ nodejs \ nodeweibo \ app. js ". Modified Code , Re-Debug and shut down cmd Program And then open the command. Although it is not difficult, it is complicated and boring.

Those who have used Wamp will surely know that Wamp has a tray on the taskbar. You can easily enable and disable various services on the tray menu.

 

We also need to do something like this to enable and disable the nodejs server. Here I am using a relatively unpopular small language: au3.

Au3 stands for autoit3, and au3 script is the autoit3 windows automatic installation script language. Autoit is an automatic control tool. It can be used to automatically complete any simple windows or DoS-based tasks.

More Introduction: http://baike.baidu.com/view/1539635.htm
 

In au3, you can easily compile the Windows tray program and set the menus on the tray and corresponding processing.

 

The following is the full source code for implementing the Program:

# Include <constants. au3>;
# Include <process. au3>;

Opt ("traymenumode", 1)
Local $ Istart = Traycreateitem ("enabled ")
Local $ Istop = Traycreateitem ("stop ")
Local $ Iexit = Traycreateitem ("exit ")
Traysetstate (1)
While 1
Local $ Msg = Traygetmsg ()
Select
Case $ Msg = 0
Continueloop

Case $ Msg = $ Istart
Trayitemsetstate ( $ Istop , $ Tray_unchecked )
_ Rundos ("Node D: \ nodejs \ nodeweibo \ app. js ") ; The Node command to be executed
Msgbox (64, "enabled:", "nodejs service enabled ")

Case $ Msg = $ Istop
Trayitemsetstate ( $ Istart , $ Tray_unchecked )
Processclose ("node.exe ")
Msgbox (64, "Stop:", "nodejs Service stopped ")

Case $ Msg = $ Iexit
Exitloop
Endselect
Wend
Exit

 

The effect is as follows:

Figure 1 A "A" tray appears in the bottom right corner of the task bar after the program runs.

 

Figure 2: click "enable" to bring up a prompt box

 

 

Figure 3: click "stop" to bring up a prompt box
 

 

Note: au3 can also easily simulate mouse and keyboard operations, and conveniently implement memory operations. So... you can use it to create some plug-ins for games to free your hands.

 

Address: http://www.cnblogs.com/xumingxiang/archive/2012/03/29/2423535.html

Author: Xu mingxiang
Source: http://www.cnblogs.com/xumingxiang
Copyright: The copyright of this article is shared by the author and the blog
Reprinted: you are welcome to reprinted. To save the author's Creative Enthusiasm, please [reprinted] As required. Thank you.
Requirement: This statement must be retained without the author's consent; Article The original text connection is provided; otherwise, the legal liability is required.

 

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.