 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Laraptor
Joined: 29 Jan 2010 Posts: 41 Location: Decatur, AL
|
Posted: Wed Mar 17, 2010 5:03 am Post subject: Random bouncing images |
|
|
Im trying to get a simple script together that will... well act like a screen saver. Id like for it to pick a random .bmp or other image file and move it around the screen. What I have so far is
| Code: | Loop
{
Random, var3, 22,1269
Random, var4, 14,777
FormatTime, var1,YYYYMMDDHH24MISS, yyyyMMdd
var1 = %var1%1700
var2 =
EnvSub, var1, %var2%, m
SplashImage, wow.bmp,,,Only %var1% min till gamez!, Timez to go!,
WinMove, Timez to go!,,%var3%,%var4%
Sleep, 700
Random, var3, 22,1269
Random, var4, 14,777
WinMove, Timez to go!,,%var3%,%var4%
Sleep, 800
Random, var3, 22,1269
Random, var4, 14,777
WinMove, Timez to go!,, %var3%,%var4%
Sleep, 1500
SplashImage, Off
Sleep, 300000
} |
Which is very basic. All it does is display an image and bounce it around the screen randomly.
Can it be told to randomly pick a img file?
How can I get it to auto run after the mouse or keyboard has been idle for ~10 min?
I was thinking something like... getmousepos, x,y and if x and y remain the same for 10 min then to auto run... but how do i word that?
Then of course mousemove:: break or something to end it.
Thanks much! |
|
| Back to top |
|
 |
link4u Guest
|
Posted: Wed Mar 17, 2010 6:09 am Post subject: |
|
|
| Laraptor wrote: | | How can I get it to auto run after the mouse or keyboard has been idle for ~10 min? | Check out the built-in variable A_TimeIdle. |
|
| Back to top |
|
 |
Laraptor
Joined: 29 Jan 2010 Posts: 41 Location: Decatur, AL
|
Posted: Wed Mar 17, 2010 2:45 pm Post subject: |
|
|
I cant seem to get it right... I have this, but all it does is just spam the image. It just bounces and bounces and I cant stop it unless I exit the script.
| Code: | IfGreater, A_TimeIdle,5000, GoSub, loopy
loopy:
Loop
{
Random, var3, 22,1269
Random, var4, 14,777
FormatTime, var1,YYYYMMDDHH24MISS, yyyyMMdd
var1 = %var1%1700
var2 =
EnvSub, var1, %var2%, m
SplashImage, wow.bmp,,,Only %var1% min till gamez!, Timez to go!,
WinMove, Timez to go!,,%var3%,%var4%
Sleep, 700
Random, var3, 22,1269
Random, var4, 14,777
WinMove, Timez to go!,,%var3%,%var4%
Sleep, 800
Random, var3, 22,1269
Random, var4, 14,777
WinMove, Timez to go!,, %var3%,%var4%
Sleep, 1500
SplashImage, Off
If MouseMove, 1, 1,,R
Break
If A_TimeIdle, 5000
Continue
Sleep, 1000
} |
|
|
| Back to top |
|
 |
answer4u Guest
|
Posted: Wed Mar 17, 2010 2:54 pm Post subject: |
|
|
Here's a simple example that demonstrates recognition of idle time: | Code: | #Persistent
SetTimer, Label, 100
Return
Label:
If A_TimeIdle > 5000
TrayTip, , Idle Time > 5 Seconds
Else, TrayTip
Return |
|
|
| Back to top |
|
 |
OceanMachine
Joined: 15 Oct 2007 Posts: 780 Location: England
|
Posted: Wed Mar 17, 2010 2:58 pm Post subject: |
|
|
| If you don't want key presses and mouse moves from the script (if any) to interrupt the Idle time, use A_TimeIdlePhysical instead. |
|
| Back to top |
|
 |
Laraptor
Joined: 29 Jan 2010 Posts: 41 Location: Decatur, AL
|
Posted: Wed Mar 17, 2010 8:17 pm Post subject: |
|
|
Ok, this is what I ended up with and so far and it seems to work like I want it to, no errors yet. Dispalys the first img 3 times every 5 min I think... then if the pc has been idle for 8 min or longer it displays the 2nd image randomly about the screen untill the mouse moves or the keyboard is touched.
| Code: | #Persistent
SetTimer, Label, 100
Return
Label:
If A_TimeIdle > 500000
GoSub, loopy
If A_TimeIdle < 500000
Goto, normal
Return
loopy:
Loop
{
Random, var3, 22,1269
Random, var4, 14,777
FormatTime, var1,YYYYMMDDHH24MISS, yyyyMMdd
var1 = %var1%1700
var2 =
EnvSub, var1, %var2%, m
SplashImage, pic.jpg,,,txt %var1%, woot!,
WinMove, woot!,,%var3%,%var4%
If A_TimeIdle < 500000
Goto, normal
Sleep, 700
Random, var3, 22,1269
Random, var4, 14,777
WinMove, woot!,,%var3%,%var4%
If A_TimeIdle < 500000
Goto, normal
Sleep, 800
Random, var3, 22,1269
Random, var4, 14,777
WinMove, woot!,, %var3%,%var4%
If A_TimeIdle < 500000
Goto, normal
Sleep, 1500
SplashImage, Off
Sleep, 1000
If A_TimeIdle < 500000
Goto, normal
}
normal:
Loop
{
Random, var3, 39, 1410
Random, var4, 26, 857
FormatTime, var1,YYYYMMDDHH24MISS, yyyyMMdd
var1 = %var1%1700
var2 =
EnvSub, var1, %var2%, m
SplashImage, wow.bmp,,,Only %var1% min till gamez!, Timez to go!,
WinMove, Timez to go!,,%var3%,%Var4%
If A_TimeIdle > 500000
GoSub, loopy
Sleep, 700
Random, var3, 39, 1410
Random, var4, 26, 857
WinMove, Timez to go!,,%var3%,%Var4%
If A_TimeIdle > 500000
GoSub, loopy
Sleep, 800
Random, var3, 39, 1410
Random, var4, 26, 857
WinMove, Timez to go!,, %var3%,%Var4%
If A_TimeIdle > 500000
GoSub, loopy
Sleep, 1500
SplashImage, Off
Sleep, 300000
If A_TimeIdle > 500000
GoSub, loopy
} |
If anyone sees where the code can be cleaned up or improved plz post!
Thanks! |
|
| 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
|