Jump to content

Recommended Posts

Posted

Hi guys again in this script is set to popup something every 30 secs as you can see :

$warn_intrvl = 30, $display_time

How to make it pop up every 2 hours ? i put 7200 but nothing happen after 2 hours.

local $target_date = '2013/01/01 00:00:00'
local $hrs, $mins, $secs, $days=0, $diff, $warn = 24*60*60, $warn_intrvl = 30, $display_time

Thank you.

Posted

Can you post the whole code so we can see what your script does (or doesn't)?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted (edited)

Yes water of course here it is and is made by Kylomas

#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <date.au3>
local $target_date = '2013/01/01 00:00:00'
local $hrs, $mins, $secs, $days=0, $diff, $warn = 24*60*60, $warn_intrvl = 30, $display_time

local $gui010 = guicreate('',@DesktopWidth,20,(@desktopwidth)/2,20,$ws_popup,bitor($ws_ex_layered,$ws_ex_topmost))
GUISetBkColor(0xABCDEF)
local $lbl010 = guictrlcreatelabel('',0,0,600,20)
guictrlsetfont(-1,10,800,-1,'lucinda console')
_WinAPI_SetLayeredWindowAttributes($gui010, 0xABCDEF, 250)
guisetstate()

adlibregister('_update',1000)

while guigetmsg() <> $gui_event_close

wend

func _update()

$diff = _datediff('s',_NowCalc(),$target_date)

; calculations made from UEZ

Local $secs = Mod($diff, 60)
Local $mins = Mod(Int($diff / 60), 60)
Local $hrs = Int($diff / 60 ^ 2)
If $hrs > 23 Then
$days = Floor($hrs/ 24)
$hrs -= $days * 24
endif

local $diff_out = stringformat('%02i Days %02i Hours %02i Minutes %02i Seconds to ' & stringleft($target_date,stringinstr($target_date,' ')), $days, $hrs, $mins, $secs)
guictrlsetdata($lbl010,$diff_out)
$warn -= 1
if mod($warn,$warn_intrvl) = 0 then
traytip('',$warn_intrvl & ' seconds have passed' & @lf & $diff_out,5)
$display_time = 1
endif
if $display_time = 10 then
traytip('','',0)
$display_time = 0
endif
if $display_time then $display_time += 1

endfunc
Edited by noobish
Posted

Why do you set "$warn -= 1" in your code? It overwrites "$warn = 24*60*60"

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted (edited)

@water the $warn -= 1 is correct. It decrements a counter that the modulo arithmetic is dependent upon.

@noobish - I think this is a timing problem. I am running the adlib every second so it might have crossed the 1 second boundry and caused the mod function to never return '0'. Changed the adlib to run every 1/2 second and added some consolewrite messages.

I also expanded the total time interval to one year and and set the warn interval to 2 hours.

If you did NOT change anything then why would you expect it to warn after 2 hours? Regardless, this made me aware of the possible timing issue.

#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <date.au3>

local $target_date  = '2013/01/01 00:00:00'
local $hrs, $mins, $secs, $days=0, $diff, $warn = 365*24*60*60, $warn_intrvl = 2 * 60 * 60, $display_time
ConsoleWrite($warn & ' ' & $warn_intrvl & @LF)

local $gui010   =   guicreate('',@DesktopWidth,20,(@desktopwidth)/2,20,$ws_popup,bitor($ws_ex_layered,$ws_ex_topmost))
                    GUISetBkColor(0xABCDEF)
local $lbl010   =   guictrlcreatelabel('',0,0,600,20)
                    guictrlsetfont(-1,10,800,-1,'lucinda console')
                    _WinAPI_SetLayeredWindowAttributes($gui010, 0xABCDEF, 250)
                    guisetstate()

adlibregister('_update',500)

while guigetmsg() <> $gui_event_close

wend

func _update()

    $diff = _datediff('s',_NowCalc(),$target_date)

    ; calcs from UEZ

    Local $secs = Mod($diff, 60)
    Local $mins = Mod(Int($diff / 60), 60)
    Local $hrs  = Int($diff / 60 ^ 2)
    If $hrs > 23 Then
        $days = Floor($hrs/ 24)
        $hrs -= $days * 24
    endif

    local $diff_out = stringformat('%02i Days %02i Hours %02i Minutes %02i Seconds to ' & stringleft($target_date,stringinstr($target_date,' ')), $days, $hrs, $mins, $secs)
    guictrlsetdata($lbl010,$diff_out)
    $warn -= 1
    if mod($warn,$warn_intrvl) = 0 then
        traytip('',$warn_intrvl & ' seconds have passed' & @lf & $diff_out,5)
        ConsoleWrite('Displaying traytip at ' & $diff_out & @LF)
        $display_time = 1
    endif
    if  $display_time = 10 then
        traytip('','',0)
        $display_time = 0
    endif
    if $display_time then $display_time += 1

endfunc

kylomas

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Posted

noobish,

This is one way to do this, search the forum for other alternatives, including UEZ's code from the OP.

Good Luck,

kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Posted

@Kylomas

Thank you a lot you UEZ and all other guys that helped me.

It works great.

In the script you made i want to add some lines from UEZ's code to run an .exe ( autoit script that installs a WP and popups a message etc.) when the time is near to New Year ( 2 hours before for example ) This is a part of the code i try to add in the main script but with no luck however.

UEZ's complete script is

Do
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
Case $button, $dummy
Run("AutoIt-Script.exe")
EndSwitch
If TimerDiff($iTimer) > $iTimeTrayIcon Then
TrayTip("Information", "Sylvester Party in: " & $sTimeLeft, 10, 1)
$iTimer = TimerInit()
EndIf
Until False

I want to add this in to your main script

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...