首先,感謝@CodingGorilla對AutoHotkey的建議。過去幾天我一直在玩這個遊戲。
我去了AutoHotkey路線,因爲我找不到一個容易的地方開始與任何Windows 10 API。各種各樣的文件推出吐司通知,但我找不到任何東西來控制行動中心。 如果有人對此有建議,請發佈。
這是我想出的使用AutoHotkey。這很簡單,但不是一個理想的解決方案,因爲有幾個變量。下面是我用來打開操作中心,單擊連接AutoHotkey的腳本代碼,然後點擊最上面的上市無線顯示:
Send #a ;Sends Windows button + A to open the action center
Sleep, 750 ; Give it some time to slide open
ImageSearch, FoundX, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, C:\Connect.png ;Try to find the Connect button tile
if ErrorLevel = 2
MsgBox Could not conduct the search for the connect button in action center. Make sure your search image is in the correct location.
else if ErrorLevel = 1
MsgBox Connect button cannot be found on the screen.
else
MoveMouseAndClick(FoundX, FoundY)
Sleep, 1250 ;Delay so the wireless displays have a chance to load into the Action Center window
ImageSearch, FoundX, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, C:\WirelessDisplay.png
if ErrorLevel = 2
MsgBox Could not conduct the search for the wireless display.
else if ErrorLevel = 1
{
;Search image cannot be found. Try 1 more time in case it took a long time for the wireless displays to appear
Sleep, 750
ImageSearch, FoundX, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, C:\WirelessDisplay.png ;try to find the first Wireless Display device listed
if ErrorLevel = 1
MsgBox Wireless display image cannot be found on the screen. Make sure the wireless device is turned on.
else
MoveMouseAndClick(FoundX, FoundY)
}
else
MoveMouseAndClick(FoundX, FoundY)
Send {Esc} ;Send Esc to get rid of the Action Center window
Return
MoveMouseAndClick(x, y) {
MouseMove, x + 25, y + 25 ;Move it down the right a bit to make sure we click the button
Sleep, 250
MouseClick, left
}
我還附上了圖片爲我做出了表率。 您需要製作自己的搜索圖片。在製作這些圖像之前,您還必須關閉Windows 10中的操作中心,啓動和任務欄的透明度 - 設置 - >個性化 - >顏色 - >設置開始,任務欄和操作中心透明 - >關閉。重做第二張圖像特別重要,因爲我的圖像在圖像中列出了「Roku Stick」。我不得不在我的桌面開發機器和MS Surface 3之間重新執行我的搜索圖像。設備之間的分辨率等會有所不同。按照有關如何在這裏創建自己的搜索圖片說明:
https://autohotkey.com/docs/commands/ImageSearch.htm
最後,這可能不會,如果無線顯示已經連接工作。在我的環境中,連接無線顯示器會導致平板電腦上的分辨率發生變化,因此無法在屏幕上找到圖像。
@MuratYıldız - 我們試圖連接到「無線顯示」 - 而不僅僅是一個WiFi網絡。 – jaredbaszler
我不認爲這些Miracast API是你自己認爲的,它們可能是Windows使用自己(底層)執行屏幕鏡像的原因,而不是屏幕鏡像本身的API。你有沒有考慮過像[AutoHotKey](https://www.autohotkey.com/)這樣的東西,你可以記錄按鍵+鼠標宏,並用按鍵執行它們 – CodingGorilla
根據你列出的文檔,Miracast API是列表駕駛員必須執行的功能;你不能調用它們,因爲操作系統必須已經有一個到設備的套接字連接。您是否在Notifications API之上尋找自動化?這將是最有可能的,因爲你只是試圖自動點擊連接 - > MS無線適配器 - >連接。 –