2008/05/08

Add Global Hotkeys for OnlineDic on Windows platform

R8070831 (by plateaukao)
(Ricoh GRD Marseille, France. ile d'if)

到馬賽沒上伊芙島,大概算不上是到過馬賽吧。不過伊芙島卻一點兒也不吸引我。來回的船票要十歐,上了島,還得一定要再交五歐參觀Chateau d'if才行。(如果有買馬賽一日周遊券的話,會比較划算,因為20歐裡面便包含了來回船票,城堡門票,還可以參觀很多市區內的博物館,一日的交通票,Tram,地鐵,巴士坐到爽,還可以坐上山的市區觀光小火車)。可惜我發現有一日券的時間太晚了,所以沒來得及買。

從伊芙島往陸上看去,海的顏色是漸層的,很夢幻。很多家庭拿著食物,就在城堡四周野餐起來,完全不介意這曾經是個關犯人的地方。小時候看過的"基度山恩仇記"早就忘光了,所以不大體會得到被關在這兒的痛苦。

****

from long time ago, I've kept trying to add supports of global hotkeys for onlinedic; however, it's always in vain. Tonight, I finally found a way to achieve it!!! (though it only works for Windows platform) Why didn't I find the API earlier, I keep wondering....

This feature is supported by wxWidgets. As consequences, it's been ported to wxPython too. Actually it's quite easy. All I need to do is to invoke RegisterHotKey provided by Frame.

self.RegisterHotKey(
self.hotKeyIdToggleScan, #a unique ID for this hotkey
MOD_WIN, #the modifier key
VK_F3) #the key to watch for

The usage of the parameters are rather obvious. The last two parameters should be filled in by definitions from win32con. If you don't have installed win32 extension, you can just find out the right definitions you want to used by the second following references.

Once you want to quit the program, you have to unregister the hotkey:

self.UnregisterHotKey(self.hotKeyIdToggleScan)

REF:
Sample of RegisterHotKey for wxpython
Virtual Key Definition in win32con

沒有留言:

張貼留言

中國 App 商業模式 -- 王泌

很有系統地介紹了中國近幾年比較大的幾十個 app,包含他們主要的商業模式,投資者,和特色在哪裡。對於想要了解中國 App (網路服務) 市場的人來說,會是個很好的入門書。雖然已經是兩三年前的資料了,這兩三年又有了很大的變化,但依然是個很好的起點。