• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录

爱女王,爱生活

  • 博客园
  • 联系
  • 订阅
  • 管理

公告

View Post

资源:Python for Windows

http://win32com.goermezer.de/content/blogsection/7/284/

一个网站,有各种Windows 下使用 Python 的脚本示例,很不错,有待继续挖掘。

 

举一个例子:

https://win32com.goermezer.de/content/view/287/285/

 
import win32com.client
# look in the makepy output for IE for the 'CLSIDToClassMap'
# dictionary, and find the entry for 'ShellWindows'
clsid='{9BA05972-F6A8-11CF-A442-00A0C90A8F39}'
ShellWindows=win32com.client.Dispatch(clsid)
 
# a busy state can be detected:
# while ShellWindows[0].Busy == False:
# go in for-loop here
 
for i in range(ShellWindows.Count):
    print ShellWindows[i].LocationURL
    for j in range(ShellWindows[i].Document.SelectedItems().Count):
        print '  ', ShellWindows[i].Document.SelectedItems().Item(j).Path
 
# Be careful: Internet Explorer uses also the same CLSID. You should implement a detection!

这段代码获取当前打开Windows Explorer窗口的名字,以及选中的文件,是不是有种黑科技的感觉呀!

 

posted on 2016-10-19 14:55  爱女王,爱生活  阅读(350)  评论(0)    收藏  举报

刷新页面返回顶部
 
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3