Sign in to follow this  
Followers 0
Shiro

adding the app's start date in message box

12 posts in this topic

hi,

i have created a very little script which shows a message box.

in the message box i want to add 30 day trial info.

something like this:

Title: You have been using this program since 1 day!

Message: This program 'll expire in 29 days!

how would i do this?


Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

MsgBox(64, "You have been using this program since 1 day!", "This program 'll expire in 29 days!")

???

it's not what i am looking for, i know MsgBox() very well.

the problem is that i want it to be changed every day!

Like if i ran/run the app today then it 'll say!

Title: You have been using this program since 1 day!

Message: This program 'll expire in 29 days!

After 5 days:

Title: You have been using this program since 5 days!

Message: This program 'll expire in 25 days!

after 18 days:

Title: You have been using this program since 18 days!

Message: This program 'll expire in 12 days!

i hope you got my point, in the message box i want to add 30 day trial info.

Edited by Shiro

Share this post


Link to post
Share on other sites

it's not what i am looking for, i know MsgBox() very well.

the problem is that i want it to be changed every day!

Like if i ran/run the app today then it 'll say!

Title: You have been using this program since 1 day!

Message: This program 'll expire in 29 days!

After 5 days:

Title: You have been using this program since 5 days!

Message: This program 'll expire in 25 days!

after 18 days:

Title: You have been using this program since 18 days!

Message: This program 'll expire in 12 days!

i hope you got my point, in the message box i want to add 30 day trial info.

Keep the starting date in the registry, and every time you start program compare this date with the current date.

Share this post


Link to post
Share on other sites

any example?


Share this post


Link to post
Share on other sites

im not sure about the registry so i wont post it... but

$startup = ;the registry key you need... or anyfile you wanted to write
$0 = @YDAY
msgbox (0,'',$0 - $startup & ' days left on trial.')

just as an example mind you... use more indepth math operations and string manipulations to do it more efficiently... also get the @YEAR and then compare that as well

Share this post


Link to post
Share on other sites

well, i could not understand at all, where in msgbox $0 is @day & $startup is the registry key?

if we store some spesific date in a txt fie or in registry key then how it 'll show them as i want them?

i think in the example mentioned above there is nothing which can help me to write it.

i mean something like "you have passed 1 day(s) running this app and 29 day(s) are left."

can any one post a example of storing date in txt file and do as i asked?


Share this post


Link to post
Share on other sites

well, i could not understand at all, where in msgbox $0 is @day & $startup is the registry key?

if we store some spesific date in a txt fie or in registry key then how it 'll show them as i want them?

i think in the example mentioned above there is nothing which can help me to write it.

i mean something like "you have passed 1 day(s) running this app and 29 day(s) are left."

can any one post a example of storing date in txt file and do as i asked?

This example should make it clearer for you. It uses the registry rather than a text file to store the date the application was first run.

#include <Date.au3>

MsgBox(0 ,"Days Used", "You have been using this application for " &  _GetNumDaysSinceFirstRun() & " days")

Func _GetNumDaysSinceFirstRun()
Local $NumDaysUsed = 0
Local $InstallDate = ""
Local $TodaysDate = _NowCalcDate()
;To test uncomment the line below to test, Adds 9 days to todays date
;$TodaysDate = _DateAdd("D",9,$TodaysDate)

    $InstallDate = RegRead ("HKEY_LOCAL_MACHINE\SOFTWARE\mytrialapplication", "firstrun" )
    If @error Then
        ; Registry key does not exist so it's probably the
        ; first time application has been run so store todays date in registry
        RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\mytrialapplication", "firstrun", "REG_SZ",  $TodaysDate)
        ;Number of days used is 0
        Return $NumDaysUsed
    Else
        ; Calculate the number of days between install date and today
        $NumDaysUsed = _DateDiff("D", $InstallDate, $TodaysDate)
    EndIf
    Return $NumDaysUsed
EndFunc

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Share this post


Link to post
Share on other sites

thanks a lot "Bowmore" but how can i get the information of days left in expiration?

For example it says: You have been using this application for 0 days.

and i also want to show days left: You have been using this application for 0 days and it will expire in 30 days.


Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

any example code?


Share this post


Link to post
Share on other sites

use this lol

$started = ;when you started the trial... get this date from however means you wish
$current = @yday
$daysleft = $current - $started

;for example
;$started = 10 (JAN 10TH)
;$Current = 11 (JAN 11TH)
;$Daysleft = $Current - $started

;therefore... $Daysleft = 1

simple as that dont bother running this code it wont work...

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0