Sign in to follow this  
Followers 0
LiquidNitrogen

WinFadeIn/WinFadeOut Functions

18 posts in this topic

#1 ·  Posted (edited)

i Don't Know if there's Ever Been a Window fade Function but Here's Mine. I Didn't Copy Anything.

WinFadeIn:

Func WinFadeIn($wTitle, $wText)
;By ReaperX
GUISetState(@SW_SHOW, $hWnd)
For $i = 0 to 255 Step 10  
WinSetTrans($wTitle, $wText, $i)  
sleep(60)
Next  
Return
EndFunc

WinFadeOut:

Func WinFadeOut($wTitle, $wText)
;By ReaperX
GUISetState(@SW_SHOW, $hWnd)
For $i = 0 to 255 Step -10
  WinSetTrans($wTitle, $wText, $i)
  sleep(60)
Next
  Return
EndFunc
Edited by ReaperX

Formerly ReaperX

Share this post


Link to post
Share on other sites



Nice.

This ist the best function: _WinAPI_AnimateWindow() from WinAPIEx-UDF.


Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Could be useful. I edited the code a bit. The Fade Out function didn't run because the loop values went from low to high with a negative step. Also got the window handle and used WinActivate instead of GuiSetState

WinFadeOut("WinFadeIn/WinFadeOut Functions","")
Sleep(1000)
WinFadeIn("WinFadeIn/WinFadeOut Functions","")

Func WinFadeIn($wTitle, $wText)
;By ReaperX
Local $hWnd = WinGetHandle($wTitle)
WinActivate($hWnd)
;GUISetState(@SW_SHOW, $hWnd)
For $i = 0 to 255 Step 10
  WinSetTrans($wTitle, $wText, $i)
  sleep(60)
Next
  Return
EndFunc

Func WinFadeOut($wTitle, $wText)
;By ReaperX
Local $hWnd = WinGetHandle($wTitle)
;GUISetState(@SW_SHOW, $hWnd)
WinActivate($hWnd)
For $i = 250 To 0  Step -10
  WinSetTrans($wTitle, $wText, $i)
  sleep(60)
Next
  Return
EndFunc

Also a param for the embedded sleep() instead of 60 hard wired, would adjust the speed. I'm going to try it on a glassy window where AnimateWindow doesn't work. I'll post back if it works.

Edited by MilesAhead
1 person likes this

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Nah, doesn't really do it for composite window. As soon as you touch the transparency value the insides go pale white. Too bad. Looks useful for regular windows.

AnimateWindow() too is not that great if the window has controls you fill with data like a ListBox. As soon as you have the window frame, then the ListBox fills up, obscuring the fade in or slide. AnitmateWindow() fade out is fine. Looks like mainly for splash screen type work.

edit: guess I was wrong about AnimateWindow() Works if I populate the ListBox before making the window visible.

eit2: Fade in doesn't work, with translucent windows. Probably because of the same transparency issue. But the other effects like slide and center do.

Edited by MilesAhead

Share this post


Link to post
Share on other sites

Thanks. Still Expanding my Knowledge. :)


Formerly ReaperX

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Thanks. Still Expanding my Knowledge. :)

Sure thing. I just recently noticed AnimateWindow() from Melba's

I've been adding effects to old programs with Guis that show on hotkey press.

Edited by MilesAhead

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Nice. Also I Cant think of Any Applications to Make or Anything. Got any Ideas That Arent already Made?

Edited by ReaperX

Formerly ReaperX

Share this post


Link to post
Share on other sites

Nice. Also I Cant think of Any Applications to Make or Anything. Got any Ideas That Arent already Made?

Tough to think of something completely original. Usually what I do is make something simple that does something the way I want it that I can't find. For example, you can right click in Explorer then choose New then Folder to make a new folder. In Windows Seven there's a hotkey to do it. But not in Vista. So I wrote a hotkey that makes a new folder when I press F7.

One thing I did in AutoIt that didn't come out as good as I hoped was a recent program grabber. It worked ok as far as detecting the active window is a program and grabbing the exe path and putting the icon in a button. But some programs don't work right unless launched from the shortcut. Somehow finding the associated shortcut automatically and storing that instead of the exe could be cool.

When I hit the hotkey I have a Gui with 16 buttons the last programs run. If I click a button the program launches but it's only the exe with no params or working directory specified. Would be cooler if somehow the shortcut could be linked to the button instead.

Share this post


Link to post
Share on other sites

Hmmm, wish I could call GetStartupInfo but with another process PID. Seems there's an undocumented flag if the program was started via a shorcut with the path to the .lnk file. But it's only callable from the process itself.

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Hmmm... I Have a Few ideas.

