新军's profileIns'PhotosBlogListsMore Tools Help

Blog


    January 02

    开机设置ie标题

    写了一个脚本,每次开机设置IE标题栏,显示当前天气.因人在武汉,所以只显示了武汉的天气.将代码保存为脚本设置为开机自启动即可.
    没有做过多的异常处理,看着用就可以.
    代码:
    [Python Code]
    #!/usr/bin/env python
    #-*-coding:utf-*-
    import win32api
    import win32con
    import datetime
    import urllib
    import re
    socket = urllib.urlopen('http://mimg.126.com/tianqi/city_share/57494.html')
    content = socket.read()
    socket.close()
    pattern = re.compile('<p>(.*)</p>')
    m = pattern.findall(content)
    title = m[0] + ' ' + m[1]
    keyname = 'Software\\Microsoft\\Internet Explorer\Main'
    try:
        key = win32api.RegOpenKey(win32con.HKEY_CURRENT_USER, keyname, 0, win32con.KEY_ALL_ACCESS)
        win32api.RegSetValueEx(key, 'Window Title', 0, win32con.REG_SZ, title)
        win32api.RegCloseKey(key)
    except:
        pass

    Comments

    Please wait...
    Sorry, the comment you entered is too long. Please shorten it.
    You didn't enter anything. Please try again.
    Sorry, we can't add your comment right now. Please try again later.
    To add a comment, you need permission from your parent. Ask for permission
    Your parent has turned off comments.
    Sorry, we can't delete your comment right now. Please try again later.
    You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
    Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
    Complete the security check below to finish leaving your comment.
    The characters you type in the security check must match the characters in the picture or audio.

    To add a comment, sign in with your Windows Live ID (if you use Hotmail, Messenger, or Xbox LIVE, you have a Windows Live ID). Sign in


    Don't have a Windows Live ID? Sign up

    Trackbacks

    The trackback URL for this entry is:
    http://atizu.spaces.live.com/blog/cns!770045E52BB97DD2!228.trak
    Weblogs that reference this entry
    • None