#Requires AutoHotkey v2.0 Persistent SetTimer UpdateFullScreenStatus, 1000 ; 初始化变量 toggle global toggle := 0 return
UpdateFullScreenStatus(){ global IsChromeFullScreen IsChromeFullScreen := false
; 判断Chrome是否为当前活动窗口
If WinActive("ahk_class Chrome_WidgetWin_1")
{
WinGetPos ,, &Width, &Height
; 判断窗口是否与屏幕尺寸相同(即全屏)
IsChromeFullScreen := (Width = A_ScreenWidth && Height = A_ScreenHeight)
}
return
}
#HotIf (WinActive("ahk_class Chrome_WidgetWin_1") && IsChromeFullScreen) XButton1::{ Send "{Left}" KeyWait "XButton1","T1" If GetKeyState("XButton1", "P") Send "{XButton1 up}" return } XButton2::{ Send "{Right}" KeyWait "XButton2","T1" If GetKeyState("XButton2", "P") Send "{XButton2 up}" return } #HotIf ; 重置条件
; 设置热键 Win + Ctrl + Z #^z:: { ; 根据 toggle 的值执行不同的命令 if (toggle = 0) { ; 执行 DisplaySwitch.exe /internal
It looks like you're working on an AutoHotkey script that toggles certain functionalities when Google Chrome is in full-screen mode. The script checks if Chrome is the active window and whether it is in full-screen mode, and it sets up hotkeys for mouse buttons XButton1 and XButton2 to send left and right arrow key presses, respectively.
Here's a continuation and completion of your script, including the toggle functionality for the Win + Ctrl + Z
hotkey:
; 执行 DisplaySwitch.exe /internal
Run, DisplaySwitch.exe /internal
toggle := 1 ; 更新 toggle 状态
} else {
; 执行 DisplaySwitch.exe /extend
Run, DisplaySwitch.exe /extend
toggle := 0 ; 更新 toggle 状态
}
return
}
Persistent and Timer: The script is set to run persistently and checks every second if Chrome is in full-screen mode.
Global Variable: A global variable toggle
is initialized to keep track of the toggle state.
UpdateFullScreenStatus Function: This function checks if the active window is Chrome and whether it is in full-screen mode by comparing its dimensions to the screen size.
Hotkeys:
XButton1
sends a left arrow key press when Chrome is in full-screen mode.XButton2
sends a right arrow key press under the same condition.Toggle Hotkey: The Win + Ctrl + Z
hotkey toggles between two commands:
toggle
is 0, it runs DisplaySwitch.exe /internal
and sets toggle
to 1.toggle
is 1, it runs DisplaySwitch.exe /extend
and sets toggle
to 0.DisplaySwitch.exe
is accessible in your system's PATH or provide the full path to the executable.