由于我无处可寻,因此我迅速开发了 AutoIt 的解决方法。
;这里是 AutoIt 代码:
; *** Variables ***
$FrameInPercent = 10
do
$hWindow = WinWaitActive("[CLASS:SunAwtDialog;TITLE:Expression editor]", "") ; *** Wait here until the Expression editor window is opened ***
WinActivate($hWindow)
; *** Calculate distance from screen edge for Expression editor window ***
$DeskSize = _GetWorkingArea()
$WindowWidth = $DeskSize[2]-($DeskSize[2]*(0.01*2*$FrameInPercent))
$WindowHeight = $DeskSize[3]-($DeskSize[3]*(0.01*2*$FrameInPercent))
$windowStartLeft = ($DeskSize[2]*(0.01*$FrameInPercent))
$windowStartTop = ($DeskSize[3]*(0.01*$FrameInPercent))
WinMove($hWindow, "",$windowStartLeft, $windowStartTop, $WindowWidth, $WindowHeight)
;WinMove($hWindow, "",71, 116, 1815, 863)
Do
Sleep(1000) ; calmly idle around as long as the Expression editor window is open
until NOT(WinExists($hWindow))
until False ; *** Loop forever ***
;===============================================================================
;
; Credits for this function goes to: https://www.autoitscript.com/forum/topic/53788-getting-windows-desktop-size/
; Function Name: _GetWorkingArea()
; Description: Returns the coordinates of desktop working area rectangle
; Parameter(s): None
; Return Value(s): On Success - Array containing coordinates:
; $a[0] = left
; $a[1] = top
; $a[2] = right
; $a[3] = bottom
; On Failure - 0
;
;===============================================================================
Func _GetWorkingArea()
#cs
BOOL WINAPI SystemParametersInfo(UINT uiAction, UINT uiParam, PVOID pvParam, UINT fWinIni);
uiAction SPI_GETWORKAREA = 48
#ce
Local $dRECT = DllStructCreate("long; long; long; long")
Local $spiRet = DllCall("User32.dll", "int", "SystemParametersInfo", _
"uint", 48, "uint", 0, "ptr", DllStructGetPtr($dRECT), "uint", 0)
If @error Then Return 0
If $spiRet[0] = 0 Then Return 0
Local $aRet[4] = [DllStructGetData($dRECT, 1), DllStructGetData($dRECT, 2), DllStructGetData($dRECT, 3), DllStructGetData($dRECT, 4)]
Return $aRet
EndFunc
要使用它,您必须安装 AutoIt:https://www.autoitscript.com/site/autoit/downloads/
然后运行这个脚本(双击它)。该脚本将永远运行,但不会占用太多 CPU 资源,因为它在等待表达式编辑器出现时是事件驱动的,并且在表达式编辑器打开时,如果此窗口仍然打开,它只会每 1 秒扫描一次。
希望这对某人有所帮助。
由于这是我的第一个 AutoIt 脚本,欢迎进行优化 :-)