Clock

General Macro Scheduler discussion

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
JRL
Automation Wizard
Posts: 3501
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Clock

Post by JRL » Wed May 08, 2013 9:59 pm

More eye candy. Think of your 1970s "digital" clock.

Click on the dialog to get the next number.


Code: Select all

//"Rate" determines speed of slide
//Bigger number is faster
Let>Rate=7


Dialog>Dialog1
object Dialog1: TForm
  Left = 508
  Top = 234
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'Click to Count'
  ClientHeight = 160
  ClientWidth = 160
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  Position = poScreenCenter
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 96
  TextHeight = 13
  object Panel1: TPanel
    Left = 30
    Top = 30
    Width = 100
    Height = 100
    Color = 16777200
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clBlack
    Font.Height = -96
    Font.Name = 'Arial'
    Font.Style = [fsBold]
    ParentBackground = False
    ParentFont = False
    TabOrder = 0
    object Panel2: TPanel
      Left = 0
      Top = 0
      Width = 100
      Height = 100
      Caption = '1'
      Color = 16777200
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clBlack
      Font.Height = -96
      Font.Name = 'Arial'
      Font.Style = [fsBold]
      ParentBackground = False
      ParentFont = False
      TabOrder = 0
    end
  end
end
EndDialog>Dialog1

AddDialogHandler>Dialog1,,OnClose,Quit
AddDialogHandler>Dialog1,,OnClick,Shift
AddDialogHandler>Dialog1,Panel2,OnClick,Shift
Let>Counter=1

Show>Dialog1,res1

SRT>Shift
  SetDialogProperty>Dialog1,Panel1,Caption,Counter
    Add>Counter,1
  Let>Slide=-100
  SetDialogProperty>Dialog1,Panel2,Caption,Counter
  Repeat>Slide
    Add>Slide,%Rate%
    SetDialogProperty>Dialog1,Panel2,Top,Slide
    Wait>0.02
    //This if> provides a smooth start and end
    //regardless of "Rate"
    If>{%Slide%+%Rate%>-2}
      SetDialogProperty>Dialog1,Panel2,Top,0
      Let>Slide=done
    EndIf
  Until>Slide=done
END>Shift

SRT>Quit
  Exit>0
END>Quit
edit-1: Changed the subject line from "Number Change Via Slide" to "Clock"
Last edited by JRL on Tue Jun 04, 2013 9:50 pm, edited 1 time in total.

User avatar
CyberCitizen
Automation Wizard
Posts: 721
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

Post by CyberCitizen » Thu May 09, 2013 3:00 am

Very Impressive Script. Great Work, Very Simple And Tidy Script As Well, I Would Like To Suggest This One For The Scripts & Tips Comp.

If You Could Make It Into A Clock, That Would Be Awesome.
FIREFIGHTER

User avatar
JRL
Automation Wizard
Posts: 3501
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Fri May 10, 2013 7:37 pm

Ok Cy, here is the old Number flap clock for your desktop. A lot could be done with this but there's never enough time.

Click on the clock for a menu. From the menu you can put the border on the clock. With the border the clock can be moved and or resized. After moving or resizing it as you like, remove the border (or not). From the menu you can also recolor the background to suit your taste. You'll need to know the color number of the color you like.

To close the clock, go to the menu and pick "Close the Clock".

Have fun.

Edit1: Its now compilable and a transparent color can be selected.

Edit2: Made the ante meridiem / post meridiem, issue due to operating system regional settings a non issue. Renamed the variable "Meridian" to "Meridiem" now that I've looked it up and see my memory has failed me.

Code: Select all

If>ScriptToRun<>{"ScriptToRun"}
  Macro>%ScriptToRun%
  Exit>0
EndIf

//"Rate" determines speed of slide
//Bigger number is faster
Let>Rate=6

IfFileExists>%temp_dir%Clock_Reflection.scp
  DeleteFile>%temp_dir%Clock_Reflection.scp
EndIf

Dialog>Dialog1
object Dialog1: TForm
  AlphaBlend = True
  AlphaBlendValue = 0
  BorderStyle = bsNone
  Caption = 'InvisibleClock'
  ClientHeight = 180
  ClientWidth = 520
  Color = 75
  Position = poScreenCenter
  object Label1: TLabel
    Left = 125
    Top = 40
    Width = 18
    Height = 77
    Caption = ':'
    Font.Charset = ANSI_CHARSET
    Font.Color = clWhite
    Font.Height = -67
    Font.Name = 'Arial Narrow'
    Font.Style = [fsBold]
    ParentFont = False
  end
  object Label2: TLabel
    Left = 255
    Top = 40
    Width = 18
    Height = 77
    Caption = ':'
    Font.Charset = ANSI_CHARSET
    Font.Color = clWhite
    Font.Height = -67
    Font.Name = 'Arial Narrow'
    Font.Style = [fsBold]
    ParentFont = False
  end
  object Panel1: TPanel
    Left = 20
    Top = 30
    Width = 50
    Height = 100
    Color = 16777200
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clBlack
    Font.Height = -96
    Font.Name = 'Arial'
    Font.Style = [fsBold]
    ParentBackground = False
    ParentFont = False
    TabOrder = 1
    object Panel101: TPanel
      Left = 0
      Top = 0
      Width = 50
      Height = 100
      Caption = '0'
      Color = 16777200
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clBlack
      Font.Height = -96
      Font.Name = 'Arial'
      Font.Style = [fsBold]
      ParentBackground = False
      ParentFont = False
      TabOrder = 0
    end
  end
  object Panel2: TPanel
    Left = 70
    Top = 30
    Width = 50
    Height = 100
    Color = 16777200
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clBlack
    Font.Height = -96
    Font.Name = 'Arial'
    Font.Style = [fsBold]
    ParentBackground = False
    ParentFont = False
    TabOrder = 2
    object Panel102: TPanel
      Left = 0
      Top = 0
      Width = 50
      Height = 100
      Caption = '0'
      Color = 16777200
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clBlack
      Font.Height = -96
      Font.Name = 'Arial'
      Font.Style = [fsBold]
      ParentBackground = False
      ParentFont = False
      TabOrder = 0
    end
  end
  object Panel3: TPanel
    Left = 150
    Top = 30
    Width = 50
    Height = 100
    Color = 16777200
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clBlack
    Font.Height = -96
    Font.Name = 'Arial'
    Font.Style = [fsBold]
    ParentBackground = False
    ParentFont = False
    TabOrder = 3
    object Panel103: TPanel
      Left = 0
      Top = 0
      Width = 50
      Height = 100
      Caption = '0'
      Color = 16777200
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clBlack
      Font.Height = -96
      Font.Name = 'Arial'
      Font.Style = [fsBold]
      ParentBackground = False
      ParentFont = False
      TabOrder = 0
    end
  end
  object Panel4: TPanel
    Left = 200
    Top = 30
    Width = 50
    Height = 100
    Color = 16777200
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clBlack
    Font.Height = -96
    Font.Name = 'Arial'
    Font.Style = [fsBold]
    ParentBackground = False
    ParentFont = False
    TabOrder = 4
    object Panel104: TPanel
      Left = 0
      Top = 0
      Width = 50
      Height = 100
      Caption = '0'
      Color = 16777200
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clBlack
      Font.Height = -96
      Font.Name = 'Arial'
      Font.Style = [fsBold]
      ParentBackground = False
      ParentFont = False
      TabOrder = 0
    end
  end
  object Panel5: TPanel
    Left = 280
    Top = 30
    Width = 50
    Height = 100
    Color = 16777200
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clBlack
    Font.Height = -96
    Font.Name = 'Arial'
    Font.Style = [fsBold]
    ParentBackground = False
    ParentFont = False
    TabOrder = 5
    object Panel105: TPanel
      Left = 0
      Top = 0
      Width = 50
      Height = 100
      Caption = '0'
      Color = 16777200
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clBlack
      Font.Height = -96
      Font.Name = 'Arial'
      Font.Style = [fsBold]
      ParentBackground = False
      ParentFont = False
      TabOrder = 0
    end
  end
  object Panel6: TPanel
    Left = 330
    Top = 30
    Width = 50
    Height = 100
    Color = 16777200
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clBlack
    Font.Height = -96
    Font.Name = 'Arial'
    Font.Style = [fsBold]
    ParentBackground = False
    ParentFont = False
    TabOrder = 6
    object Panel106: TPanel
      Left = 0
      Top = 0
      Width = 50
      Height = 100
      Caption = '0'
      Color = 16777200
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clBlack
      Font.Height = -96
      Font.Name = 'Arial'
      Font.Style = [fsBold]
      ParentBackground = False
      ParentFont = False
      TabOrder = 0
    end
  end
  object Panel7: TPanel
    Left = 400
    Top = 30
    Width = 50
    Height = 100
    Color = 16777200
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clBlack
    Font.Height = -96
    Font.Name = 'Arial'
    Font.Style = [fsBold]
    ParentBackground = False
    ParentFont = False
    TabOrder = 7
    object Panel107: TPanel
      Left = 0
      Top = 0
      Width = 50
      Height = 100
      Caption = 'P'
      Color = 16777200
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clBlack
      Font.Height = -66
      Font.Name = 'Arial'
      Font.Style = [fsBold]
      ParentBackground = False
      ParentFont = False
      TabOrder = 0
    end
  end
  object Panel8: TPanel
    Left = 450
    Top = 30
    Width = 50
    Height = 100
    Caption = 'M'
    Color = 16777200
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clBlack
    Font.Height = -66
    Font.Name = 'Arial'
    Font.Style = [fsBold]
    ParentBackground = False
    ParentFont = False
    TabOrder = 0
  end
