AutoHotkey Community

It is currently May 26th, 2012, 4:54 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: June 23rd, 2006, 6:35 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8775
Quote:
How to Animate a GUI Window ?
http://www.autohotkey.com/forum/viewtopic.php?p=65596#65596

Quote:
Foreword: The post is all about DllCall to AnimateWindow function in User32.dll.

MSDN Reference: AnimateWindow Function
Additional Reference: Animate a Window - Real's PB How-to

    AnimateWindow() : The Wrapper for User32.dll\AnimateWindow function.

    Code:
    AnimateWindow(hWnd,Duration,Flag) {
    Return DllCall("AnimateWindow","UInt",hWnd,"Int",Duration,"UInt",Flag)
    }


    AnimateWindow() requires three parameters :
    • Handle to the GUI Window
    • Duration of the Animation (in milliseconds)
    • Animation flag which may be any (or proper combination) of the following :

      Code:
      /*

      Note: Following integers have to be converted to Hex
            before passing as a parameter to AnimateWindow

      1       = Left to Right
      2       = Right to Left
      4       = Top to Bottom
      8       = Bottom to Top
      16      = Center           
      65536   = Hide
      131072  = Show
      262144  = Slide
      524288  = Fade

      */

How to Fade-In / Fade-Out a GUI ? How To Fade In Fade Out a GUI ?

    Copy / Paste / Try example:
Code:
FADE       := 524288
SHOW       := 131072
HIDE       := 65536

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

;Converting the above to Hexdecimal value

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

Duration = 500 ; Duration of Animation in milliseconds

Gui, Margin, 0,0
Gui +LastFound
GUI_ID:=WinExist() ; Handle to the GUI
Gui,Show,w400 h300 Hide, Animated Window ( Fade-In / Fade-Out )
AnimateWindow(GUI_ID, Duration, FADE_SHOW)
Return

GuiEscape:
GuiClose:
  AnimateWindow(GUI_ID, Duration, FADE_HIDE)
  ExitApp
Return

AnimateWindow(hWnd,Duration,Flag) {
Return DllCall("AnimateWindow","UInt",hWnd,"Int",Duration,"UInt",Flag)
}
    Optimised version of above code:
Code:
Gui, Margin, 0,0
Gui +LastFound
GUI_ID:=WinExist()
Gui,Show,w400 h300 Hide, Animated Window ( Fade-In / Fade-Out )
DllCall("AnimateWindow","UInt",GUI_ID,"Int",500,"UInt","0xa0000")
Return

GuiEscape:
GuiClose:
  DllCall("AnimateWindow","UInt",GUI_ID,"Int",500,"UInt","0x90000")
  ExitApp
Return


We can modify the wrapper's DllCall to be:
DllCall("AnimateWindow", "UInt", hWnd, "Int", Duration, "Int", Flag)
so that we do not have to convert integers into hexdecimal values.

BUT!.. For reasons unknown to me, many transitions are not smooth (or noticeably jittery!) for me.
Please try both and use what suits you.

In case you need one, here is a simple Integer to Hexadecimal convertor
I made for myself to understand this stuff! I calculated the following effects:

Code:
ROLL_LEFT_TO_RIGHT = 0x20001
ROLL_RIGHT_TO_LEFT = 0x20002
ROLL_TOP_TO_BOTTOM = 0x20004
ROLL_BOTTOM_TO_TOP = 0x20008
ROLL_DIAG_TL_TO_BR = 0x20005
ROLL_DIAG_TR_TO_BL = 0x20006
ROLL_DIAG_BL_TO_TR = 0x20009
ROLL_DIAG_BR_TO_TL = 0x2000a
SLIDE_LEFT_TO_RIGHT= 0x40001
SLIDE_RIGHT_TO_LEFT= 0x40002
SLIDE_TOP_TO_BOTTOM= 0x40004
SLIDE_BOTTOM_TO_TOP= 0x40008
SLIDE_DIAG_TL_TO_BR= 0x40005
SLIDE_DIAG_TR_TO_BL= 0x40006
SLIDE_DIAG_BL_TO_TR= 0x40009
SLIDE_DIAG_BR_TO_TL= 0x40010
ZOOM_IN            = 0x16
ZOOM_OUT           = 0x10010
FADE_IN            = 0xa0000
FADE_OUT           = 0x90000


Visit the following post to download & try SlideShow.exe which extensively and effectively
uses the AnimateWindow function:

Image




Edit:

Quote:
Animated SplashImage !

Copy / Paste / Try example: Fade-In / Fade-Out

Code:
IfNotExist, asplash1.gif
 URLDownloadToFile
 , http://autohotkey.net/goyyah/CrazyScripts/SlideShow/asplash1.gif
 , asplash1.gif

