Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

[AHK 1.1+] AnimateWindow wrapper


  • Please log in to reply
18 replies to this topic
nimda
  • Members
  • 4368 posts
  • Last active: Aug 09 2015 02:36 AM
  • Joined: 26 Dec 2010

Hi all
This is a wrapper for "AnimateWindow"
It allows you to have cool effects on showing/hiding Gui's.
Function should be self explanatory. Here's a demo: (Although your real Gui's should NOT take this long to animate wink.png )

Gui, Add, Text,, hi`nBye`nhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh`n`n`n`n
Gui, +LastFound
Gui Show, hide
H := WinExist()
AnimateWindow(H, "Center BT Activate", 2000)
return

GuiClose:
AnimateWindow(H, "Hide Slide TB", 1000)
Sleep 1000
AnimateWindow(H, "Slide RL BT Activate", 500)
Sleep 200
AnimateWindow(H, "Hide Fade", 1000)
ExitApp

; AHK_L AnimateWindow wrapper 5L by nimda
; returns: nonzero on success, false on failure
; MSDN http://msdn.microsoft.com/en-us/library/ms632669(v=vs.85).aspx

AnimateWindow(HWND, Options, t=200){
o := 0, op := {Activate : 0x00020000, Fade : 0x00080000, Center : 0x00000010, Hide : 0x00010000, LR : 0x00000001, RL : 0x00000002, Slide : 0x00040000, TB : 0x00000004, BT : 0x00000008}
For k in op
If InStr(Options, k, false)
o |= op[k]
return DllCall("AnimateWindow", "UPtr", HWND, "Int", t, "UInt", o)
}


aaronbewza
  • Members
  • 466 posts
  • Last active: Feb 05 2013 08:40 AM
  • Joined: 20 Feb 2011
aw that's too cool! gotta use it :) it looks neat.

nimda
  • Members
  • 4368 posts
  • Last active: Aug 09 2015 02:36 AM
  • Joined: 26 Dec 2010
Licensed under the WTFPL as always

aaronbewza
  • Members
  • 466 posts
  • Last active: Feb 05 2013 08:40 AM
  • Joined: 20 Feb 2011
Excellent! A prized addition to the cache stasher :) thank you very much!
Works perfectly on XP (animates the entire window, frames included) but on Windows 7
the window frame appears first, then the animation (while opening) is completed. Then when closed, the window frame stays intact until the animation is completed, then it disappears.

nimda
  • Members
  • 4368 posts
  • Last active: Aug 09 2015 02:36 AM
  • Joined: 26 Dec 2010
Probably something to do with Aero
Theres not much on the MSDN
I can't help much here. I didn't write the thing, I just added 6 lines so you can say "slide" instead of 0x40000 :)

Edit: one thing is keep the animations short. Like the default 200ms. Then it wont be too bad.

aaronbewza
  • Members
  • 466 posts
  • Last active: Feb 05 2013 08:40 AM
  • Joined: 20 Feb 2011
I've got them on 400, 200 is nice too.
Could the GUI's aero theme be turned off right before the function does its thing? That might work.

sumon
  • Moderators
  • 1317 posts
  • Last active: Dec 05 2016 10:14 PM
  • Joined: 18 May 2010
-Caption works, then you can do +Caption when the animation is finished. Seems the window sometimes goes to the background while doing this though, but that is fixable too.

Btw, I'll add the "obvious" that you can use either show or hide, and add a choice (or combination) of options/animations. Read <!-- m -->http://msdn.microsof... ... 69(v=vs.85<!-- m -->).aspx to see what the animations do. TB is Top-to-bottom and BT vice versa.

nimda
  • Members
  • 4368 posts
  • Last active: Aug 09 2015 02:36 AM
  • Joined: 26 Dec 2010