end
EndDialog>Dialog1

Dialog>Dialog2
object Dialog2: TForm
  Position = poScreenCenter
  BorderStyle = bsNone
  BorderIcons = []
  TransparentColor = True
  TransparentColorValue = 16777190
  Caption = 'DickitalClock'
  ClientHeight = 180
  ClientWidth = 520
end
EndDialog>Dialog2

Dialog>Dialog3
object Dialog3: TForm
  AutoSize = True
  AlphaBlend = True
  AlphaBlendValue = 255
  BorderStyle = bsNone
  object Panel1: TPanel
    Left = 0
    Top = 0
    Width = 130
    Height = 25
    Alignment = taLeftJustify
    Caption = 'Border'
    TabOrder = 0
  end
  object Panel2: TPanel
    Left = 0
    Top = 25
    Width = 130
    Height = 25
    Alignment = taLeftJustify
    Caption = 'Background Color'
    TabOrder = 1
  end
  object Panel3: TPanel
    Left = 0
    Top = 50
    Width = 130
    Height = 25
    Alignment = taLeftJustify
    Caption = 'Close the Clock'
    TabOrder = 2
  end
  object Panel4: TPanel
    Left = 0
    Top = 75
    Width = 130
    Height = 25
    Alignment = taLeftJustify
    Caption = 'Close This Menu'
    TabOrder = 3
  end
end
EndDialog>Dialog3

AddDialogHandler>Dialog2,,OnClose,Quit
AddDialogHandler>Dialog2,,OnClick,Ask
AddDialogHandler>Dialog3,Panel1,OnClick,Border
AddDialogHandler>Dialog3,Panel2,OnClick,BGColor
AddDialogHandler>Dialog3,Panel3,OnClick,CloseClock
AddDialogHandler>Dialog3,Panel4,OnClick,CloseMenu

Let>Counter=0
Let>arr_kk=0
Repeat>arr_kk
  add>arr_kk,1
  Let>Last%arr_kk%=0
Until>arr_kk=6

Show>Dialog1
Show>Dialog2

GetTime>now
Length>now,nlen
Sub>nlen,1
MidStr>now,nlen,1,Meridiem
SetDialogProperty>Dialog1,Panel107,Caption,Meridiem
SetDialogProperty>Dialog1,Panel7,Caption,Meridiem

LabelToVar>Reflection,vscript
WriteLn>%temp_dir%Clock_Reflection.scp,wres,vScript
Wait>0.1

ExtractFileName>%Command_Line%,WhatToDo
LowerCase>WhatToDo,WhatToDo
StringReplace>WhatToDo,",,WhatToDo
Trim>WhatToDo,WhatToDo
If>WhatToDo=msched.exe
  ExecuteFile>%temp_dir%Clock_Reflection.scp
Else
Let>RP_Wait=0
  RunProgram>%Command_Line% /ScriptToRun=%temp_dir%Clock_Reflection.scp
EndIf

Label>Loop
  Hour>HH
  If>%HH%>11
    Let>NewMeridiem=P
    If>NewMeridiem<>Meridiem
      Let>Meridiem=NewMeridiem
      GoSub>MeridiemChange
    EndIf
  EndIf
  If>%HH%<12
    Let>NewMeridiem=A
    If>NewMeridiem<>Meridiem
      Let>Meridiem=NewMeridiem
      GoSub>MeridiemChange
    EndIf
  EndIf

  Min>MN
  Sec>SS
  If>%HH%>12
    Sub>HH,12
    VBEval>right("00"&"%HH%",2),HH
  EndIf
  If>%HH%=00
    Let>HH=12
  EndIf
  MidStr>HH,1,1,next1
  MidStr>HH,2,1,next2
  MidStr>MN,1,1,next3
  MidStr>MN,2,1,next4
  MidStr>SS,1,1,next5
  MidStr>SS,2,1,next6
  Let>nxt_kk=7
  Repeat>nxt_kk
  Sub>nxt_kk,1
  Let>value1=last%nxt_kk%
  Let>value2=next%nxt_kk%
    If>%value1%<>%value2%
      Let>slide_kk=%nxt_kk%+100
      GoSub>Shift,%nxt_kk%,%slide_kk%
    EndIf
    Let>last%nxt_kk%=%value2%
  Until>nxt_kk=1
  Wait>0.01
Goto>Loop