Gui, Margin, 0,0
Gui +LastFound
GUI_ID:=WinExist()
Gui, -Caption +AlwaysOnTop +Border
Gui, Add, Picture, , asplash1.gif
Gui,Show, AutoSize Hide, Animated Splash Window - Demo
DllCall("AnimateWindow","UInt",GUI_ID,"Int",500,"UInt","0xa0000")
Sleep 3000
DllCall("AnimateWindow","UInt",GUI_ID,"Int",500,"UInt","0x90000")
ExitApp


Copy / Paste / Try example: Slide-In from left / Slide-Out to right

Code:
IfNotExist, asplash1.gif
 URLDownloadToFile
 , http://autohotkey.net/goyyah/CrazyScripts/SlideShow/asplash1.gif
 , asplash1.gif

Gui, Margin, 0,0
Gui +LastFound
GUI_ID:=WinExist()
Gui, -Caption +AlwaysOnTop +Border
Gui, Add, Picture, , asplash1.gif
Gui,Show, AutoSize Hide, Animated Splash Window - Demo
DllCall("AnimateWindow","UInt",GUI_ID,"Int",1000,"UInt","0x40001")
Sleep 3000
DllCall("AnimateWindow","UInt",GUI_ID,"Int",1000,"UInt","0x50001")
ExitApp




Edit:

Quote:
Animated SplashText!

Copy / Paste / Try example: Slow Scrolling Text

Code:
ScrollText =
(


AutoHotkey is a free, open-source utility for Windows.

With it, you can:

Automate almost anything by sending keystrokes and mouse
clicks. You can write macros by hand or use the macro recorder.

Create hotkeys for keyboard, joystick, and mouse. Virtually any
key, button, or combination can become a hotkey.

Expand abbreviations as you type them. For example, typing "btw"
can automatically produce "by the way".

Create custom data entry forms, user interfaces, and menu bars.

Remap keys and buttons on your keyboard, joystick, and mouse.

Respond to signals from hand-held remote controls via the WinLIRC
client script.

Run existing AutoIt v2 scripts and enhance them with new capabilities.

Convert any script into an EXE file that can be run on computers
that don't have AutoHotkey installed.



)

Gui, Margin, 0,0
Gui +LastFound
GUI_ID:=WinExist()
Gui, -Caption +AlwaysOnTop +Border
Gui, Color, FFFFFF
Gui, Margin, 40, 40
Gui, Font, s12 Bold, Verdana

Gui, Add, Text, x41 y41 c808080 BackGroundTrans, % ScrollText
Gui, Add, Text, x40 y40 c000000 BackGroundTrans, % ScrollText

Gui,Show, AutoSize Hide, Animated Splash Window - Demo

DllCall("AnimateWindow","UInt",GUI_ID,"Int",20000,"UInt","0x40008")
DllCall("AnimateWindow","UInt",GUI_ID,"Int",20000,"UInt","0x50008")
ExitApp


Last edited by SKAN on June 16th, 2008, 7:35 am, edited 3 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 24th, 2006, 2:31 pm 
Offline

Joined: February 9th, 2006, 8:36 pm
Posts: 338
As to jerky transition in AnimateWindow, MSDN says that it is possible when "Shadows under menus" are enabled in Display effects options. Also "Drag full windows" may interfere I think


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 24th, 2006, 3:34 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
Very nice effects! Thanks!
Goyyah wrote:
we do not have to convert integers into hexadecimal values.
BUT!.. For reasons unknown to me, many transitions are not smooth (or noticeably jittery!) for me.
Since at dll calls AHK passes on integers in binary form, there should be no difference. In my laptop I have not seen any, as expected. Are you sure, there was no other change? You don't need many of your quotation marks, either.
Code:
Gui +LastFound
WinGet GUI_ID, ID
Gui Show, w400 h300 Hide, Animated Window
DllCall("AnimateWindow",UInt,GUI_ID,UInt,750,UInt,0xa0000)
Return

GuiEscape:
GuiClose:
  DllCall("AnimateWindow",UInt,GUI_ID,UInt,750,UInt,0x90000)
ExitApp


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 25th, 2006, 7:51 am 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8775
Dear Laszlo, :)

You wrote:
Since at dll calls AHK passes on integers in binary form, there should be no difference. In my laptop I have not seen any, as expected. Are you sure, there was no other change?


You are right! The jiterring was due to processor load by other running programs. Thank you.

Quote:
You don't need many of your quotation marks, either.


It has become a habit :( ... I will change it :).

Thanks again for posting. :)

Regards, :)


