AutoHotkey Community

It is currently May 27th, 2012, 5:44 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Random bouncing images
PostPosted: March 17th, 2010, 6:03 am 
Offline

Joined: January 29th, 2010, 6:05 pm
Posts: 41
Location: Decatur, AL
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!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 17th, 2010, 7:09 am 
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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 17th, 2010, 3:45 pm 
Offline

Joined: January 29th, 2010, 6:05 pm
Posts: 41
Location: Decatur, AL
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
   }


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 17th, 2010, 3:54 pm 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 17th, 2010, 3:58 pm 
Offline

Joined: October 15th, 2007, 3:10 pm
Posts: 790
Location: England
If you don't want key presses and mouse moves from the script (if any) to interrupt the Idle time, use A_TimeIdlePhysical instead.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 17th, 2010, 9:17 pm 
Offline

Joined: January 29th, 2010, 6:05 pm
Posts: 41
Location: Decatur, AL
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!


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Apollo, Bing [Bot], Google Feedfetcher, mrhobbeys, rbrtryn and 59 guests


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