SRT>Shift
  SetDialogProperty>Dialog1,Panel%Shift_var_1%,Caption,value1
  Let>Slide=-100
  SetDialogProperty>Dialog1,Panel%Shift_var_2%,Top,Slide
  SetDialogProperty>Dialog1,Panel%Shift_var_2%,Caption,value2
  Repeat>Slide
    Add>Slide,%Rate%
    SetDialogProperty>Dialog1,Panel%Shift_var_2%,Top,Slide
    Wait>0.01
    //This if> provides a smooth start and end
    //regardless of "Rate"
    If>{%Slide%+%Rate%>-2}
      SetDialogProperty>Dialog1,Panel%Shift_var_2%,Top,0
      Let>Slide=done
    EndIf
  Until>Slide=done
END>Shift

SRT>MeridiemChange
  Let>value2=Meridiem
  GetDialogProperty>Dialog1,Panel7,Caption,value1
  GoSub>Shift,7,107
END>MeridiemChange

SRT>Ask
  GetCursorPos>CurX,CurY
  Let>WIN_USEHANDLE=1
    MoveWindow>Dialog3.Handle,CurX,CurY
  Let>WIN_USEHANDLE=0
  Show>Dialog3
END>Ask

SRT>Border
  GetDialogProperty>Dialog3,Panel1,Caption,D3Cap
  If>D3Cap=Border
    SetDialogProperty>Dialog1,,BorderStyle,bsSizeable
    SetDialogProperty>Dialog2,,BorderStyle,bsSizeable
    SetDialogProperty>Dialog3,Panel1,Caption,No Border
  Else
    SetDialogProperty>Dialog1,,BorderStyle,bsNone
    SetDialogProperty>Dialog2,,BorderStyle,bsNone
    SetDialogProperty>Dialog3,Panel1,Caption,Border
  EndIf
  CloseDialog>Dialog1
  Show>Dialog1
  CloseDialog>Dialog3
END>Border

SRT>BGColor
  Input>NewColor,New Color Number For Clock BackGround,16777190 to be transparent
  If>NewColor=
  Else
    SetDialogProperty>Dialog1,,Color,NewColor
  EndIf
  CloseDialog>Dialog3
END>BGColor

SRT>CloseClock
  CloseDialog>Dialog2
END>CloseClock

SRT>CloseMenu
  CloseDialog>Dialog3
END>CloseMenu

SRT>Quit
  Exit>0
END>Quit



/*
Reflection:
OnEvent>WINDOW_NOTOPEN,InvisibleClock,1,Quit

  LibFunc>user32,GetDC,HDC1,%Dialog1.handle%
  LibFunc>user32,GetDC,HDC2,%Dialog2.handle%
  LibFunc>Gdi32,SetStretchBltMode,SSBMres,HDC2,4
  LibFunc>Gdi32,SetBrushOrgEx,SBOEres,HDC2,0,0,

Label>Loop
  Let>WIN_USEHANDLE=1
    GetWindowSize>%Dialog2.handle%,WinX,WinY
  Let>WIN_USEHANDLE=0
  LibFunc>Gdi32,StretchBlt,SBres,HDC2,0,0,WinX,WinY,HDC1,0,0,520,180,13369376
  LibFunc>Kernel32,Sleep,Sres,1
Goto>Loop

SRT>Quit
  LibFunc>user32,ReleaseDC,RDCres1,HDC1_1,HDC1
  LibFunc>user32,ReleaseDC,RDCres1,HDC2_1,HDC2
  LibFunc>GDI32,DeleteObject,DOres,LIres
  Exit>0
END>Quit
*/
Last edited by JRL on Mon May 13, 2013 6:01 pm, edited 1 time in total.

User avatar
Phil Pendlebury
Automation Wizard
Posts: 538
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Post by Phil Pendlebury » Sat May 11, 2013 10:44 am

Haha this is lovely. Nice one Dick. The "Dickital" Clock. :-)
Phil Pendlebury - Linktree

User avatar
CyberCitizen
Automation Wizard
Posts: 721
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

Post by CyberCitizen » Mon May 13, 2013 8:51 am

Thanks for the sample.

Code: Select all

If>WhatToDo=msched.exe
  ExecuteFile>%temp_dir%Clock_Reflection.scp
Gets stuck here for me as I don't have MS installed by default (made portable) therefore it opens in notepad.

Compiling it though works fine.

I did have the PM show as 0M? I have my system to display time in 24hr (18:21).

Not sure if that makes a difference, but really a great example of the power of MS.

Image
FIREFIGHTER

User avatar
JRL
Automation Wizard
Posts: 3501
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Mon May 13, 2013 1:55 pm

@Phil
Glad you like it :)

@Cy
Seeing as it was your idea to make a clock I feel bad that its not working for you.

For the ExecuteFile> problem, I've never set up a portable Macro Scheduler so I can't test to see what the problem might be. Seems to me that the executing file has to be msched.exe and the executed file was placed in the %temp_dir% and named Clock_Reflection.scp. Is it possible that you don't have a temp directory if you have a portable set up? Or is the "Command_Line" variable not "Path\msched.exe"? What do you see if you run the single line:?

MDL>Command_Line

For the "0" displaying rather than the "A" or "P" I wonder if it is your system settings. What do you see from:?

GetTime>now
MDL>now

I'll rewite to remove system settings possibly interfering.

OK...
I've rewritten the script to use the Macro Scheduler Hour> function which is always in a 24 hour format. If hour is less than 12 we are in the am if the hour is greater than 11 we are in the pm. If the hour is greater than 12 we subtract 12 from it giving us a 12 hour clock.

User avatar
CyberCitizen
Automation Wizard
Posts: 721
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

Post by CyberCitizen » Mon May 13, 2013 11:59 pm

JRL wrote:Seeing as it was your idea to make a clock I feel bad that its not working for you.

For the ExecuteFile> problem, I've never set up a portable Macro Scheduler so I can't test to see what the problem might be. Seems to me that the executing file has to be msched.exe and the executed file was placed in the %temp_dir% and named Clock_Reflection.scp. Is it possible that you don't have a temp directory if you have a portable set up? Or is the "Command_Line" variable not "Path\msched.exe"? What do you see if you run the single line:?

MDL>Command_Line
Hi JRL,

No that is fine, I suspected this was the case when I made it portable. I have only made the MS stuff portable / virtualised, however left all the other folders & registry entries open so that MS can interact with the system & not the virtual system. This is the reason it couldn't find the MS.exe to execute the scp file as they are not registered as a file type on the local system (virtualised).
JRL wrote: For the "0" displaying rather than the "A" or "P" I wonder if it is your system settings. What do you see from:?

GetTime>now
MDL>now

I'll rewite to remove system settings possibly interfering.

OK...
I've rewritten the script to use the Macro Scheduler Hour> function which is always in a 24 hour format. If hour is less than 12 we are in the am if the hour is greater than 11 we are in the pm. If the hour is greater than 12 we subtract 12 from it giving us a 12 hour clock.
I would say its due to the fact that I have my time set in 24hrs. Now that you have used the Hour function, that should resolve the issues. I tend to use hour for most of my scripts as it provides a more across the platform workable script, less chance of running into a system time setting being different. Thanks for all the hard work.
FIREFIGHTER

User avatar
JRL
Automation Wizard
Posts: 3501
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Tue Jun 04, 2013 9:49 pm

Here's a simple analog clock.

Code: Select all

OnEvent>key_down,VK27,0,Quit

