Use python to automate Windows interface operations

Source: Internet
Author: User

If you want to copy hundreds of files to another directory with duplicate names, but do not want to overwrite the original files, you can use the command line switch to complete the requirement.

Http://sunxiunan.com /? P = 1737

But I have already started copying and want to use the interface. What should I do? (Too tangled !)

Fortunately, we can use python.

Http://www.tizmoi.net/watsup/intro.html

Http://www.brunningonline.net/simon/blog/archives/winGuiAuto.py.html

The main design idea is to use Windows API to find a specific window and then send a keyboard or mouse message.

Watsup I used python2.6, installed pywin32, And the sendkeys library. Finally, download watsup and unzip it to the python lib directory.

CodeVery simple. I slightly modified winguiauto and added the plain text parameter. Because the original wantedtext uses (wantedtextintargetwindows), as long as "no" is returned in the string, it is not the same as what I want to achieve. Of course, you can also use selectionfunction to add lambda, but I don't want to bother.

 
 From watsup. winguiauto import findcontrol, findtopwindow, clickbutton
 From time import sleep 
 
 Awindow = findtopwindow (wantedtext ='Confirm file replace')
 
 WhileAwindow:
 
 Button = findcontrol (awindow, plain text ='No')
 
 Sleep (0.1)
 
 Clickbutton)
 
 Sleep (1)
 Awindow = findtopwindow (wantedtext ='Confirm file replace')

If you use Ruby, you can refer to this article and use related Windows APIs.

http://rubyonwindows.blogspot.com/2007/05/automating-applications-with-ruby.html

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.