계산기를 시작하거나 이미 열려 있는 경우 창을 '활성화'하거나 이미 활성화된 경우 계산기를 닫는 하나의 단축키를 갖기 위해 다음 스크립트를 만들었습니다. 모든 것이 잘 작동합니다. 계산기가 최소화되면 복원할 수 없다는 점을 인정하세요. 내가 알 수 있는 한 나는 모든 일을 올바르게 해냈습니다. 나는 문제가 무엇인지 이해하지 못합니다. AHK 문서에서는 최소화된 창에서 WinActivate를 호출하면 먼저 해당 창을 복원한다고 주장하지만 이는 거짓말입니다. MsgBox 줄의 주석 처리를 제거하면 창이 최소화될 때 메시지가 계속 표시되지만 더 이상 아무것도 할 수 없습니다.
If WinExist("Calculator") {
;MsgBox Calculator Exists.
IfWinActive
WinKill
Else
WinGet, winState, MinMax
If (winState = -1)
WinRestore, Calculator
WinActivate, Calculator
}
Else {
run calc
WinActivate, Calculator
}
답변1
어떤 OS를 사용하고 있나요? 제목에 ahk_class를 추가하면 코드가 Win10에서 작동합니다.
If WinExist("Calculator ahk_class ApplicationFrameWindow")
{
;MsgBox Calculator Exists.
IfWinActive
WinClose
Else
{
WinGet, winState, MinMax
If (winState = -1)
{
WinRestore
WinActivate
}
}
}
Else
{
run calc
WinWait, Calculator
WinActivate
}
답변2
이것이 내가 나를 위해 일하게 된 것입니다.
;------hotkey to open/close explorer------
^LWin:: ;control and leftwindows
if WinExist("ahk_class ActualTools_TabbedExplorerContainerWindow"){ ; if the window exists
if WinActive("ahk_class ActualTools_TabbedExplorerContainerWindow") or WinActive("ahk_exe Explorer.EXE")
WinMinimize, ahk_class ActualTools_TabbedExplorerContainerWindow
else{
WinActivate ; otherwise make it the active window
}
}else
run, explorer.exe ;otherwise not open, open explorer
return
나는 다음을 사용한다:
;------hotkey to open/close explorer------
^LWin:: ;control and leftwindows
;WinGetClass, Clipboard, A ;Use this to get the name(class?) of the window you want the script to open. https://stackoverflow.com/questions/45642727/what-is-ahk-class-how-can-i-use-it-for-window-matching
if WinExist("ahk_class ActualTools_TabbedExplorerContainerWindow"){ ; if the window exists
WinGet, state, MinMax ;get the state of the window. is it maximized or minimized. this could be part of the issue
If state >= 0 ; if its not minimized, minimize it
WinMinimize
else
WinActivate ; otherwise make it the active window
}else
Run, Explorer.exe ;otherwise not open, open explorer
return
하지만 이 솔루션을 사용하려면 종종 단축키를 두 번 눌러야 했습니다. 한 번 활성화하고(최상위가 아닌 경우에도 여전히 볼 수 있음) 다시 최소화합니다. 이것이 누군가에게 도움이 되기를 바랍니다.