Dialog>Dialog1
object Dialog1: TForm
  Left = 411
  Top = 295
  HelpContext = 5000
  BorderIcons = [biSystemMenu, biMinimize]
  Caption = 'Analog'
  ClientHeight = 300
  ClientWidth = 300
  Color = clWhite
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  Position = poScreenCenter
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 96
  TextHeight = 13
  object Panel1: TPanel
    Left = 0
    Top = 0
    Width = 300
    Height = 300
    BevelOuter = bvNone
    Caption = 'Panel1'
    Color = clWhite
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWhite
    Font.Height = -11
    Font.Name = 'MS Sans Serif'
    Font.Style = []
    ParentFont = False
    TabOrder = 0
  object Label1: TLabel
    Left = 216
    Top = 18
    Width = 12
    Height = 24
    Caption = '1'
    Font.Charset = ANSI_CHARSET
    Font.Color = clWindowText
    Font.Height = -31
    Font.Name = 'Arial'
    Font.Style = [fsBold]
    ParentFont = False
  end
  object Label2: TLabel
    Left = 262
    Top = 66
    Width = 12
    Height = 24
    Caption = '2'
    Font.Charset = ANSI_CHARSET
    Font.Color = clWindowText
    Font.Height = -31
    Font.Name = 'Arial'
    Font.Style = [fsBold]
    ParentFont = False
  end
  object Label3: TLabel
    Left = 280
    Top = 134
    Width = 12
    Height = 24
    Caption = '3'
    Font.Charset = ANSI_CHARSET
    Font.Color = clWindowText
    Font.Height = -31
    Font.Name = 'Arial'
    Font.Style = [fsBold]
    ParentFont = False
  end
  object Label4: TLabel
    Left = 262
    Top = 198
    Width = 12
    Height = 24
    Caption = '4'
    Font.Charset = ANSI_CHARSET
    Font.Color = clWindowText
    Font.Height = -31
    Font.Name = 'Arial'
    Font.Style = [fsBold]
    ParentFont = False
  end
  object Label5: TLabel
    Left = 216
    Top = 246
    Width = 12
    Height = 24
    Caption = '5'
    Font.Charset = ANSI_CHARSET
    Font.Color = clWindowText
    Font.Height = -31
    Font.Name = 'Arial'
    Font.Style = [fsBold]
    ParentFont = False
  end
  object Label6: TLabel
    Left = 142
    Top = 270
    Width = 12
    Height = 24
    Caption = '6'
    Font.Charset = ANSI_CHARSET
    Font.Color = clWindowText
    Font.Height = -31
    Font.Name = 'Arial'
    Font.Style = [fsBold]
    ParentFont = False
  end
  object Label7: TLabel
    Left = 72
    Top = 246
    Width = 12
    Height = 24
    Caption = '7'
    Font.Charset = ANSI_CHARSET
    Font.Color = clWindowText
    Font.Height = -31
    Font.Name = 'Arial'
    Font.Style = [fsBold]
    ParentFont = False
  end
  object Label8: TLabel
    Left = 24
    Top = 198
    Width = 12
    Height = 24
    Caption = '8'
    Font.Charset = ANSI_CHARSET
    Font.Color = clWindowText
    Font.Height = -31
    Font.Name = 'Arial'
    Font.Style = [fsBold]
    ParentFont = False
  end
  object Label9: TLabel
    Left = 8
    Top = 134
    Width = 12
    Height = 24
    Caption = '9'
    Font.Charset = ANSI_CHARSET
    Font.Color = clWindowText
    Font.Height = -31
    Font.Name = 'Arial'
    Font.Style = [fsBold]
    ParentFont = False
  end
  object Label10: TLabel
    Left = 16
    Top = 70
    Width = 24
    Height = 24
    Caption = '10'
    Font.Charset = ANSI_CHARSET
    Font.Color = clWindowText
    Font.Height = -31
    Font.Name = 'Arial'
    Font.Style = [fsBold]
    ParentFont = False
  end
  object Label11: TLabel
    Left = 72
    Top = 18
    Width = 24
    Height = 24
    Caption = '11'
    Font.Charset = ANSI_CHARSET
    Font.Color = clWindowText
    Font.Height = -31
    Font.Name = 'Arial'
    Font.Style = [fsBold]
    ParentFont = False
  end
  object Label12: TLabel
    Left = 135
    Top = 0
    Width = 24
    Height = 24
    Caption = '12'
    Font.Charset = ANSI_CHARSET
    Font.Color = clWindowText
    Font.Height = -31
    Font.Name = 'Arial'
    Font.Style = [fsBold]
    ParentFont = False
  end
  end
end
EndDialog>Dialog1

AddDialogHandler>Dialog1,,OnClose,Quit

Show>Dialog1

Sec>FirstTime

Label>Loop
  Sec>SecondTime
  If>FirstTime=SecondTime
  Else
    Let>FirstTime=SecondTime
    Let>SecDir={(%SecondTime%*6)+(90*-1)}
    SetDialogProperty>Dialog1,Panel1,Caption,SecDir
    GoSub>Angle,Dialog1,Panel1,SecDir,150,150,120,1,255
  Min>ThisMinute
    Let>MinDir={(%ThisMinute%*6)+(90*-1)+((%SecondTime%/60)*6)}
    GoSub>Angle,Dialog1,Panel1,MinDir,150,150,110,5,0
  Hour>HourTime
  If>HourTime>11
    Sub>HourTime,12
  EndIf
    Let>HourDir={(%HourTime%*30)+(90*-1)+((%ThisMinute%/60)*30)}
    GoSub>Angle,Dialog1,Panel1,HourDir,150,150,70,5,0
  EndIf
Goto>Loop

SRT>Quit
  Exit>0
END>Quit

//Angle Usage:
//GoSub>Angle,Dialog,Object,Angle(in degrees),XStart,YStart,Length,PenSize,PenColor
SRT>Angle
  Let>DegreeAngle=Angle_var_3
  Let>XStart=Angle_var_4
  Let>Ystart=Angle_var_5
  Let>LineLength=Angle_var_6
  Let>RadAngle={%DegreeAngle%*(pi/180)}
  Let>XEnd={trunc((cos(%RadAngle%))*%LineLength%)}
  Let>YEnd={trunc((sin(%RadAngle%))*%LineLength%)}
  Let>XEnd=%XEnd%+%XStart%
  Let>YEnd=%YEnd%+%YStart%
  GoSub>DrawLine,%Angle_var_1%.%Angle_var_2%.Handle,Angle_var_7,Angle_var_8,XStart,YStart,XEnd,YEnd
END>Angle


//DrawLine Usage:
//GoSub>DrawLine,WindowHandle,PenSize,PenColor,XStart,YStart,XEnd,YEnd
SRT>DrawLine
  LibFunc>user32,GetDC,HDC,%DrawLine_var_1%
  LibFunc>gdi32,CreatePen,Penres,0,%DrawLine_var_2%,%DrawLine_var_3%
  LibFunc>gdi32,SelectObject,SOPres,hdc,Penres
  Libfunc>gdi32,MoveToEx,mtres,HDC,%DrawLine_var_4%,%DrawLine_var_5%,0
  LibFunc>gdi32,LineTo,ltres,hdc,%DrawLine_var_6%,%DrawLine_var_7%
  LibFunc>gdi32,DeleteObject,DOres,Penres
  LibFunc>user32,ReleaseDC,RDCres,HDC_1,HDC
