seandisanti Posted January 4, 2006 Share Posted January 4, 2006 (edited) here it is. the last thing you ever needed: a green binary clock that sits in the top left corner of the screen and confuses your co-workers... expandcollapse popup#include <GUIConstants.au3> HotKeySet("!{capslock}", "OkIveWastedEnoughTimeLookingAtThisStupidThing") $hwnd = GUICreate("Text Region", @DesktopWidth, 50, 0, 0, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW)) GUISetBkColor(0x00FF00) GUISetState() While 1 Sleep(1000) $rgn = CreateTextRgn($hwnd, tobin(@HOUR) & "." & tobin(@MIN) & "." & tobin(@SEC), 50, "Arial", 1000) SetWindowRgn($hwnd, $rgn) WEnd Func SetWindowRgn($h_win, $rgn) DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $rgn, "int", 1) EndFunc ;==>SetWindowRgn Func CreateTextRgn(ByRef $CTR_hwnd, $CTR_Text, $CTR_height, $CTR_font = "Microsoft Sans Serif", $CTR_weight = 1000) Local Const $ANSI_CHARSET = 0 Local Const $OUT_CHARACTER_PRECIS = 2 Local Const $CLIP_DEFAULT_PRECIS = 0 Local Const $PROOF_QUALITY = 4 Local Const $FIXED_PITCH = 1 Local Const $RGN_XOR = 3 Local $gdi_dll = DllOpen("gdi32.dll") Local $CTR_hDC = DllCall("user32.dll", "int", "GetDC", "hwnd", $CTR_hwnd) Local $CTR_hMyFont = DllCall($gdi_dll, "hwnd", "CreateFont", "int", $CTR_height, "int", 0, "int", 0, "int", 0, _ "int", $CTR_weight, "int", 0, "int", 0, "int", 0, "int", $ANSI_CHARSET, "int", $OUT_CHARACTER_PRECIS, _ "int", $CLIP_DEFAULT_PRECIS, "int", $PROOF_QUALITY, "int", $FIXED_PITCH, "str", $CTR_font) Local $CTR_hOldFont = DllCall($gdi_dll, "hwnd", "SelectObject", "int", $CTR_hDC[0], "hwnd", $CTR_hMyFont[0]) DllCall($gdi_dll, "int", "BeginPath", "int", $CTR_hDC[0]) DllCall($gdi_dll, "int", "TextOut", "int", $CTR_hDC[0], "int", 0, "int", 0, "str", $CTR_Text, "int", StringLen($CTR_Text)) DllCall($gdi_dll, "int", "EndPath", "int", $CTR_hDC[0]) Local $CTR_hRgn1 = DllCall($gdi_dll, "hwnd", "PathToRegion", "int", $CTR_hDC[0]) Local $CTR_rc = DllStructCreate("int;int;int;int") DllCall($gdi_dll, "int", "GetRgnBox", "hwnd", $CTR_hRgn1[0], "ptr", DllStructGetPtr($CTR_rc)) Local $CTR_hRgn2 = DllCall($gdi_dll, "hwnd", "CreateRectRgnIndirect", "ptr", DllStructGetPtr($CTR_rc)) DllCall($gdi_dll, "int", "CombineRgn", "hwnd", $CTR_hRgn2[0], "hwnd", $CTR_hRgn2[0], "hwnd", $CTR_hRgn1[0], "int", $RGN_XOR) DllCall($gdi_dll, "int", "DeleteObject", "hwnd", $CTR_hRgn1[0]) DllCall("user32.dll", "int", "ReleaseDC", "hwnd", $CTR_hwnd, "int", $CTR_hDC[0]) DllCall($gdi_dll, "int", "SelectObject", "int", $CTR_hDC[0], "hwnd", $CTR_hOldFont[0]) DllClose($gdi_dll) Return $CTR_hRgn2[0] EndFunc ;==>CreateTextRgn Func tobin($number) $result = "" $power = 7 While $number > 0 If BitAND(2 ^ $power, $number) Then $result = $result & "1" $number = $number - 2 ^ $power Else $result = $result & "0" EndIf $power = $power - 1 WEnd While StringLen($result) < 8 If StringLen($result) < 8 Then $result = $result & "0" WEnd Return String($result) EndFunc ;==>tobin Func OkIveWastedEnoughTimeLookingAtThisStupidThing() Exit EndFunc ;==>OkIveWastedEnoughTimeLookingAtThisStupidThing ***edit*** the tooltip saying alt capslock to exit wasn't going away, so i took it out... Edited January 4, 2006 by cameronsdad Link to comment Share on other sites More sharing options...
greenmachine Posted January 4, 2006 Share Posted January 4, 2006 (edited) At first glance, I like the name of the exit function. Now to try it.... Other than the fact that it partially blocks the menus while it's running, I like it. Binary is amusing. Brainstorming... It could be centered. Or.. it could be placed strategically at the top of the screen to fit "within" the menu bar - between title and close buttons. The first three 0's (in hour) could be removed to save space. [ EDIT ] Changed region to the upper right half of the screen, fitting between title and buttons on a full-sized window (such as SciTE). Text is smaller too. My screen dimensions are 1024 by 768 pixels, so bigger and smaller screens would have to adjust. Only two lines I changed: $hwnd = GUICreate("Text Region", 360, 30, 590, 0, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW)) $rgn = CreateTextRgn($hwnd, tobin(@HOUR) & "." & tobin(@MIN) & "." & tobin(@SEC), 30, "Arial", 800) Edited January 4, 2006 by greenmachine Link to comment Share on other sites More sharing options...
seandisanti Posted January 4, 2006 Author Share Posted January 4, 2006 At first glance, I like the name of the exit function. Now to try it....Other than the fact that it partially blocks the menus while it's running, I like it. Binary is amusing.Brainstorming...It could be centered. Or.. it could be placed strategically at the top of the screen to fit "within" the menu bar - between title and close buttons.The first three 0's (in hour) could be removed to save space.yeah i was thinking about trimming it down, 7 spots could be trimmed, which would take about 30% of the length off of it, but decided against it just out of laziness... it's good for work though, because i can disable my systray clock and use that for time, then i won't watch the clock as closely, and by the time i've worked out the time i'm 30 seconds closer to the end of my day... Link to comment Share on other sites More sharing options...
msa2004 Posted January 6, 2006 Share Posted January 6, 2006 (edited) Does this require beta? It compiles for me but I get "C:\*********\******\******\binaryclock.au3 (35) : ==> Unknown function name.: Local $CTR_rc = DllStructCreate("int;int;int;int") Local $CTR_rc = ^ ERROR" on execution. Granted, I'm a newbie. Thanks! Edited January 6, 2006 by msa2004 Link to comment Share on other sites More sharing options...
BigDod Posted January 6, 2006 Share Posted January 6, 2006 Does this require beta? It compiles for me but I get "C:\*********\******\******\binaryclock.au3 (35) : ==> Unknown function name.: Local $CTR_rc = DllStructCreate("int;int;int;int") Local $CTR_rc = ^ ERROR" on execution.Granted, I'm a newbie. Thanks!Yep needs Beta, see link in my sig for download. Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
msa2004 Posted January 6, 2006 Share Posted January 6, 2006 Yep needs Beta, see link in my sig for download.Thanks for the quick reply...I can be taught! Link to comment Share on other sites More sharing options...
seandisanti Posted January 6, 2006 Author Share Posted January 6, 2006 Does this require beta? It compiles for me but I get "C:\*********\******\******\binaryclock.au3 (35) : ==> Unknown function name.: Local $CTR_rc = DllStructCreate("int;int;int;int") Local $CTR_rc = ^ ERROR" on execution.Granted, I'm a newbie. Thanks!yes, beta is required, and no worries about being new, everyone on these forums was at one point or another. welcome to the forums. Link to comment Share on other sites More sharing options...
ACalcutt Posted January 6, 2006 Share Posted January 6, 2006 cool... took me a minute to remember how to count in binary...lol Andrew Calcutt Http://www.Vistumbler.net Http://www.TechIdiots.net Its not an error, its a undocumented feature Link to comment Share on other sites More sharing options...
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