Last edited by SKAN on June 16th, 2008, 7:36 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 25th, 2006, 10:29 am 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8775
Post Updated: Added an example for Slow Scrolling SplashText.

Regards, :)

_________________
URLGet - Internet Explorer based Downloader
StartEx - Portable Shortcut Link


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 30th, 2006, 2:59 pm 
Offline

Joined: March 21st, 2006, 8:31 pm
Posts: 49
Location: Slovakia, Europe :)
1)
hey i just want ask if i can animate also another then gui windows ( ie notepad etc )

i made code like this
Code:
o::
{
WinActivate , a - Notepad
WinGet, GUI_ID , ID , a - Notepad
AnimateWindow(GUI_ID, 5000 , 0x90000 )
winclose , a - Notepad
}

AnimateWindow(hWnd,Duration,Flag) {
Return DllCall("AnimateWindow","UInt",hWnd,"Int",Duration,"UInt",Flag)
}


but it only remove notepad button from taskbar and hide window. ( no fade out ).. pls help :))


2)
also is there a way to hide single button from taskbar ????


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 30th, 2006, 3:31 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8775
Dear Friend, :)

You wrote:
i just want ask if i can animate also another then gui windows ( ie notepad etc )


I am afraid you cannot! Atleast not with AnimateWindow function.
MSDN states that the calling thread (script) should own the window.. (in other words: You may not use WindowsAnimate with a GUI create by an another program!)

You wrote:
also is there a way to hide single button from taskbar ????


I see that you have also posted it in Ask-for-Help section.. Allow me sometime .. I will try to answer it in that post

Regards, :)

_________________
URLGet - Internet Explorer based Downloader
StartEx - Portable Shortcut Link


Last edited by SKAN on July 30th, 2006, 7:47 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 6th, 2007, 10:31 pm 
Quote:
How to Animate a GUI Window ?
Have found that marvelous piece of code. A life saver!
Thanks, Skan (I owe you a लस्सी) 8)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 6th, 2007, 10:57 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8775
BoBo¨ wrote:
I owe you a लस्सी


:D


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 7th, 2007, 12:08 am 
Offline

Joined: June 26th, 2006, 6:14 pm
Posts: 1379
Location: USA
Skan wrote:
BoBo¨ wrote:
I owe you a लस्सी


:D


yogurt drink?????????
(googled it)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 7th, 2007, 8:59 am 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8775
Lassi is a Curd-shake ( like milk-shake ) with added flavour. :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 26th, 2008, 5:24 am 
Offline

Joined: December 30th, 2007, 5:42 pm
Posts: 31
Location: East Coast
Looks like if you have previously set a transcolor in the gui the animation dll calls do not work. I tested several versions of code posted in this topic. All samples work fine until you try to winset, transcolor, somecolor and then dllcall to animate. Is there a way around this that I'm unaware of?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 26th, 2008, 2:01 pm 
Offline

Joined: January 6th, 2008, 8:09 pm
Posts: 39
Location: Gdi+ v1.1
The gui animation (from dll) doesn't work for transparent windows. Try using a loop and a transparency/transcolor function, like this:

Code:
Loop 255
    WinSet, TransColor, FFFFFF %A_Index%, Title


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 26th, 2008, 9:16 pm 
Offline

Joined: December 30th, 2007, 5:42 pm
Posts: 31
Location: East Coast
jk7800 wrote:
The gui animation (from dll) doesn't work for transparent windows. Try using a loop and a transparency/transcolor function, like this:

Code:
Loop 255
    WinSet, TransColor, FFFFFF %A_Index%, Title


Try using ^ for what? The above code makes no sense to me logically. The window is not transparent, part of it is. I have set a transcolor and made a certain part of a gui transparent. It's obvious the dll animation doesnt work for a window with a transcolor set, that was the point in my first post.

What I'm trying to do is show the window from left to right, not fade it. To fade it there's no reason to use dllcall. The above code may be refering to fade I'm not sure. Fade in and out can easily be accomplished with winset transparent, no need to make all colors within the window transparent.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 27th, 2008, 7:23 pm 
Offline

Joined: January 6th, 2008, 8:09 pm
Posts: 39
Location: Gdi+ v1.1
precisewitit wrote:
Is there a way around (...)

You asked for a workaround, so I wrote it. You didn't mention what type of animation you wanted, so I wrote a workaround for fading in the gui. If you know that it won't work, than why are posting?... My script makes sense, because it works and it simply uses the transparency to fade the window (I see nothing "illogical" here). You should post a better question next time and don't criticize attempts of help...


Last edited by jk7800 on August 1st, 2008, 6:36 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: zjaii and 1 guest


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group