END>DrawLine





User avatar
JRL
Automation Wizard
Posts: 3501
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Mon Jun 24, 2013 5:36 pm

Here is a clock with a few more features.

Start this and after a couple of screen gyrations a clock should appear in the middle of your screen. Double click on the clock and a menu will appear giving you the options to Minimize, Resize, Move, Stay-On_Top, Close the Clock or Close This Menu.

If you pick Minimize the clock will minimize to the taskbar

If you pick Resize the screen will go semi white. At this time you can draw a circle on the screen by picking a point and dragging to make the circle any size you like. When you release the mouse the screen will return to normal and the clock will fill the circle you just drew.

If you pick Move you will be able to click on the clock and drag it to a new location on the screen. When you release the mouse the clock will reside in the location to which you dragged it.

If you pick Stay-On-Top the clock will remain visible over the top of most other windows. See the remarks in the script if you intend to compile this.

If you pick Close the Clock the program will end saving your current size and location settings.

If you pick Close This Menu the menu will close without making any changes to the clock.

Code: Select all

StringReplace>Command_Line,",,Command_Line
ExtractFileName>Command_Line,strFileName
ExtractFileExt>Command_Line,strFileExt
StringReplace>strFileName,strFileExt,,strFileName
Trim>strFileName,strFileName
Let>APP_TITLE=%strFileName%

Dialog>Dialog1
object Dialog1: TForm
  Left = 534
  Top = 289
  AlphaBlend = True
  AlphaBlendValue = 255
  BorderStyle = bsNone
  HelpContext = 5000
  Caption = 'Analog'
  ClientHeight = 400
  ClientWidth = 400
  Color = 3
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  Position = poScreenCenter
  ShowHint = True
  PixelsPerInch = 96
  TextHeight = 13
  object Panel1: TPanel
    Left = 0
    Top = 0
    Width = 400
    Height = 400
    BevelOuter = bvNone
    Caption = 'o'
    Color = clWhite
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWhite
    Font.Height = -5
    Font.Name = 'MS Sans Serif'
    Font.Style = []
    ParentFont = False
    TabOrder = 0
    object Label1: TLabel
      Left = 257
      Top = 68
      Width = 17
      Height = 36
      Caption = '1'
      Font.Charset = ANSI_CHARSET
      Font.Color = clWindowText
      Font.Height = -31
      Font.Name = 'Arial'
      Font.Style = [fsBold]
      ParentFont = False
    end
    object Label2: TLabel
      Left = 306
      Top = 116
      Width = 17
      Height = 36
      Caption = '2'
      Font.Charset = ANSI_CHARSET
      Font.Color = clWindowText
      Font.Height = -31
      Font.Name = 'Arial'
      Font.Style = [fsBold]
      ParentFont = False
    end
    object Label3: TLabel
      Left = 324
      Top = 182
      Width = 17
      Height = 36
      Caption = '3'
      Font.Charset = ANSI_CHARSET
      Font.Color = clWindowText
      Font.Height = -31
      Font.Name = 'Arial'
      Font.Style = [fsBold]
      ParentFont = False
    end
    object Label4: TLabel
      Left = 306
      Top = 248
      Width = 17
      Height = 36
      Caption = '4'
      Font.Charset = ANSI_CHARSET
      Font.Color = clWindowText
      Font.Height = -31
      Font.Name = 'Arial'
      Font.Style = [fsBold]
      ParentFont = False
    end
    object Label5: TLabel
      Left = 260
      Top = 296
      Width = 17
      Height = 36
      Caption = '5'
      Font.Charset = ANSI_CHARSET
      Font.Color = clWindowText
      Font.Height = -31
      Font.Name = 'Arial'
      Font.Style = [fsBold]
      ParentFont = False
    end
    object Label6: TLabel
      Left = 192
      Top = 316
      Width = 17
      Height = 36
      Caption = '6'
      Font.Charset = ANSI_CHARSET
      Font.Color = clWindowText
      Font.Height = -31
      Font.Name = 'Arial'
      Font.Style = [fsBold]
      ParentFont = False
    end
    object Label7: TLabel
      Left = 122
      Top = 296
      Width = 17
      Height = 36
      Caption = '7'
      Font.Charset = ANSI_CHARSET
      Font.Color = clWindowText
      Font.Height = -31
      Font.Name = 'Arial'
      Font.Style = [fsBold]
      ParentFont = False
    end
    object Label8: TLabel
      Left = 78
      Top = 248
      Width = 17
      Height = 36
      Caption = '8'
      Font.Charset = ANSI_CHARSET
      Font.Color = clWindowText
      Font.Height = -31
      Font.Name = 'Arial'
      Font.Style = [fsBold]
      ParentFont = False
    end
    object Label9: TLabel
      Left = 61
      Top = 182
      Width = 17
      Height = 36
      Caption = '9'
      Font.Charset = ANSI_CHARSET
      Font.Color = clWindowText
      Font.Height = -31
      Font.Name = 'Arial'
      Font.Style = [fsBold]
      ParentFont = False
    end
    object Label10: TLabel
      Left = 69
      Top = 120
      Width = 34
      Height = 36
      Caption = '10'
      Font.Charset = ANSI_CHARSET
      Font.Color = clWindowText
      Font.Height = -31
      Font.Name = 'Arial'
      Font.Style = [fsBold]
      ParentFont = False
    end
    object Label11: TLabel
      Left = 119
      Top = 68
      Width = 32
      Height = 36
      Caption = '11'
      Font.Charset = ANSI_CHARSET
      Font.Color = clWindowText
      Font.Height = -31
      Font.Name = 'Arial'
      Font.Style = [fsBold]
      ParentFont = False
    end
    object Label12: TLabel
      Left = 183
      Top = 50
      Width = 34
      Height = 36
      Caption = '12'
      Font.Charset = ANSI_CHARSET
      Font.Color = clWindowText
      Font.Height = -31
      Font.Name = 'Arial'
      Font.Style = [fsBold]
      ParentFont = False
    end
    object MSImage1: tMSImage
      Left = 0
      Top = 0
      Width = 400
      Height = 400
    end
  end
end
EndDialog>Dialog1

Dialog>Dialog2
object Dialog2: TForm
  Position = poScreenCenter
  BorderStyle = bsNone
  BorderIcons = [biSystemMenu, biMinimize]
  TransparentColor = True
  TransparentColorValue = 3
  Caption = 'AnalogClock'
  ClientHeight = 400
  ClientWidth = 400
  Color = 3
  OnTaskBar = True
end
EndDialog>Dialog2

