 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
infogulch
Joined: 27 Mar 2008 Posts: 123 Location: KC, MO
|
Posted: Tue Jun 17, 2008 8:32 pm Post subject: AnimateWindow - DllCall Test Script with Code Generator |
|
|
I've noticed many scripts with guis that fade/slide into view as a cool animation. Usually they do this with WinMove or WinSet, Transparent inside a loop. I've been guilty of this myself, but there is a much better way!
Using DllCall("AnimateWindow"... you can fade windows, slide them, and make them do other cool stuff. This is more customizable, shorter, and I'm sure, very much more efficient - using less system resources. (as it opereates at a lower level)
Since there are a bunch of options, (and they're not easy to find) I created this script with 2 guis to choose effects and play them out immediately for you to see. When you hit the "Test" button on the main gui, it animates the second gui with the options you select. Then it generates the code that creates that effect in two boxes below for you to copy into your script.
Here's the script.
| Code: | #SingleInstance, Force
SetFormat, integer, Hex
; MSDN: http://msdn.microsoft.com/en-us/library/ms632669(VS.85).aspx
; DllCall("AnimateWindow","UInt", WindowID ,"Int", TimeToFinish ,"UInt", Constants)
AW_HIDE := 0x10000
AW_ACTIVATE := 0x20000
AW_CENTER := 0x10
AW_BLEND := 0x80000
AW_SLIDE := 0x40000
AW_HOR_POSITIVE := 0x1
AW_HOR_NEGATIVE := 0x2
AW_VER_POSITIVE := 0x4
AW_VER_NEGATIVE := 0x8
Menu, Tray, Add
Menu, Tray, Add, Show Test Windows, ShowWindows
ShowWindows:
If Initiated
{
Gui, 2:Show
Gui, Show
return
}
Gui, Add, Text, x5, Animation 1:
Gui, Add, Text, , PlayTime
Gui, Add, Edit, xp+50 vPlayTime1, 500
Gui, Add, CheckBox, v_HIDE1 x5 , AW_HIDE
Gui, Add, CheckBox, v_ACTIVATE1 , AW_ACTIVATE
Gui, Add, CheckBox, v_BLEND1 , AW_BLEND
Gui, Add, CheckBox, v_CENTER1 , AW_CENTER
Gui, Add, CheckBox, v_SLIDE1 , AW_SLIDE
Gui, Add, CheckBox, v_HOR_POSITIVE1 , - AW_HOR_POSITIVE
Gui, Add, CheckBox, v_HOR_NEGATIVE1 , - AW_HOR_NEGATIVE
Gui, Add, CheckBox, v_VER_POSITIVE1 , - AW_VER_POSITIVE
Gui, Add, CheckBox, v_VER_NEGATIVE1 , - AW_VER_NEGATIVE
Gui, Add, Text, ys section, Animation 2:
Gui, Add, Text, , PlayTime
Gui, Add, Edit, xp+50 vPlayTime2, 500
Gui, Add, CheckBox, v_HIDE2 xs , AW_HIDE
Gui, Add, CheckBox, v_ACTIVATE2 , AW_ACTIVATE
Gui, Add, CheckBox, v_BLEND2 , AW_BLEND
Gui, Add, CheckBox, v_CENTER2 , AW_CENTER
Gui, Add, CheckBox, v_SLIDE2 , AW_SLIDE
Gui, Add, CheckBox, v_HOR_POSITIVE2 , - AW_HOR_POSITIVE
Gui, Add, CheckBox, v_HOR_NEGATIVE2 , - AW_HOR_NEGATIVE
Gui, Add, CheckBox, v_VER_POSITIVE2 , - AW_VER_POSITIVE
Gui, Add, CheckBox, v_VER_NEGATIVE2 , - AW_VER_NEGATIVE
Gui, Add, Text, x5, Time Between Animations:
Gui, Add, Edit, xp+130 vSleepTime, 1000
Gui, Add, Button, x5 +Default, &Test
Gui, Add, Button, xp+50 yp gShowWindows, &Show Windows
Gui, Add, Text, x5, 1:
Gui, Add, Edit, xp+20 +ReadOnly w250 vOutput
Gui, Add, Text, x5, 2:
Gui, Add, Edit, xp+20 +ReadOnly w250 vOutput2
Gui, Show, , AnimateWindow Testing
Gui, 2:+ToolWindow +AlwaysOnTop
Gui, 2:Add, Text, , This is a test window. AnimateWindow will work on this`n`n`n`n`n`n`n`n`n
Gui, 2:Show, x10 y500, Test window.
Gui, 2:+LastFoundExist
WindowID := WinExist()
Initiated := True
return
GuiClose:
GuiEscape:
Gui, Hide
return
2GuiClose:
2GuiEscape:
Gui, 2:Hide
return
ButtonTest:
Gui, Submit, NoHide
Constants1 := 0x0 + 0
Constants2 := 0x0 + 0
If _HIDE1
Constants1 := AW_HIDE
If _ACTIVATE1
Constants1 |= AW_ACTIVATE
If _BLEND1
Constants1 |= AW_BLEND
If _SLIDE1
Constants1 |= AW_SLIDE
If _HOR_POSITIVE1
Constants1 |= AW_HOR_POSITIVE
If _HOR_NEGATIVE1
Constants1 |= AW_HOR_NEGATIVE
If _VER_POSITIVE1
Constants1 |= AW_VER_POSITIVE
If _VER_NEGATIVE1
Constants1 |= AW_VER_NEGATIVE
If _CENTER1
Constants1 |= AW_CENTER
If _HIDE2
Constants2 := AW_HIDE
If _ACTIVATE
Constants2 |= AW_ACTIVATE
If _BLEND2
Constants2 |= AW_BLEND
If _SLIDE2
Constants2 |= AW_SLIDE
If _HOR_POSITIVE2
Constants2 |= AW_HOR_POSITIVE
If _HOR_NEGATIVE2
Constants2 |= AW_HOR_NEGATIVE
If _VER_POSITIVE2
Constants2 |= AW_VER_POSITIVE
If _VER_NEGATIVE2
Constants2 |= AW_VER_NEGATIVE
If _CENTER2
Constants2 |= AW_CENTER
If Constants1
DllCall("AnimateWindow", "UInt", WindowID, "Int", PlayTime1, "UInt", Constants1)
Sleep %SleepTime%
If Constants2
DllCall("AnimateWindow", "UInt", WindowID, "Int", PlayTime2, "UInt", Constants2)
Call1 = DllCall("AnimateWindow","UInt", HWND ,"Int", %PlayTime1%,"UInt", %Constants1%)
Call2 = DllCall("AnimateWindow","UInt", HWND ,"Int", %PlayTime2%,"UInt", %Constants2%)
GuiControl, , Output, %Call1%
GuiControl, , Output2, %Call2%
return |
See AnimateWindow's MSDN article for more information.
I learned about AnimateWindow in the Toaster Popups topic. Thanks to Rhys and engunner from there.
Thanks also to the posters in Win32 Constants. I had to use corrupt's version to get the AW_* constant values.
Tell me what you think! _________________
 |
|
| Back to top |
|
 |
Krogdor
Joined: 18 Apr 2008 Posts: 859 Location: The Interwebs
|
Posted: Tue Jun 17, 2008 8:40 pm Post subject: |
|
|
Very, very nice.
I'm barely even beginning to understand DLLCalls at all, and this should come in very handy if I ever feel the need to animate my GUIs. |
|
| Back to top |
|
 |
heresy
Joined: 11 Mar 2008 Posts: 269
|
Posted: Tue Jun 17, 2008 8:40 pm Post subject: |
|
|
it's pretty interesting infogulch.
it would be good if there's easy way to copy generated codes like autocopy
Thanks for sharing ! _________________ Easy WinAPI - Dive into Windows API World
Benchmark your AutoHotkey skills at PlayAHK.com |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 5816
|
|
| Back to top |
|
 |
neXt
Joined: 19 Mar 2007 Posts: 461
|
Posted: Sat Jun 28, 2008 11:33 pm Post subject: |
|
|
really interesting, but your test are not working on vista _________________ simplified csv - easy way to handle csv files. |
|
| Back to top |
|
 |
infogulch
Joined: 27 Mar 2008 Posts: 123 Location: KC, MO
|
Posted: Sun Jun 29, 2008 6:23 pm Post subject: |
|
|
| neXt wrote: | | really interesting, but your test are not working on vista | Man, that's too bad. I wouldn't know what the problem is, though, since I don't have vista. Do you have any hunches? Maybe the dllcall ?
Thanks for your comments. I'll try to update it sometime.  _________________
 |
|
| Back to top |
|
 |
IN2ITive
Joined: 15 Apr 2008 Posts: 47
|
Posted: Mon Jun 30, 2008 3:00 am Post subject: |
|
|
Infogulch...cool idea!
While the Vista issue doesn't affect me yet, I would love to see this functionality implemented into the Expose Clone by holomind. I don't have much time right now but hopefully I will be able to take a look at implementing this. Just gives the user "cooler" features when selecting a window.
Anyway, if anyone wants to see about implementing this in Expose Clone here is the link:
http://www.autohotkey.com/forum/topic13001.html
Thanks again Infogulch! |
|
| Back to top |
|
 |
automaticman
Joined: 27 Oct 2006 Posts: 322
|
Posted: Tue Aug 26, 2008 11:58 am Post subject: |
|
|
Thanks for sharing your idea, just tested quickly and it seems this can give a much cooler feel to any displaying/un-displaying operation in AHK. I was asking myself all the time which is the coolest way of replacing the standard "MsgBox" operations with anything "cooler" having
1- auto removing the message window again after a given time or after any action (also clicking anywhere, rather than on the OK button, or any mouse coordinate change = mouse movement)
2- allowing semi-random movements of this message window depending on its context and application (moving somehow on the screen, also physical behaviour applied to this movements, blending in/out, zooming in/out and fading out nicely without any additional actions necessary.)
3- supporting also some "standard" image library to be used in this message windows, so anyone could simply replace those library images with their own customized images if they wanted.
I have the feeling infogulch's idea might be a good candidate in this direction! |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|