簡體   English   中英

如果然后在AutoHotkey中循環以在桌面之間切換

[英]If Then Loop in AutoHotkey to switch between desktops

假設^ RButton切換到我的右桌面,^ LButton切換到我的左桌面。 然后的問題是,每當我切換到右側桌面時,都會打開一個下拉菜單,因為我將鼠標右鍵用作熱鍵。 為了解決這個問題,我可以添加sleep 500,然后發送{Escape}退出下拉菜單。 到現在為止還挺好。 但是,如果我現在想從台式機1切換到台式機5,我不能只連續執行5個^ RButton,而必須在每次單擊之間等待半秒。 真煩人! 對於您如何避免每次點擊之間等待500毫秒的想法,我將不勝感激。 我的想法是使用if語句。 雖然我不知道如何編寫一個程序...看起來像這樣:

If ^RButton = True, go to right desktop, 
if after 500 miliseconds there were no further ^RButton clicks, 
then send, {Escape}. 
If there were ^RButton clicks, 
go to the right desktop and wait 500 miliseconds for another ^RButton click,
then send, {Escape}.

如果有人可以將我的文本代碼轉換為AutoHotkey代碼,那就太好了:D

嘗試這個

^RButton:: SendEvent {LWin down}{LCtrl down}{Right down}{LWin up}{LCtrl up}{Right up} ; switch to next virtual desktop
^LButton:: SendEvent {LWin down}{LCtrl down}{Left down}{LWin up}{LCtrl up}{Left up}   ; switch to previous virtual desktop

編輯:

作為獨立腳本適用於我。

也嘗試一下

^RButton:: 
    Send {LWin down}{Ctrl down}{Right}{LWin up}{Ctrl up}    ; switch to next virtual desktop
    SetTimer, CloseContextMenu, -50
return

^LButton:: Send {LWin down}{Ctrl down}{Left}{LWin up}{Ctrl up}  ; switch to previous virtual desktop

CloseContextMenu:
    KeyWait, Ctrl, L
    ; Sleep, 300
    Send {Esc}
return

https://www.autohotkey.com/docs/commands/SetTimer.htm

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM