最近太忙,忙的过程中写了七八个小脚本,其中一些比较通用的,贴在了代码发芽网上:
模拟《骇客帝国》中的滚屏效果,只需要几行简单的Python语句哦,以下是效果图:

#coding:utf-8
#
#简单的几句Python语句,模拟滚动的Matrix屏保
#
# 1. 打开Windows命令行(运行-》输入“cmd”然后回车)
# 2. 打开命令行属性设置,设置背景为黑色,前景为绿色
# 3. 执行这个脚本,就可以看到类似电影《骇客帝国》中的经典滚屏了 - 不过是反着的。。。
#
#呵呵,无聊之作。。。Alt+Enter全屏观看效果更好
import random, string
a = " " * 100 + string.printable
while True:
print a[random.randint(0,len(a)-1)],
#What : a small tool to locate files in system "PATH" variable
import sys
if len(sys.argv) < 2:
print " Usage:"
print " where.py test # normal search"
print " where.py te* # blurred search"
print " where.py -x te*.cmd # regular expression search"
sys.exit()
elif len(sys.argv) == 2:
pattern = sys.argv[1].replace(".", "\\.").replace("*", "\\*").replace("?", ".?").lower()
else:
pattern = sys.argv[2]#tricky, no "-x" checking here
import os
paths = [p for p in os.getenv('PATH').split(";") if p]
exts = [ext.lower() for ext in os.getenv('PATHEXT').split(";") if ext]
paths.append(".\\")
import re
for p in paths:
if not os.path.isdir(p):
continue
for f in os.listdir(p):
if re.search(pattern, f.lower()):
is_exe = False
for ext in exts:
if f.endswith(ext):
is_exe = True
break
if is_exe:
print os.path.join(p,f)
#! /usr/bin/env python # -*- coding: utf-8 -*-
from win32gui import *
titles = set()
def foo(hwnd,nouse):
#去掉下面这句就所有都输出了,但是我不需要那么多
if IsWindow(hwnd) and IsWindowEnabled(hwnd) and IsWindowVisible(hwnd):
titles.add(GetWindowText(hwnd))
EnumWindows(foo, 0)
lt = [t for t in titles if t]
lt.sort()
for t in lt:
print t
十二月 04th, 2009 | 分类:
编程随笔 |