簡介:
在Windows下的網易郵箱大師客戶端中,閱讀郵件時,可以使用快捷鍵Delete刪除郵件,然后自動跳到下一封,如果再按一次Delete鍵,再跳到下一封。為了迅速的閱讀郵件,同時刪除沒有必要的郵件,特地寫了如下腳本,自用同時放出來共享。
問題:
1. 如上圖,我積累太多未讀郵件,原因是每天郵件太多,根本看不完,數量馬上到上限了;
2. 我想看到每封郵件;
3. 郵件有時內容太過雞肋,屬于知曉型即可,看完即可刪除;
4. 大多數看完就要刪除,一個個刪除太麻煩;
一句話,需要自動刪除我看完之后覺得沒有用處的郵件。
一個解決方案:
見如下代碼
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
import win32api import time def fast_email_reading_and_delete(vk_code: int ) - > None : """ Virtual Key Code reference: https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes """ print ( "Running, please switch to the software you are using within 3 seconds!" ) time.sleep( 3 ) # use this 3 seconds to switch to the software you use, for example Netease email client count = 0 while True : win32api.keybd_event( int (vk_code), 0 , 0 , 0 ) count + = 1 if count % 30 = = 0 : # refresh every 30 seconds to get more email from Netease email server win32api.keybd_event( int ( 0x71 ), 0 , 0 , 0 ) # 0x71 is F2 refresh, int is 113 time.sleep( 1 ) # mail reading time # press space key or right arrow would halt the delete process. 0x20 spacekey 0x27 right arrow key if win32api.GetAsyncKeyState( int ( 0x20 )) or win32api.GetAsyncKeyState( int ( 0x27 )): while True : time.sleep( 0.5 ) if win32api.GetAsyncKeyState( int ( 0x20 )) or win32api.GetAsyncKeyState( int ( 0x27 )): break if __name__ = = '__main__' : fast_email_reading_and_delete( 0x2E ) # 0x2E is DEL key, equivalent int is 46 |
將來我如果有機會自行開發郵件客戶端,就將自動展現郵件內容(一封接著另一封)、自動刪除(或者歸檔)郵件,作為原始功能提供給用戶。
理論上講,上述腳本適用于任何有DEL快捷鍵功能的軟件,注意不要把自己的東西搞砸了,自動刪除時間是1秒。
好了,以上代碼調用了Windows的api,所以只能在Windows下運行,Linux下面應該有類似的工具,歡迎留言交流!
以上就是python 實現網易郵箱郵件閱讀和刪除輔助小腳本的詳細內容,更多關于python 網易郵箱腳本的資料請關注服務器之家其它相關文章!
原文鏈接:https://www.cnblogs.com/johnthegreat/p/13647419.html