Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

clock


  • Please log in to reply
9 replies to this topic
GBeam
  • Guests
  • Last active:
  • Joined: --
I want to be in a game window, when I click a hotkey, I will have a timer on the top right or left of the screen that will starts to countdown or count up to 20 seconds (note: the timer must be visible and always stay on top of the application in the game mode). Also, when I hit the same hotkey again, I want it to start from either zero and starts to count up to 20 or it count starts from 20 and count down to zero. Furthermore, can the clock be shown as a meter either increasing or decreasing...just like how we install a application..it shows how long we still have left. thank you

Jon
  • Members
  • 349 posts
  • Last active: Aug 30 2011 08:35 PM
  • Joined: 28 Apr 2004
#persistent



^t::



x=20

y=100



Progress,B1 X0 Y0, 20

Progress, 100, 20



loop, 20

{

sleep 1000



x--

y-=5



Progress, %y%, %x%



}



sleep, 1000

progress, off



Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
Great solution. Hopefully the game will allow the window to appear (some full screen games might not show it).

GBeam
  • Guests
  • Last active:
  • Joined: --
Chris,
That was really cool. Thanks a lot.

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
I got this from somewhere:

If it works, Jon wrote it. If it doesn't work, we don't know who wrote it. :)

  • Guests
  • Last active:
  • Joined: --
After looking at the above code I decided to experience using splashtext to create a timer. It counts from 1-5 in a game mode, however, it flashes every interval. How do I stop it from flashing?

#persistent
F1::
SetTimer, ontop,250
a= 1

Loop, 5
{

	SplashTextOn,15 ,20 , timer,%a%
	WinMove,timer, ,0,0
	
	a++
	Sleep, 1000
}

ontop:
WinSet, AlwaysOnTop,on,Confirmation
return
#x::
ExitApp


Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
Here is a revised version that hopefully will work. It uses the on-screen display trick mentioned earlier. It can be improved a little by doing the changes while the window is hidden rather than visible:
#persistent 

F1:: 

a = 1

CustomColor = EEAA99  ; Can be any RGB color (it will be made transparent below).

Gui, color, %CustomColor%

Gui, font, s24  ; Change this font size as desired.

Gui, add, text, cLime, %a%

Gui, show, x0 y0, CountDown

; Make all pixels of this color transparent and make the text itself translucent (150):

WinSet, TransColor, %CustomColor% 200, CountDown

WinSet, AlwaysOnTop, On, CountDown

; Remove the borders. Due to a quirk in Windows, this must be done after transparency:

Gui, -Caption

SetTimer, CountDown, 1000

SetTimer, ontop, 250 

return



CountDown:

if a = 5  ; All done.

{

     SetTimer, CountDown, off

     Gui, Destroy

     return

} 

; Otherwise, since above didn't return:

a++

GuiControl,, static1, %a%  ; Update the window without "flashing".

return



ontop: 

WinSet, AlwaysOnTop,on,Confirmation 

return 



#x:: 

ExitApp


  • Guests
  • Last active:
  • Joined: --
Chris,
Your codes are just awesome. Thanks!

afterburner
  • Members
  • 52 posts
  • Last active: Oct 26 2006 07:11 AM
  • Joined: 23 Jul 2005
Awesome code Chris. I have a few questions:
In addition to your code

1. How can one code to make the form movable? Let's say I want to make it so that I could drag the form out of the way. How could one make it so that the area around close to the edge of the form would allow you to move it?

2. If it is possible to make the form movable (as described above), is it also possible to make the form auto move in case it's in the way of something you need to see? (Like the Microsoft Office Paperclip assistant) If so how? I understand that the MS Office assitant moves when you type close to it, so I'm not asking for that, I'm curious to know if the form could be made to move when you for example placed the mouse pointer at the center of the form, then after 2 seconds the form would move out of the way.
---------------------------------

Afterburner

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004

1. How can one code to make the form movable?
How could one make it so that the area around close to the edge of the form would allow you to move it?

You can try "Gui +Resize", but that might impact the transparency of the window. You can also try something like the Easy Window Drag script, which allows a window to be moved by right-clicking and then dragging its interior.

2. ...is it also possible to make the form auto move in case it's in the way of something you need to see?

It might be possible with something like PixelSearch or PixelGetColor -- it depends on how easy it is to determine the importance of an image based solely on the colors it contains.

...if the form could be made to move when you for example placed the mouse pointer at the center of the form, then after 2 seconds the form would move out of the way.

That's probably possible. You could use SetTimer to periodically call MouseGetPos to determine whether the mouse has hovered over the window long enough.