Dialog>Dialog3
object Dialog3: TForm
  AutoSize = True
  AlphaBlend = True
  AlphaBlendValue = 0
  BorderStyle = bsNone
  object Panel1: TPanel
    Left = 0
    Top = 0
    Width = 130
    Height = 25
    Alignment = taLeftJustify
    Caption = 'Minimize'
    TabOrder = 0
  end
  object Panel2: TPanel
    Left = 0
    Top = 25
    Width = 130
    Height = 25
    Alignment = taLeftJustify
    Caption = 'Resize'
    TabOrder = 1
  end
  object Panel3: TPanel
    Left = 0
    Top = 50
    Width = 130
    Height = 25
    Alignment = taLeftJustify
    Caption = 'Move'
    TabOrder = 2
  end
  object Panel4: TPanel
    Left = 0
    Top = 75
    Width = 130
    Height = 25
    Alignment = taLeftJustify
    Caption = 'Stay-on-Top'
    TabOrder = 3
  end
  object Panel5: TPanel
    Left = 0
    Top = 100
    Width = 130
    Height = 25
    Alignment = taLeftJustify
    Caption = 'Close the Clock'
    TabOrder = 3
  end
  object Panel6: TPanel
    Left = 0
    Top = 125
    Width = 130
    Height = 25
    Alignment = taLeftJustify
    Caption = 'Close This Menu'
    TabOrder = 3
  end
  object MSImage1: tMSImage
    Left = 0
    Top = 0
    AutoSize = True
  end
end
EndDialog>Dialog3

Dialog>Dialog4
object Dialog4: TForm
  BorderStyle = bsNone
  FormStyle = fsStayOnTop
  AlphaBlend = True
  AlphaBlendValue = 100
  object Panel1: TPanel
    Left = 0
    Top = 0
    Width = 400
    Height = 400
    BevelOuter = bvNone
    Caption = 'o'
    Color = clWhite
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWhite
    Font.Height = -11
    Font.Name = 'MS Sans Serif'
    Font.Style = []
  end
end
EndDialog>Dialog4

AddDialogHandler>Dialog1,,OnClose,Quit
AddDialogHandler>Dialog2,,OnClose,Quit
AddDialogHandler>Dialog2,,OnDblClick,Ask
AddDialogHandler>Dialog2,,OnMouseDown,MoveTheClock
AddDialogHandler>Dialog2,,OnMouseUp,StopMoveTheClock
AddDialogHandler>Dialog3,Panel1,OnClick,Minimizer
AddDialogHandler>Dialog3,Panel2,OnClick,ReSizeClock
AddDialogHandler>Dialog3,Panel3,OnClick,MoveClock
AddDialogHandler>Dialog3,Panel4,OnClick,OnTopClock
AddDialogHandler>Dialog3,Panel5,OnClick,CloseClock
AddDialogHandler>Dialog3,Panel6,OnClick,CloseMenu
AddDialogHandler>Dialog4,Panel1,OnMouseDown,DrawResizeCircle
AddDialogHandler>Dialog4,Panel1,OnMouseUp,StopDrawResizeCircle
SetDialogProperty>Dialog2,,Caption,APP_TITLE
Let>ClockResizeFlag=0
Let>ClockMoveFlag=0
Let>AskFlag=0
Let>StayOnTopFlag=0
Let>rednum=0
Let>greennum=0
Let>bluenum=0
Random>2,Direction

LibFunc>user32,GetDC,HDC1,%Dialog1.handle%
LibFunc>user32,GetDC,HDC2,%Dialog2.handle%
LibFunc>Gdi32,SetStretchBltMode,SSBMres,HDC2,4
LibFunc>Gdi32,SetBrushOrgEx,SBOEres,HDC2,0,0,

IfFileExists>%temp_dir%ClockFace.bmp
  SetDialogProperty>Dialog1,,AlphaBlendValue,0
  Show>Dialog1
Else
  Show>Dialog1
  Let>TickAngle=-96
  Let>TickCount=0
  Repeat>TickCount
    Add>TickCount,1
    Add>TickAngle,6
    GoSub>Tick,Dialog1,Panel1,TickAngle,200,200,110,1,0
  Until>TickCount=60
  GoSub>DrawArc,Dialog1.Panel1.Handle,10,0,196,196,204,204,196,196,196,196
  GetWindowSize>Analog,WinsizeW,WinSizeH
  GetWindowPos>Analog,WinposX,WinposY
  Let>resx=%WinSizeW%-400
  Let>resy=%WinSizeH%-400
  Let>vBorder=%Resx%/2
  Let>Titlebar={%WinSizeH%-%vBorder%-400}
  Let>TLX=%WinposX%+%vBorder%
  Let>TLY=%WinposY%+%titlebar%
  Let>BRX=%TLX%+400
  Let>BRY=%TLY%+400
  Wait>1
  ScreenCapture>TLX,TLY,BRX,BRY,%temp_dir%ClockFace.bmp
EndIf
SetDialogProperty>Dialog1,MSImage1,LoadImage,%temp_dir%ClockFace.bmp
SetDialogProperty>Dialog1,,AlphaBlendValue,0

Show>Dialog2

IfFileExists>%temp_dir%JRLClockSettings.ini
  ReadIniFile>%temp_dir%JRLClockSettings.ini,Settings,Xposition,D2WinX
  ReadIniFile>%temp_dir%JRLClockSettings.ini,Settings,Yposition,D2WinY
  ReadIniFile>%temp_dir%JRLClockSettings.ini,Settings,Width,D2WinW
  ReadIniFile>%temp_dir%JRLClockSettings.ini,Settings,Height,D2WinH
  Let>WIN_USEHANDLE=1
    MoveWindow>Dialog2.Handle,D2WinX,D2WinY
    ResizeWindow>Dialog2.Handle,D2WinW,D2WinH
  Let>WIN_USEHANDLE=0
EndIf

Dialog>TitleBarSizeCalculation
Button=1,0,0,0,0,0
EndDialog>TitleBarSizeCalculation
Let>WIN_USEHANDLE=1
MoveWindow>TitleBarSizeCalculation.handle,0,0
GetWindowPos>TitleBarSizeCalculation.msButton1.handle,OffSetX,OffSetY
Let>WIN_USEHANDLE=0

Sec>FirstTime

//////////////////  Start Process Loop  //////////////////
Label>Loop
  Sec>SecondTime
  If>FirstTime=SecondTime
  Else
    GoSub>SetColor
    Let>FirstTime=SecondTime
    Let>SecDir={(%SecondTime%*6)+(90*-1)}
    SetDialogProperty>Dialog1,Panel1,Caption,SecDir
    GoSub>Angle,Dialog1,Panel1,SecDir,200,200,120,2,255
    Min>ThisMinute
    Let>MinDir={(%ThisMinute%*6)+(90*-1)+((%SecondTime%/60)*6)}
    GoSub>Angle,Dialog1,Panel1,MinDir,200,200,110,5,0
    Hour>HourTime
    If>HourTime>11
      Sub>HourTime,12
    EndIf
    Let>HourDir={(%HourTime%*30)+(90*-1)+((%ThisMinute%/60)*30)}
    GoSub>Angle,Dialog1,Panel1,HourDir,200,200,70,5,0
  EndIf
  GoSub>DrawArc,Dialog1.Panel1.Handle,5,255,196,196,204,204,196,196,196,196
  GoSub>DrawArc,Dialog1.Panel1.Handle,160,3,-30,-30,430,430,-30,-30,-30,-30
  If>NewColor={"NewColor"}
    Let>newcolor=0
  EndIf
  GoSub>DrawArc,Dialog1.Panel1.Handle,20,newcolor,40,40,360,360,40,40,40,40
  GoSub>Reflect
  Wait>0.01