Edit: Is There a REG Key that Writes the Options to the "New File/Folder" Context menu?

Edited by ReaperX

Formerly ReaperX

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Yes, there's ShellNew. But what I'm trying to do is get the path of the shortcut that started a process from outside the process. I have a hotkey that watches the active window.

WinAPIEx has a call to get the command line. But I haven't found anything that can get the shortcut path from another process. It would be nice to get it auto-magically. The easy way for the programmer would be just to have the user use SentTo. There's AutoIt function to get the shortcut info. But then it's like just another launcher. If I could somehow get the shortcut path without the user doing anything special then I could cache the last 14 programs.

I have the app all done. It's called ReRun. But it just gets the icon and exe path and has a Gui with 14 buttons. Injecting a DLL into every process to get the info would be too slow. If there was some event hook like FileOpen for .lnk file type, that might work. Thing is if I interfered with .lnk opens it would seem like some malware. So I'm reluctant to go that route. I haven't found any undocumented stuff in PEB that points back to the shortcut. There must be something because it has it in GetProcessInfo() but you can only call that inside the process. Too bad it doesn't take a PID as parameter. :)

Edited by MilesAhead

Share this post


Link to post
Share on other sites

I Have No Idea How it Would Be Done This Way, But Youre Right. It Has to Be Possible.


Formerly ReaperX

Share this post


Link to post
Share on other sites

It's frustrating with Windows because there always seems to be an undocumented thing that does what you want, but you can't use it. :)

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

This page shows how to get the shortcut(if the app was started via shortcut) that started the process, from inside the process:

http://www.catch22.net/tuts/undoc01

Scroll down to :

Detect if an executable was started from a Short-Cut

Interesting stuff. MS tries to keep the fun info to itself. :)

Edited by MilesAhead

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

This page shows how to get the shortcut(if the app was started via shortcut) that started the process, from inside the process:

http://www.catch22.net/tuts/undoc01

Scroll down to :

Detect if an executable was started from a Short-Cut

Interesting stuff. MS tries to keep the fun info to itself. :)

But Youre Interested in Getting it from OUTSIDE the Process, Right?

Edit: That is Interesting. But I Dont Have much Exp. With Booleans, how Would You Retrieve the Flag to Check it?

Edited by ReaperX

Formerly ReaperX

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

For my own program it's easy. Just use the undocumented field of STARTUPINFO as shown in the article. From outside another process I don't know of an easy way. All the stuff I've found has to do with CreateRemoteThread and other ways of poking into another process's address space. I don't want to do that. I was just hoping MS secreted away the info somewhere. As it is, I now can get the command line thanks to the WinAPIEx function. That's some progress.

For example Irfanview will automatically paste from the clipboard when you launch it with this command line switch:

/clippaste but relaunching with no command line switch serves no purpose. In this case I could add the command line switch. But still missing stuff I could get from the .lnk file like custom icon, start folder location etc..

Edited by MilesAhead

Share this post


Link to post
Share on other sites

Well I didn't figure out how to get the STARTUPINFO but thanks to WinAPIEx functions I can get the program path of the active window, the command line args(if there were any) and working directory if it was specified. Almost as good. Doesn't seem to be heavy on CPU or memory. Not bad for a quick and dirty re-launcher. :)

Share this post


Link to post
Share on other sites

Could be useful. I edited the code a bit. The Fade Out function didn't run because the loop values went from low to high with a negative step. Also got the window handle and used WinActivate instead of GuiSetState

WinFadeOut("WinFadeIn/WinFadeOut Functions","")
Sleep(1000)
WinFadeIn("WinFadeIn/WinFadeOut Functions","")

Func WinFadeIn($wTitle, $wText)
;By ReaperX
Local $hWnd = WinGetHandle($wTitle)
WinActivate($hWnd)
;GUISetState(@SW_SHOW, $hWnd)
For $i = 0 to 255 Step 10
WinSetTrans($wTitle, $wText, $i)
sleep(60)
Next
Return
EndFunc

Func WinFadeOut($wTitle, $wText)
;By ReaperX
Local $hWnd = WinGetHandle($wTitle)
;GUISetState(@SW_SHOW, $hWnd)
WinActivate($hWnd)
For $i = 250 To 0 Step -10
WinSetTrans($wTitle, $wText, $i)
sleep(60)
Next
Return
EndFunc

Also a param for the embedded sleep() instead of 60 hard wired, would adjust the speed. I'm going to try it on a glassy window where AnimateWindow doesn't work. I'll post back if it works.

This one worked for me!! Thanks!! :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0