sharpharp Posted January 20, 2010 Posted January 20, 2010 Hi all, Hope somebody can help. I've coded in vbscript and hta to create a small window in the top right of a windows 7 desktop. The hta script displays a small box with orange background in the top right hand corner of the screen, displaying a countdown time from 30 mins to 0 mins. Problem I have is its not possible to use vbscript and hta to keep the hta timer to stay on top of all windows. I would really appreciate it if anyone could help me achieve this with autoit. I simply need a box in the corner with a countdown timer that stays on top and cannot be closed by a user. Thanks, Happy to try any suggested scripts. Sharpy
jvanegmond Posted January 20, 2010 Posted January 20, 2010 http://www.google.com/search?q=site:autoitscript.com+countdown+timerWinSetOnTopBon chance github.com/jvanegmond
sharpharp Posted January 20, 2010 Author Posted January 20, 2010 (edited) http://www.google.com/search?q=site:autoitscript.com+countdown+timer WinSetOnTop Bon chance Thanks, i've had a look, and this looks just like what I am after -it even stays on top of all windows :-) #include <date.au3> Global $afksleep, $lasth, $lastm, $lasts $begin = Random(600000, 1500000, 1) $afksleep = $begin $start = TimerInit() While $afksleep > 0 $afksleep = $begin - TimerDiff($start) GoToBathroom() Sleep(1000) WEnd ToolTip("") Func GoToBathroom() Local $iHours, $iMins, $iSecs _TicksToTime($afksleep, $iHours, $iMins, $iSecs) If $lasth <> $iHours Or $lastm <> $iMins Or $lasts <> $iSecs Then ToolTip("Time left" & " " & $iMins & ":" & $iSecs, 0, 0) $lasth = $iHours $lastm = $iMins $lasts = $iSecs EndIf EndFunc ;==>GoToBathroom However I am not a good programmer at all, so would appreciate it if someone could maybe edit this to display the window on the top right hand side and change the background colour and text size, anyone able to help please? Is it possible to make it flash when it gets down to 1 minute? Again, any help would be appreciated. Edited January 20, 2010 by sharpharp
jvanegmond Posted January 20, 2010 Posted January 20, 2010 We don't do script requests. The name General Help & Support implies that. "Help" is worlds apart from "Do it for you". github.com/jvanegmond
sharpharp Posted January 20, 2010 Author Posted January 20, 2010 We don't do script requests. The name General Help & Support implies that. "Help" is worlds apart from "Do it for you".Ok, no need to be so pompous about it. Don't people help each other these days on a forum like this? I hasten to think if you needed help in an area other than coding, how would you feel if they said no?I would happily help anyone if it was within my means, but like i sais i'm no programmer. I can just about cobble together vbsript and hta, but have no ideas with autoit. I am not asking for a massive program, just simply a countdown timer using the code i have provided, and was hoping perhaps some of the nicer members on here could help with it. You Manadar just need to be more helpful and less anal.
Moderators Melba23 Posted January 20, 2010 Moderators Posted January 20, 2010 sharpharp,Your script will have to change quite a bit as you cannot set a colour to a ToolTip as far as I know. So you will need a small GUI like this:expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <Date.au3> Global $afksleep Global $begin = Random(6000, 150000, 1) Global $afksleep = $begin Global $start = TimerInit() Global $prev = 0 Global $fcolour_toggle = True $hGUI = GUICreate("", 100, 20, @DesktopWidth - 100, 0, BitOR($WS_POPUP, $WS_BORDER), $WS_EX_TOPMOST) $hLabel = GUICtrlCreateLabel("", 0, 0, 100, 20, BitOr($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetBkColor(-1, 0xFF8000) GUISetState() While $afksleep > 0 $afksleep = $begin - TimerDiff($start) If $afksleep / 1000 <> $prev Then $prev = $afksleep / 1000 GoToBathroom() EndIf Sleep(100) WEnd Func GoToBathroom() Local $iHours, $iMins, $iSecs _TicksToTime($afksleep, $iHours, $iMins, $iSecs) GUICtrlSetData($hLabel, "Time left" & " " & $iMins & ":" & StringFormat("%02i", $iSecs)) If $iMins < 1 Then $fcolour_toggle =Not $fcolour_toggle If $fcolour_toggle Then GUICtrlSetBkColor($hLabel, 0xFFFF00) Else GUICtrlSetBkColor($hLabel, 0xFF8000) EndIf EndIf EndFunc ;==>GoToBathroomI have seriously reduced the Random parameters to check the "flash" code - so unless you are suffering from dysentery you may find the bathroom visits a bit too frequent unless you reset them. I think the rest should be self explanatory with a bit of Help file reading, but please ask if anything remains opaque even after that.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
sharpharp Posted January 20, 2010 Author Posted January 20, 2010 That is excellent Melba, much appreciated. (I love the flashy colours, nearly had a seizure with the choice of flashing colours :-) Can I ask quickly, which bit of code moves the box about two inches to the left? Reason being it obscures the X and minimise buttons on open applications? Also, once the countdown reaches 0, is it easy to issue a "logoff" command on the PC? Many thanks Sharpy
Moderators Melba23 Posted January 20, 2010 Moderators Posted January 20, 2010 sharpharp,For the GUI position, this comes from the Help file:GUICreate ( "title" [, width [, height [, left [, top [, style [, exStyle [, parent]]]]]]] )And this from the script:$hGUI = GUICreate("", 100, 20, @DesktopWidth - 100, 0, BitOR($WS_POPUP, $WS_BORDER), $WS_EX_TOPMOST)So you should be able to work that one out on your own! As for logging off - try ShutDown(0). Details of this command can be found............you guessed it! M23P.S. The Help file really is very good. You are likely to get quite a lot of "unhelpful" replies if you have not even looked there first. Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
sharpharp Posted January 20, 2010 Author Posted January 20, 2010 M23, thanks for your help, got the window to move left a bit and the shutdown works well. One last question, and its not in the help i checked. When the script is running, you get an AutoIT icon in the System Tray (which you can pause or exit), is there any way to hide that icon so a user cannot quit the script when it is running? Thanks sharpy
Moderators Melba23 Posted January 20, 2010 Moderators Posted January 20, 2010 sharpharp,its not in the help i checkedWould you be willing to bet? Try looking for #NoTrayIcon. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
sharpharp Posted January 20, 2010 Author Posted January 20, 2010 Time for some new specs :-) Thanks for all your speedy help.
sharpharp Posted January 22, 2010 Author Posted January 22, 2010 (edited) Melba, Is there any way of adjusting the "speed of the flicker rate" when it gets to below 1 minute? I'm just thinking that the present yellow/orange flash rate is a bit too intense.? Cheers Edited January 22, 2010 by sharpharp
Moderators Melba23 Posted January 22, 2010 Moderators Posted January 22, 2010 sharpharp, Sure. Replace the loop with this: While $afksleep > 0 $afksleep = $begin - TimerDiff($start) If Int($afksleep / 1000) <> $prev Then $prev = Int($afksleep / 1000) GoToBathroom() EndIf Sleep(100) WEnd The timer now flashes at 1 per sec. Would Sir like fries with that? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
sharpharp Posted January 27, 2010 Author Posted January 27, 2010 Hi, fries would be good, as long as I can have a large diet coke to go with it plz... Script works well, having adjusted the flash speed, it is perfectly flashing at 1 flash per second when there is 1 minute left but despite all my attempts, I cannot get it to speed up the flash rate at 30 seconds, to great a sense of urgency. I tried messing with the while loop, but that effects the function below for both times. With you being a wizard of fast food and fast scripts, any way of adjusting the script so that the flash rate is slow (as it is already), but then when it gets to 30 seconds left, the flash rate goes ballistic as we had originally? Much appreciated, mr maccy dee's (fry master)
Moderators Melba23 Posted January 27, 2010 Moderators Posted January 27, 2010 (edited) sharpharp, Try this - the flashing is now not quite synchronised with the time, but it does speed up at 30 secs: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <Date.au3> Global $afksleep Global $begin = Random(70000, 80000, 1) Global $afksleep = $begin Global $start = TimerInit() Global $prev = 0 Global $fcolour_toggle = True $hGUI = GUICreate("", 100, 20, @DesktopWidth - 100, 0, BitOR($WS_POPUP, $WS_BORDER), $WS_EX_TOPMOST) $hLabel = GUICtrlCreateLabel("", 0, 0, 100, 20, BitOr($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetBkColor(-1, 0xFF8000) GUISetState() While $afksleep > 0 $afksleep = $begin - TimerDiff($start) Select Case $afksleep < 31100 And $afksleep > 31000 AdlibRegister("_Colour_Toggle", 250) ; reduce this value to increase flash rate Case $afksleep < 61100 And $afksleep > 61000 AdlibRegister("_Colour_Toggle", 1000) EndSelect If Int($afksleep / 1000) <> $prev Then $prev = Int($afksleep / 1000) GoToBathroom() EndIf Sleep(100) WEnd Func GoToBathroom() Local $iHours, $iMins, $iSecs _TicksToTime($afksleep, $iHours, $iMins, $iSecs) GUICtrlSetData($hLabel, "Time left" & " " & $iMins & ":" & StringFormat("%02i", $iSecs)) EndFunc ;==>GoToBathroom Func _Colour_Toggle() $fcolour_toggle = Not $fcolour_toggle If $fcolour_toggle Then GUICtrlSetBkColor($hLabel, 0xFFFF00) Else GUICtrlSetBkColor($hLabel, 0xFF8000) EndIf EndFunc M23 Edit: This one is better - and synchonised again: expandcollapse popupGlobal $afksleep Global $begin = Random(70000, 80000, 1) Global $afksleep = $begin Global $start = TimerInit() Global $prev = 0 Global $fcolour_toggle = True $hGUI = GUICreate("", 100, 20, @DesktopWidth - 100, 0, BitOR($WS_POPUP, $WS_BORDER), $WS_EX_TOPMOST) $hLabel = GUICtrlCreateLabel("", 0, 0, 100, 20, BitOr($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetBkColor(-1, 0xFF8000) GUISetState() While $afksleep > 0 $afksleep = $begin - TimerDiff($start) If Int($afksleep / 1000) <> $prev Then $prev = Int($afksleep / 1000) GoToBathroom() EndIf Sleep(100) WEnd Func GoToBathroom() Local $iHours, $iMins, $iSecs _TicksToTime($afksleep, $iHours, $iMins, $iSecs) GUICtrlSetData($hLabel, "Time left" & " " & $iMins & ":" & StringFormat("%02i", $iSecs)) If $iMins < 1 Then If $iSecs < 30 Then AdlibRegister("_Colour_Toggle", 200) Else _Colour_Toggle() EndIf EndIf EndFunc ;==>GoToBathroom Func _Colour_Toggle() $fcolour_toggle = Not $fcolour_toggle If $fcolour_toggle Then GUICtrlSetBkColor($hLabel, 0xFFFF00) Else GUICtrlSetBkColor($hLabel, 0xFF8000) EndIf EndFunc M23 Edited January 27, 2010 by Melba23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
MegaGamerGuy Posted March 28, 2012 Posted March 28, 2012 (edited) expandcollapse popup#include <WindowsConstants.au3> #include <StaticConstants.au3> #include <Date.au3> Global $afksleep Global $begin = Random(70000, 80000, 1) Global $afksleep = $begin Global $start = TimerInit() Global $prev = 0 Global $fcolour_toggle = True $hGUI = GUICreate("", 100, 20, @DesktopWidth - 100, 0, BitOR($WS_POPUP, $WS_BORDER), $WS_EX_TOPMOST) $hLabel = GUICtrlCreateLabel("", 0, 0, 100, 20, BitOr($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetBkColor(-1, 0xFF8000) GUISetState() While $afksleep > 0 $afksleep = $begin - TimerDiff($start) If Int($afksleep / 1000) <> $prev Then $prev = Int($afksleep / 1000) GoToBathroom() EndIf Sleep(100) WEnd Func GoToBathroom() Local $iHours, $iMins, $iSecs _TicksToTime($afksleep, $iHours, $iMins, $iSecs) GUICtrlSetData($hLabel, "Time left" & " " & $iMins & ":" & StringFormat("%02i", $iSecs)) If $iMins < 1 Then If $iSecs < 30 Then _Colour_Toggle() Sleep(125) _Colour_Toggle() Sleep(125) _Colour_Toggle() Sleep(125) _Colour_Toggle() Sleep(125) _Colour_Toggle() Sleep(125) _Colour_Toggle() Sleep(125) _Colour_Toggle() Sleep(125) _Colour_Toggle() Else _Colour_Toggle() EndIf EndIf EndFunc ;==>GoToBathroom Func _Colour_Toggle() $fcolour_toggle = Not $fcolour_toggle If $fcolour_toggle Then GUICtrlSetBkColor($hLabel, 0xFFFF00) Else GUICtrlSetBkColor($hLabel, 0xFF8000) EndIf EndFunc Didn't notice date until post Thought I'd change Melba23's last edit: AdlibRegister("_Colour_Toggle", 200) to _Colour_Toggle() Sleep(125) _Colour_Toggle() Sleep(125) _Colour_Toggle() Sleep(125) _Colour_Toggle() Sleep(125) _Colour_Toggle() Sleep(125) _Colour_Toggle() Sleep(125) _Colour_Toggle() Sleep(125) _Colour_Toggle() if it looks too tacky use: For $i = 0 to 7 _Colour_Toggle() Sleep(125) Next _Colour_Toggle() Edited March 28, 2012 by MegaGamerGuy
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now