Goto>Loop
//////////////////  End Process Loop  //////////////////

//////////////////  Start JRL's Draw Function Subs  //////////////////
//Angle Usage:
//GoSub>Angle,Dialog,Object,Angle(in degrees),XStart,YStart,Length,PenSize,PenColor
//Requires Drawline subroutine
SRT>Angle
  Let>DegreeAngle=Angle_var_3
  Let>XStart=Angle_var_4
  Let>Ystart=Angle_var_5
  Let>LineLength=Angle_var_6
  Let>RadAngle={%DegreeAngle%*(pi/180)}
  Let>XEnd={trunc((cos(%RadAngle%))*%LineLength%)}
  Let>YEnd={trunc((sin(%RadAngle%))*%LineLength%)}
  Let>XEnd=%XEnd%+%XStart%
  Let>YEnd=%YEnd%+%YStart%
  GoSub>DrawLine,%Angle_var_1%.%Angle_var_2%.Handle,Angle_var_7,Angle_var_8,XStart,YStart,XEnd,YEnd
END>Angle

//DrawLine Usage:
//GoSub>DrawLine,WindowHandle,PenSize,PenColor,XStart,YStart,XEnd,YEnd
SRT>DrawLine
  LibFunc>user32,GetDC,HDC,%DrawLine_var_1%
  LibFunc>gdi32,CreatePen,Penres,0,%DrawLine_var_2%,%DrawLine_var_3%
  LibFunc>gdi32,SelectObject,SOPres,hdc,Penres
  Libfunc>gdi32,MoveToEx,mtres,HDC,%DrawLine_var_4%,%DrawLine_var_5%,0
  LibFunc>gdi32,LineTo,ltres,hdc,%DrawLine_var_6%,%DrawLine_var_7%
  LibFunc>gdi32,DeleteObject,DOres,Penres
  LibFunc>user32,ReleaseDC,RDCres,HDC_1,HDC
END>DrawLine

//DrawArc Usage:
//GoSub>DrawArc,WindowHandle,PenSize,PenColor,ULXLoc,ULYLoc,LRXLoc,LRYLoc,SXLoc,SYLoc,EXLoc,EYLoc
SRT>DrawArc
  LibFunc>user32,GetDC,HDC,%DrawArc_var_1%
  LibFunc>gdi32,CreatePen,Penres,0,%DrawArc_var_2%,%DrawArc_var_3%
  LibFunc>gdi32,SelectObject,SOPres,hdc,Penres
  Libfunc>gdi32,Arc,ARCres,HDC,%DrawArc_var_4%,%DrawArc_var_5%,%DrawArc_var_6%,%DrawArc_var_7%,%DrawArc_var_8%,%DrawArc_var_9%,%DrawArc_var_10%,%DrawArc_var_11%
  LibFunc>gdi32,DeleteObject,DOres,Penres
  LibFunc>user32,ReleaseDC,RDCres,HDC_1,HDC
END>DrawArc
//////////////////  End JRL's Draw Function Subs  //////////////////

//////////////////  Start Draw Clock Minute Tick Marks Sub  //////////////////
SRT>Tick
  Let>DegreeAngle=Tick_var_3
  Let>XStart=Tick_var_4
  Let>Ystart=Tick_var_5
  Let>LineLength=Tick_var_6
  Let>RadAngle={%DegreeAngle%*(pi/180)}
  Let>XEnd={trunc((cos(%RadAngle%))*%LineLength%)}
  Let>YEnd={trunc((sin(%RadAngle%))*%LineLength%)}
  Let>XEnd=%XEnd%+%XStart%
  Let>YEnd=%YEnd%+%YStart%
  Let>AngleTest={%Tick_var_3% mod 5}
  If>AngleTest=0
    Let>Tick_var_7=%Tick_var_7%*4
    Let>LineLength=%LineLength%-15
  Else
    Let>LineLength=%LineLength%-5
  EndIf
  Let>XNew={trunc((cos(%RadAngle%))*%LineLength%)}
  Let>YNew={trunc((sin(%RadAngle%))*%LineLength%)}
  Let>XNew=%XNew%+%XStart%
  Let>YNew=%YNew%+%YStart%
  GoSub>DrawLine,%Tick_var_1%.%Tick_var_2%.Handle,Tick_var_7,Tick_var_8,XNew,YNew,XEnd,YEnd
END>Tick
//////////////////  End Draw Clock Minute Tick Marks Sub  //////////////////

//////////////////  Start Draw Clock Outside Frame Sub  //////////////////
SRT>SetColor
  Random>3,Hue
  Random>5,step
  If>{(%rednum%<%step%)or(%greennum%<%step%)or(%bluenum%<%step%)}
    Let>Direction=1
  EndIf
  If>{(%rednum%>(255-%step%))or(%greennum%>(255-%step%))or(%bluenum%>(255-%step%))}
    Let>Direction=0
  EndIf
  If>Direction=1
    If>{(%Hue%=2) and (%rednum%<(255-%step%))}
      Let>rednum=%rednum%+%step%
    EndIf
    If>{(%Hue%=1) and (%greennum%<(255-%step%))}
      Let>greennum=%greennum%+%step%
    EndIf
    If>{(%Hue%=0) and (%bluenum%<(255-%step%))}
      Let>bluenum=%bluenum%+%step%
    EndIf
  Else
    If>{(%Hue%=2) and (%rednum%>(0+%step%))}
      Let>rednum=%rednum%-%step%
    EndIf
    If>{(%Hue%=1) and (%greennum%>(0+%step%))}
      Let>greennum=%greennum%-%step%
    EndIf
    If>{(%Hue%=0) and (%bluenum%>(0+%step%))}
      Let>bluenum=%bluenum%-%step%
    EndIf
  EndIf
  RGB>rednum,greennum,bluenum,newcolor
END>SetColor
//////////////////  End Draw Clock Outside Frame Sub  //////////////////

//////////////////  Start Clock Projection Sub  //////////////////
SRT>Reflect
  Let>WIN_USEHANDLE=1
    GetWindowSize>%Dialog2.handle%,WinX,WinY
    GetWindowSize>%Dialog1.handle%,Win1X,Win1Y
  Let>WIN_USEHANDLE=0
  Add>Win1X,%OffSetX%
  Add>Win1Y,%OffSetY%
  LibFunc>Gdi32,StretchBlt,SBres,HDC2,0,0,WinX,WinY,HDC1,0,0,400,400,13369376
END>Reflect
//////////////////  End Clock Projection Sub  //////////////////

//////////////////  Start Clock Menu Sub  //////////////////
SRT>Ask
  If>ClockMoveFlag=0
    Let>AskFlag=1
    GetCursorPos>CurX,CurY
    Let>WIN_USEHANDLE=1
      MoveWindow>Dialog3.Handle,CurX,CurY
    Let>WIN_USEHANDLE=0
    SetDialogProperty>Dialog2,,FormStyle,fsNormal
    Show>Dialog3
    SetDialogProperty>Dialog3,,AlphaBlendValue,255
  EndIf
