Jump to content

WinFadeIn/WinFadeOut Functions


LiquidNitrogen
 Share

Recommended Posts

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

Link to comment
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.

Link to comment
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.

Edited by MilesAhead
Link to comment
Share on other sites

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
Link to comment
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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
Link to comment
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. :)

Link to comment
Share on other sites

  • 1 year later...

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!! :)
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...