un zwar habe ich ein Problem mit einem Script.
Ich möchte ein bestimmtes Programm per Hotkey verstecken bzw. wieder sichtbar machen.
Hierfür nutze ich ein angepasstes Beispielscript:
Code: Select all
mwt_MaxWindows = 2
mwt_Hotkey = F9
mwt_UnHotkey = F8
mwt_StandardMenu = N
#HotkeyModifierTimeout 100
SetWinDelay 10
SetKeyDelay 0
#SingleInstance
Hotkey, %mwt_Hotkey%, mwt_Minimize,
Hotkey, %mwt_UnHotkey%, mwt_UnMinimize
OnExit, mwt_RestoreAllThenExit
if mwt_StandardMenu = Y
Menu, Tray, Add
else
{
Menu, Tray, NoStandard
Menu, Tray, Add, E&xit and Unhide All, mwt_RestoreAllThenExit
}
Menu, Tray, Add, &Unhide All Hidden Windows, mwt_RestoreAll
Menu, Tray, Add
if A_AhkVersion =
mwt_MaxLength = 100
else
mwt_MaxLength = 260
return
mwt_Minimize:
if mwt_WindowCount >= %mwt_MaxWindows%
{
MsgBox No more than %mwt_MaxWindows% may be hidden simultaneously.
return
}
WinWait, A,, 2
if ErrorLevel <> 0
return
WinGet, mwt_ActiveID, ID
WinGetTitle, mwt_ActiveTitle
WinGetClass, mwt_ActiveClass
if mwt_ActiveClass in Shell_TrayWnd,Progman
{
MsgBox The desktop and taskbar cannot be hidden.
return
}
Send, !{esc}
WinHide
if mwt_ActiveTitle =
mwt_ActiveTitle = ahk_class %mwt_ActiveClass%
StringLeft, mwt_ActiveTitle, mwt_ActiveTitle, %mwt_MaxLength%
Loop, %mwt_MaxWindows%
{
if mwt_WindowTitle%A_Index% = %mwt_ActiveTitle%
{
StringTrimLeft, mwt_ActiveIDShort, mwt_ActiveID, 2
StringLen, mwt_ActiveIDShortLength, mwt_ActiveIDShort
StringLen, mwt_ActiveTitleLength, mwt_ActiveTitle
mwt_ActiveTitleLength += %mwt_ActiveIDShortLength%
mwt_ActiveTitleLength += 1
if mwt_ActiveTitleLength > %mwt_MaxLength%
{
TrimCount = %mwt_ActiveTitleLength%
TrimCount -= %mwt_MaxLength%
StringTrimRight, mwt_ActiveTitle, mwt_ActiveTitle, %TrimCount%
}
mwt_ActiveTitle = %mwt_ActiveTitle% %mwt_ActiveIDShort%
break
}
}
mwt_AlreadyExists = n
Loop, %mwt_MaxWindows%
{
if mwt_WindowID%A_Index% = %mwt_ActiveID%
{
mwt_AlreadyExists = y
break
}
}
if mwt_AlreadyExists = n
{
Menu, Tray, add, %mwt_ActiveTitle%, RestoreFromTrayMenu
mwt_WindowCount += 1
Loop, %mwt_MaxWindows%
{
if mwt_WindowID%A_Index% =
{
mwt_WindowID%A_Index% = %mwt_ActiveID%
mwt_WindowTitle%A_Index% = %mwt_ActiveTitle%
break
}
}
}
return
RestoreFromTrayMenu:
Menu, Tray, delete, %A_ThisMenuItem%
Loop, %mwt_MaxWindows%
{
if mwt_WindowTitle%A_Index% = %A_ThisMenuItem%
{
StringTrimRight, IDToRestore, mwt_WindowID%A_Index%, 0
WinShow, ahk_id %IDToRestore%
WinActivate ahk_id %IDToRestore%
mwt_WindowID%A_Index% =
mwt_WindowTitle%A_Index% =
mwt_WindowCount -= 1
break
}
}
return
mwt_UnMinimize:
if mwt_WindowCount > 0
{
StringTrimRight, IDToRestore, mwt_WindowID%mwt_WindowCount%, 0
WinShow, ahk_id %IDToRestore%
WinActivate ahk_id %IDToRestore%
StringTrimRight, MenuToRemove, mwt_WindowTitle%mwt_WindowCount%, 0
Menu, Tray, delete, %MenuToRemove%
mwt_WindowID%mwt_WindowCount% =
mwt_WindowTitle%mwt_WindowCount% =
mwt_WindowCount -= 1
}
return
mwt_RestoreAllThenExit:
Gosub, mwt_RestoreAll
ExitApp
mwt_RestoreAll:
Loop, %mwt_MaxWindows%
{
if mwt_WindowID%A_Index% <>
{
StringTrimRight, IDToRestore, mwt_WindowID%A_Index%, 0
WinShow, ahk_id %IDToRestore%
WinActivate ahk_id %IDToRestore%
StringTrimRight, MenuToRemove, mwt_WindowTitle%A_Index%, 0
Menu, Tray, delete, %MenuToRemove%
mwt_WindowID%A_Index% =
mwt_WindowTitle%A_Index% =
mwt_WindowCount -= 1
}
if mwt_WindowCount = 0
break
}
return
Das Programm welches ich verstecken möchte besteht aus zwei Fenstern (deshalb habe ich die mwt_MaxWindows auf 2 gesetzt).
D.h. ich muss zwei mal F9 drücken um es zu verstecken bzw. zwei mal F8 um es wieder sichtbar zu machen.
Was muss ich machen, um den Hotkey nur 1x drücken zu müssen und trotzdem F9 / F8 2x zu senden, damit beide Fenster versteckt werden ich aber nur 1x drücken muss?
Ein weiteres Problem ist, dass das Script beliebige Fenster versteckt. Wie kann ich es umschreiben das es nur das gewünschte Programm (ahk_exe xyz.exe) versteckt?
Ich habe schon alles mögliche probiert, aber leider reichen meine Anfänger Script Skills nicht aus.... :/
Grüße