婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > 如何用python 實現老板鍵功能

如何用python 實現老板鍵功能

熱門標簽:ai地圖標注 女王谷地圖標注 長春人工智能電銷機器人官網 如何在地圖標注文字 西藏快速地圖標注地點 地圖標注推廣單頁 百應ai電銷機器人鄭州 廈門crm外呼系統如何 n400電話申請多少錢

主要實現目標:為多個指定的程序實現統一的老板鍵,一鍵隱藏多個指定的應用程序的窗口及任務欄。

1.獲取所有頂層窗口

import win32gui

hwnd_title = dict()

def get_all_hwnd(hwnd, mouse):
 # 判斷句柄是否為窗口、窗口是否允許輸入、窗口是否可視
 if win32gui.IsWindow(hwnd) and win32gui.IsWindowEnabled(hwnd) and win32gui.IsWindowVisible(hwnd):
 hwnd_title.update({hwnd: win32gui.GetWindowText(hwnd)})

# EnumWindows枚舉所有頂層窗口
win32gui.EnumWindows(get_all_hwnd, 0)

# 打印出所有窗口名不為空的窗口
for key in list(hwnd_title):
 if hwnd_title[key] is "":
 del hwnd_title[key]

2.手動選擇需要設置老板鍵的程序

import tkinter as tk

root = tk.Tk()
root.geometry("800x400")

# 列表顯示所有頂層窗口
listBox = tk.Listbox(root, selectmode="multiple")
listBox.pack(side="left", expand="yes", fill="both")

for i, j in hwnd_title.items():
 if j is not "":
 listBox.insert("end", str(i) + ":" + j)

bt = tk.Button(root, text='選擇')
bt.pack()

root.mainloop()

3.隱藏或顯示選中程序

# 通過GetWindowRect方法獲取隱藏前的窗口位置及尺寸信息
left, top, right, bottom = win32gui.GetWindowRect()

def close_windows(aimLists):
 for k in aimLists:
 # 隱藏程序窗口
 win32gui.SetWindowPos(lists[k][0], 0, 0, 0, 0, 0, SWP_HIDEWINDOW)


def open_windows(aimLists):
 for k in aimLists:
 # 顯示程序窗口
 t = lists[k]
 win32gui.SetWindowPos(t['hwnd'], 0, t['left'], t['top'], t['right'] - t['left'], t['bottom'] - t['top'],
  SWP_SHOWWINDOW)

4.設置顯示隱藏快捷鍵

這里設置F7顯示,F8隱藏,F12中止

import PyHook3
import pythoncom

def onKeyboardEvent(event):
 key = event.Key
 if key == "F7":
 close_windows(aimLists)
 if key == "F8":
 open_windows(aimLists)
 if key == "F12":
 win32gui.PostQuitMessage(0)
 return True

hm = PyHook3.HookManager()
hm.KeyDown = onKeyboardEvent
hm.HookKeyboard()

# 開啟監聽
pythoncom.PumpMessages()

5.最終效果

以上就是python 老板鍵功能的實現步驟的詳細內容,更多關于python 老板鍵功能的資料請關注腳本之家其它相關文章!

您可能感興趣的文章:
  • python爬蟲開發之使用python爬蟲庫requests,urllib與今日頭條搜索功能爬取搜索內容實例
  • Python開發之基于模板匹配的信用卡數字識別功能
  • Python使用百度翻譯開發平臺實現英文翻譯為中文功能示例
  • 使用Python來開發微信功能
  • Python開發之快速搭建自動回復微信公眾號功能

標簽:廊坊 黔東 拉薩 亳州 渭南 綿陽 內江 興安盟

巨人網絡通訊聲明:本文標題《如何用python 實現老板鍵功能》,本文關鍵詞  如,何用,python,實現,老板,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《如何用python 實現老板鍵功能》相關的同類信息!
  • 本頁收集關于如何用python 實現老板鍵功能的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 安西县| 大化| 肇东市| 莒南县| 枝江市| 黎平县| 吉安市| 许昌县| 宾阳县| 永城市| 嵊泗县| 鹿邑县| 蚌埠市| 祁东县| 满洲里市| 宁安市| 绥滨县| 天峨县| 镇沅| 万源市| 清流县| 南华县| 宜城市| 弋阳县| 扎兰屯市| 鹤岗市| 汝南县| 铜山县| 临高县| 祁阳县| 通州市| 醴陵市| 阿拉善盟| 新竹县| 大冶市| 弋阳县| 萨迦县| 金川县| 汝州市| 崇文区| 卫辉市|