END>Ask
//////////////////  End Clock Menu Sub  //////////////////

//////////////////  Start Clock Minimize Sub  //////////////////
SRT>Minimizer
  CloseDialog>Dialog3
  Let>WIN_USEHANDLE=1
    WindowAction>2,Dialog2.handle
  Let>WIN_USEHANDLE=0
END>Minimizer
//////////////////  End Clock Minimize Sub  //////////////////

//////////////////  Start Clock Resize Subs  //////////////////
SRT>ReSizeClock
  CloseDialog>Dialog3
  LibFunc>User32,GetSystemMetrics,VScrWidth,78
  LibFunc>User32,GetSystemMetrics,VScrHeight,79
  LibFunc>User32,GetSystemMetrics,VScrLeft,76
  LibFunc>User32,GetSystemMetrics,VScrTop,77
  Let>WIN_USEHANDLE=1
    ReSizeWindow>Dialog4.handle,VScrWidth,VScrHeight
    MoveWindow>Dialog4.handle,VScrLeft,VScrTop
    ReSizeWindow>Dialog4.Panel1.handle,VScrWidth,VScrHeight
    MoveWindow>Dialog4.Panel1.handle,VScrLeft,VScrTop
  Let>WIN_USEHANDLE=0
  Show>Dialog4
END>ReSizeClock

SRT>DrawResizeCircle
  Let>ClockResizeFlag=0
  GetCursorPos>CurX,CurY
  Label>RunResizeLoop
  If>ClockResizeFlag=0
    GetCursorPos>NextX,NextY
    Let>RadiusX={abs(%CurX%-%NextX%)}
    Let>RadiusY={abs(%CurY%-%NextY%)}
    Let>Radius={round(sqrt((sqr(%RadiusX%))+(sqr(%RadiusY%))))}
    SetDialogProperty>Dialog4,Label1,Caption,Radius
    Let>ULXLoc=%CurX%-%Radius%
    Let>ULYLoc=%CurY%-%Radius%
    Let>LRXLoc=%CurX%+%Radius%
    Let>LRYLoc=%CurY%+%Radius%
    SetDialogProperty>Dialog4,Panel1,Caption,Radius
    GoSub>DrawArc,Dialog4.Panel1.Handle,3,0,ULXLoc,ULYLoc,LRXLoc,LRYLoc,ULXLoc,ULYLoc,ULXLoc,ULYLoc
    Goto>RunResizeLoop
  EndIf
  CloseDialog>Dialog4
  Let>BoxSize={round(%radius%*400/170)}
  Let>WIN_USEHANDLE=1
    GetWindowPos>%Dialog2.handle%,d2WinX,d2WinY
    ResizeWindow>%Dialog2.handle%,BoxSize,BoxSize
  Let>WIN_USEHANDLE=0
  GoSub>Reflect
  Let>d2WinX={round(%CurX%-(200*(%radius%/170)))}
  Let>d2WinY={round(%CurY%-(200*(%radius%/170)))}
  Let>WIN_USEHANDLE=1
    MoveWindow>%Dialog2.handle%,d2WinX,d2WinY
  Let>WIN_USEHANDLE=0
  Let>ClockResizeFlag=0
  GoSub>ResetStayOnTop
END>DrawResizeCircle

SRT>StopDrawResizeCircle
  Let>ClockResizeFlag=1
END>StopDrawResizeCircle
//////////////////  End Clock Resize Subs  //////////////////

//////////////////  Start Clock Move Subs  //////////////////
SRT>MoveClock
  Wait>0.01
  CloseDialog>Dialog3
  If>AskFlag=1
    Let>ClockMoveFlag=1
    Let>AskFlag=0
  EndIf
END>MoveClock

SRT>MoveTheClock
  GetCursorPos>CurX,CurY
  Let>WIN_USEHANDLE=1
    GetWindowPos>Dialog2.handle,D2WinX,D2WinY
  Let>WIN_USEHANDLE=0
  Let>DiffWinX=%CurX%-%D2WinX%
  Let>DiffWinY=%CurY%-%D2WinY%
  Label>MoveClockMore
  If>ClockMoveFlag=1
    GetCursorPos>CurX,CurY
    Let>D2WinX=%CurX%-%DiffWinX%
    Let>D2WinY=%CurY%-%DiffWinY%
    Let>WIN_USEHANDLE=1
      MoveWindow>Dialog2.handle,D2WinX,D2WinY
    Let>WIN_USEHANDLE=0
    Goto>MoveClockMore
  Else
  EndIf
END>MoveTheClock

SRT>StopMoveTheClock
  If>AskFlag=0
    Let>ClockMoveFlag=0
    GoSub>ResetStayOnTop
  EndIf
END>StopMoveTheClock
//////////////////  End Clock Move Subs  //////////////////

//////////////////  Start StayOnTop Subs  //////////////////
SRT>OnTopClock
  CloseDialog>Dialog3
  If>StayOnTopFlag=0
    Let>StayOnTopFlag=1
    SetDialogProperty>Dialog3,Panel4,Caption,Remove From Top Z
    SetDialogProperty>Dialog2,,FormStyle,fsStayOnTop
  Else
    Let>StayOnTopFlag=0
    SetDialogProperty>Dialog3,Panel4,Caption,Stay-on-Top
    SetDialogProperty>Dialog2,,FormStyle,fsNormal
  EndIf
END>OnTopClock

SRT>ResetStayOnTop
  If>StayOnTopFlag=1
    SetDialogProperty>Dialog2,,FormStyle,fsStayOnTop
  Else
    SetDialogProperty>Dialog2,,FormStyle,fsNormal
  EndIf
END>ResetStayOnTop
//////////////////  End StayOnTop Subs  //////////////////

SRT>CloseClock
  CloseDialog>Dialog2
END>CloseClock

SRT>CloseMenu
  CloseDialog>Dialog3
  GoSub>ResetStayOnTop
END>CloseMenu

SRT>Quit
  Let>WIN_USEHANDLE=1
    GetWindowPos>Dialog2.Handle,D2WinX,D2WinY
    GetWindowSize>Dialog2.Handle,D2WinW,D2WinH
  Let>WIN_USEHANDLE=0
  LibFunc>user32,ReleaseDC,RDCres1,HDC1_1,HDC1
  LibFunc>user32,ReleaseDC,RDCres1,HDC2_1,HDC2
  LibFunc>GDI32,DeleteObject,DOres,LIres
  IfFileExists>%temp_dir%JRLClockSettings.ini
  Else
    WriteLn>%temp_dir%JRLClockSettings.ini,wres,
  EndIf
  EditIniFile>%temp_dir%JRLClockSettings.ini,Settings,Xposition,D2WinX
  EditIniFile>%temp_dir%JRLClockSettings.ini,Settings,Yposition,D2WinY
  EditIniFile>%temp_dir%JRLClockSettings.ini,Settings,Width,D2WinW
  EditIniFile>%temp_dir%JRLClockSettings.ini,Settings,Height,D2WinH
  Exit>0
END>Quit


User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Tue Jun 25, 2013 11:54 am

Another cool toy... thanks for sharing. :)

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts