# Project SKKGate.py # coding: shift_jis # サンプル1 - 変換・確定・削除の処理の雛形 myself = 0 # 自分のゲート番号 (ゲート0: フロントエンドからの要求) target = 1 # 接続先ゲート番号 (ゲート1: 辞書プロセスへの処理依頼) import win32com.client, re Gate = win32com.client.Dispatch("SKKGate") for i in ("Search", "Abbrev", "Update", "Delete", "Sync", "Exec", "Get", "Put"): Gate._FlagAsMethod(i) # メイン while 1: # 待機 id = Gate.Sync(myself, 1) # 終了 (停止要求 -1 / 二重起動 -2) if id < 0: if id == -2: print "停止します" Gate.Sync(-1, myself) break index = Gate.Get() cand = Gate.Get(1) attr = Gate.Get(2) # 変換 if id == 0: result = re.split(r'\x03', Gate.Search(index, attr, target)) for one in result: Gate.Put(one) # 補完 elif id == 1: result = re.split(r'\x03', Gate.Abbrev(index, attr, target)) for one in result: Gate.Put(one) # 確定 elif id == 2: Gate.Update(index, cand, attr, target) # 削除 elif id == 3: Gate.Delete(index, cand, attr, target) # # 予約 # else: # Gate.Exec(target)