I don't know why everyone isn't running AHK_L with at least revision 97, but this requires revision 97 (just because I'm that lazy :p)

tfwall112
  • Members
  • 31 posts
  • Last active: Nov 06 2014 12:01 AM
  • Joined: 17 Sep 2011
Am I missing something? When I try to run this script I get an error.

Line: 005 Call to nonexistent function
Specifically AnimateWindow(H, "Center BT Activate", 2000)

I dont know where the issue lies.....Do I need to reference the User32.dll or something somewhere?

I am running Vista Home premium SP1 if that helps, and I just got the latest and greatest release of AHK.

I am really new at this scripting thing, and I find out every day that there is something else I need to setup or learn hahahaha.

nimda
  • Members
  • 4368 posts
  • Last active: Aug 09 2015 02:36 AM
  • Joined: 26 Dec 2010
<!-- m -->http://d.ahk4.me/Functions<!-- m -->
You need to #include the function, or copy-paste it in.

tfwall112
  • Members
  • 31 posts
  • Last active: Nov 06 2014 12:01 AM
  • Joined: 17 Sep 2011
I will give'r a go soon....I found a work around with gui, move and winset lol. But seriously, thanks again

  • Guests
  • Last active:
  • Joined: --
You need to click on the code box in nimda's post to expand it and make sure you copy the WHOLE code as you've evidently left out the function definition. :wink:

tfwall112
  • Members
  • 31 posts
  • Last active: Nov 06 2014 12:01 AM
  • Joined: 17 Sep 2011

http://d.ahk4.me/Functions
You need to #include the function, or copy-paste it in.


Ok, tried that. Maybe I am just not doing something right.
I need to #Include User32.dll correct?

I tried it with path and without.
Carats before and after
but I get an error now Function Library not found.

Will your sample script run as a standalone?

I added #Include <User32.dll> at Line1 of your script.

jpjazzy
  • Members
  • 800 posts
  • Last active: Dec 17 2014 07:22 AM
  • Joined: 16 Feb 2010
The function is found right at the bottom of the script that your error is claiming does not exist. The guest is right and you need to put that within your script. When nimda said #Include the function, he meant this:

AnimateWindow(HWND, Options, t=200){
   o := 0, op := {Activate : 0x00020000, Fade : 0x00080000, Center : 0x00000010, Hide : 0x00010000, LR : 0x00000001, RL : 0x00000002, Slide : 0x00040000, TB : 0x00000004, BT : 0x00000008}
   List = Activate|Blend|Center|Hide|LR|RL|Slide|TB|BT
   Loop Parse, List,|
      If InStr(Options, A_LoopField, false)
         o |= op[A_LoopField]
   return DllCall("AnimateWindow", "UInt", HWND, "Int", t, "UInt", o)
}

AutoHotkey Basic - Windows 7
Posted Image

tfwall112
  • Members
  • 31 posts
  • Last active: Nov 06 2014 12:01 AM
  • Joined: 17 Sep 2011

The function is found right at the bottom of the script that your error is claiming does not exist. The guest is right and you need to put that within your script. When nimda said #Include the function, he meant this:

AnimateWindow(HWND, Options, t=200){
   o := 0, op := {Activate : 0x00020000, Fade : 0x00080000, Center : 0x00000010, Hide : 0x00010000, LR : 0x00000001, RL : 0x00000002, Slide : 0x00040000, TB : 0x00000004, BT : 0x00000008}
   List = Activate|Blend|Center|Hide|LR|RL|Slide|TB|BT
   Loop Parse, List,|
      If InStr(Options, A_LoopField, false)
         o |= op[A_LoopField]
   return DllCall("AnimateWindow", "UInt", HWND, "Int", t, "UInt", o)
}


Ok, so what actually happened was when I copied it out of the script window, (I tried selecting text manually (I got it all), then I did the copy function on the page, BUT....when I pasted from the clipboard, it broke the long line with all the 0x0......commands into 3 sections.

I reconfigured the line, and viola, it works.. Thanks folks fer helping me work thru this. I was almost bald.