2015-02-09 73 views
0

我有一個隱藏的窗口在AutoHotkey代碼:窗口透明度變化影響活動窗口

NumpadEnter:: 
Trans:=255 
Loop 
{ 
    WinSet, Transparent, %Trans%, A 
    Sleep, 20 
    Trans-=1 
    if(Trans <= 0) 
     Break 
} 
return 

就像一個魅力,但你可以看到這個函數的執行時間約爲4-5秒。我無法在這些4-5秒之間切換其他窗口,因爲其他窗口會受到WinSet功能的影響。

我需要在循環之前將窗口句柄保存到變量。並在WinSet函數中使用它。

我該怎麼做?

+1

後,你嘗試過的代碼。它應該工作。 – KickAss 2015-02-12 17:31:50

+1

請參閱下面我的工作示例代碼。 – KickAss 2015-02-12 19:55:22

回答

1

一種方法是使用帶有A選項的winexist()函數作爲wintittle參數,它將爲您提供活動窗口的ID,以便您可以使用它。

這樣

NumpadEnter:: 
hWnd := WinExist("A") 
Trans:=255 
Loop 
{ 
    WinSet, Transparent, %Trans%, Ahk_id %hWnd% 
    Sleep, 20 
    Trans-=1 
    if(Trans <= 0) 
     Break 
} 
return 

東西希望它可以幫助

+1

您可以使用Windows內置的轉換效果dll隱藏窗口。你可以做很多不同的轉換,並且它們在操作系統處理時都很流暢。我明天會發布代碼。 – KickAss 2015-02-09 23:03:55

+0

GoogleThis WinFade() – 2015-02-10 04:52:42

+1

@KickAss對此有何更新? – 2015-02-11 23:34:22

1

編輯:

完整的文檔: http://www.autohotkey.com/board/topic/80577-how-to-animate-a-gui-window/

編輯2:

你提到它不適合你。下面是一個使用Ahk_L(又名Autohotkey_L或Autohotkey_Lexiko。)Windows 8的機器上工作示例

DetectHiddenWindows, On ;//Allow hidden windows to be detectable 
SetWinDelay, -1 ;//Make Window update very fast (smooth animation) 

FADE  := 524288 
SHOW  := 131072 
HIDE  := 65536 

FADE_SHOW := FADE+SHOW 
FADE_HIDE := FADE+HIDE 

SetFormat, Integer, Hex 
FADE_SHOW+=0 ;//Converts to 0xa0000 
FADE_HIDE+=0 ;//Converts to 0x90000 
SetFormat, Integer, d 

Gui, Font, w500 s35 Center, Verdana 
Gui, Add, Text, , Hello! This Window will hide in 5 Seconds. 
Gui, Show, NA Hide, Test Window ; //Create the Window hidden 
Gui, +LastFound 
GUI_ID := WinExist() ;//Get Window ID 

Duration := 3000 ;//Speed of Window showing/hiding 

DllCall("AnimateWindow","UInt",GUI_ID,"Int",Duration,"UInt", FADE_SHOW) ;//Fade in Window 
Sleep, 5000 ;//Pause for 5 seconds 
DllCall("AnimateWindow","UInt",GUI_ID,"Int",Duration,"UInt", FADE_HIDE) ;//Fade out Window 
Return