Jump to content

Need help with this.


Recommended Posts

Ok, Ive decided to make a proper project, but one that I will use.

Basically, it will be to alert you when someones birthday is near.

I want it to run on startup.

First of all, I want to have some sort or file ( .ini? ) that i edit and put in the dates of the birthdays

eg

FRED    31  MAY
BOB 22  AUGUST
BILL    7   JUNE

So having the ini set like that.

I want it so, every 4hours, it will check the computer time, and if it happens to be one of those dates,

then a message box will pop up "Today it is Freds birthday" or "Today it is Bobs birthday" etc.

How would I go about making this?

# MY LOVE FOR YOU... IS LIKE A TRUCK- #
Link to comment
Share on other sites

Maybe start by creating the gui to input the info

( maybe KODA Form Desaigner or GUI Builder > in SciTE Tools )

then when a button is pressed

use guictrlread() to read the inputed info

then use iniWrite() to write the info to the file

thats a way to start... after that we can work on the date functions and the message

8)

NEWHeader1.png

Link to comment
Share on other sites

Maybe start by creating the gui to input the info

( maybe KODA Form Desaigner or GUI Builder > in SciTE Tools )

then when a button is pressed

use guictrlread() to read the inputed info

then use iniWrite() to write the info to the file

thats a way to start... after that we can work on the date functions and the message

8)

I dont really know how it will look though, or work. Tips? Hints?
# MY LOVE FOR YOU... IS LIKE A TRUCK- #
Link to comment
Share on other sites

I dont really know how it will look though, or work. Tips? Hints?

Well, I made a GUI, but now i need to put in the code for the button.

Posted Image

# MY LOVE FOR YOU... IS LIKE A TRUCK- #
Link to comment
Share on other sites

you need to paste the script here

[ code] ; no space

; paste code here

[ /code] ; no space

8)

#include <GUIConstants.au3>
; == GUI generated with Koda ==
$Form1 = GUICreate("Write", 193, 113, 192, 125)
GUISetBkColor(0xFFFBF0)
$Button1 = GUICtrlCreateButton("Write", 8, 80, 177, 25)
GUICtrlCreateLabel("Name", 8, 8, 32, 17)
GUICtrlSetBkColor(-1, 0xFFFBF0)
GUICtrlCreateLabel("Day", 8, 32, 23, 17)
GUICtrlSetBkColor(-1, 0xFFFBF0)
GUICtrlCreateLabel("Month", 8, 56, 34, 17)
GUICtrlSetBkColor(-1, 0xFFFBF0)
$Input1 = GUICtrlCreateInput("Input Persons Name Here", 48, 8, 137, 21, -1, $WS_EX_CLIENTEDGE)
$Input2 = GUICtrlCreateInput("Input Day Here", 48, 32, 137, 21, -1, $WS_EX_CLIENTEDGE)
$Input3 = GUICtrlCreateInput("Input Month Here", 48, 56, 137, 21, -1, $WS_EX_CLIENTEDGE)
GUISetState(@SW_SHOW)
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
    ;;;;;;;
    EndSelect
WEnd
Exit

Like this?

# MY LOVE FOR YOU... IS LIKE A TRUCK- #
Link to comment
Share on other sites

follow this

Case $msg =  $Button1
$Name = GuiCtrlRead($input1)
...
... same for other inputs

8)

where do I do/put this? where ";;;;;;;;" is?
# MY LOVE FOR YOU... IS LIKE A TRUCK- #
Link to comment
Share on other sites

#include <GUIConstants.au3>
; == GUI generated with Koda ==
$Form1 = GUICreate("Write", 193, 113, 192, 125)
GUISetBkColor(0xFFFBF0)
$Button1 = GUICtrlCreateButton("Write", 8, 80, 177, 25)
GUICtrlCreateLabel("Name", 8, 8, 32, 17)
GUICtrlSetBkColor(-1, 0xFFFBF0)
GUICtrlCreateLabel("Day", 8, 32, 23, 17)
GUICtrlSetBkColor(-1, 0xFFFBF0)
GUICtrlCreateLabel("Month", 8, 56, 34, 17)
GUICtrlSetBkColor(-1, 0xFFFBF0)
$Input1 = GUICtrlCreateInput("Input Persons Name Here", 48, 8, 137, 21, -1, $WS_EX_CLIENTEDGE)
$Input2 = GUICtrlCreateInput("Input Day Here", 48, 32, 137, 21, -1, $WS_EX_CLIENTEDGE)
$Input3 = GUICtrlCreateInput("Input Month Here", 48, 56, 137, 21, -1, $WS_EX_CLIENTEDGE)
GUISetState(@SW_SHOW)
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
;;;;;;;
    EndSelect
WEnd
Exit

Like this?

Good start! :(

At the Case Else, change it to Case $msg = $Button1. That will handle clicking the Write button. Under that, you want to read the contents of your input boxes with $InputData1 = GuiCtrlRead($Input1), etc. and exit the loop to save the data to your ini file with IniWrite().

You'll be sharing birthday wishes in no time... :)

P.S. Oops, Valuater's all over it already...

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

try this...I added a exit button so you can do more than one, then you can exit when done.

#include <GUIConstants.au3>
$Form1 = GUICreate("Write", 193, 113, 192, 125)
GUISetBkColor(0xFFFBF0)
$Button1 = GUICtrlCreateButton("Write", 8, 80, 135, 25)
$Button2 = GUICtrlCreateButton("Exit", 147, 80, 40, 25)
GUICtrlCreateLabel("Name", 8, 8, 32, 17)
GUICtrlSetBkColor(-1, 0xFFFBF0)
GUICtrlCreateLabel("Day", 8, 32, 23, 17)
GUICtrlSetBkColor(-1, 0xFFFBF0)
GUICtrlCreateLabel("Month", 8, 56, 34, 17)
GUICtrlSetBkColor(-1, 0xFFFBF0)
$Input1 = GUICtrlCreateInput("Input Persons Name Here", 48, 8, 137, 21, -1, $WS_EX_CLIENTEDGE)
$Input2 = GUICtrlCreateInput("Input Day Here", 48, 32, 137, 21, -1, $WS_EX_CLIENTEDGE)
$Input3 = GUICtrlCreateInput("Input Month Here", 48, 56, 137, 21, -1, $WS_EX_CLIENTEDGE)

GUISetState(@SW_SHOW)
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
 Case $msg =  $Button1
   $Name = GuiCtrlRead($input1)
   $day = GuiCtrlRead($input2)
   $month = GuiCtrlRead($input3)
   IniWrite("birthday.ini",$Name,"name",$Name)
   IniWrite("birthday.ini",$Name,"date",$day)
   IniWrite("birthday.ini",$Name,"month",$month)
 Case $msg =  $Button2 
  exit   
 Case Else
 ;;;;;;;
    EndSelect
WEnd
Exit

I would also make it so when you click on a field to enter data, the default data would blank out.

Edited by vollyman
Link to comment
Share on other sites

Good start! :(

At the Case Else, change it to Case $msg = $Button1. That will handle clicking the Write button. Under that, you want to read the contents of your input boxes with $InputData1 = GuiCtrlRead($Input1), etc. and exit the loop to save the data to your ini file with IniWrite().

You'll be sharing birthday wishes in no time... :)

P.S. Oops, Valuater's all over it already...

While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg =  $Button1
    $Name = GuiCtrlRead($input1)
    $Day = GuiCtrlRead($input2)
    $Month = GuiCtrlRead($input3)
        ExitLoop
;;;;;;;
    EndSelect
WEnd
Exit

Is this write? I searched the help file for the iniwrite function. but i still dont understand.. Im, one of those people that needs everything explained to me, very clearly xP or else i just get really confused, and give up.

Hehe...

Nevermind, just saw the post above me after i posted, will try it.

Edited by AzKay
# MY LOVE FOR YOU... IS LIKE A TRUCK- #
Link to comment
Share on other sites

This works for me....it will also check the ini every 4 hours but the time could be changed and a button/hotkey can also be set up to check the birthdays.

#include <GUIConstants.au3>
; == GUI generated with Koda ==
$Form1 = GUICreate("Write", 193, 113, 192, 125)
GUISetBkColor(0xFFFBF0)
$Button1 = GUICtrlCreateButton("Write", 8, 80, 177, 25)
GUICtrlCreateLabel("Name", 8, 8, 32, 17)
GUICtrlSetBkColor(-1, 0xFFFBF0)
GUICtrlCreateLabel("Day", 8, 32, 23, 17)
GUICtrlSetBkColor(-1, 0xFFFBF0)
GUICtrlCreateLabel("Month", 8, 56, 34, 17)
GUICtrlSetBkColor(-1, 0xFFFBF0)
$Input1 = GUICtrlCreateInput("Input Persons Name Here", 48, 8, 137, 21, -1, $WS_EX_CLIENTEDGE)
$Input2 = GUICtrlCreateInput("Input Day Here", 48, 32, 137, 21, -1, $WS_EX_CLIENTEDGE)
$Input3 = GUICtrlCreateInput("Input Month Here", 48, 56, 137, 21, -1, $WS_EX_CLIENTEDGE)
GUISetState(@SW_SHOW)

;check to see if the ini exists, if not make a new one
FileChangeDir( @ScriptDir )
$temp = IniRead( "birthdays.ini", "counter", "entries", "-1" )

If $temp < 0 Then
    IniWrite( "birthdays.ini", "counter", "entries", "0" )
EndIf

;execute the check_bday function every 4 hours ( 14400000ms )
AdlibEnable( "check_bday", 14400000 )

While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Button1
        $entries = IniRead( "birthdays.ini", "counter", "entries", "-1" )
        
        $key = "birthday" & $entries
        $value = GUICtrlRead( $Input1 ) & "-" & GUICtrlRead( $Input2 ) & "-" & GUICtrlRead( $Input3 )
        
        $err = IniWrite( "birthdays.ini", "bdays", $key, $value )
        $err += IniWrite( "birthdays.ini", "counter", "entries", $entries + 1 )
        If $err <> 2 Then    
            MsgBox( 4096, "Error", "Error writing to ini file." )
            Exit
        EndIf

        MsgBox( 0, "Record Added", "The new birthday has been added to the ini file!" )
    EndSelect
WEnd
Exit


Func check_bday()
    $bday_info = IniReadSection( "birthdays.ini", "bdays" )

    If @error Then
        MsgBox( "4096", "Error", "Error reading ini file, please make sure file exists and is in same folder as script." )
        Exit
    EndIf
    
    Local $temp
    
    For $iter = 1 To $bday_info[0][0]
        ;temp will be array of name then day then month
        $temp = StringSplit( $bday_info[$iter][1], "-" )
        
        If $temp[3] = @MON And $temp[2] = @MDAY Then
            MsgBox( 0, "HAPPY BIRTHDAY!!!", "The current date is " & @MON & "/" & @MDAY & "/" & @YEAR & @CR & _
            "Dont forget to wish " & $temp[1] & " a happy birthday today!" )
        EndIf
    Next
EndFunc

Let me know how it goes...

EDIT: typo in code :)

Edited by Don N

_____________________________________________________"some people live for the rules, I live for exceptions"Wallpaper Changer - Easily Change Your Windows Wallpaper

Link to comment
Share on other sites

This works for me....it will also check the ini every 4 hours but the time could be changed and a button/hotkey can also be set up to check the birthdays.

#include <GUIConstants.au3>
; == GUI generated with Koda ==
$Form1 = GUICreate("Write", 193, 113, 192, 125)
GUISetBkColor(0xFFFBF0)
$Button1 = GUICtrlCreateButton("Write", 8, 80, 177, 25)
GUICtrlCreateLabel("Name", 8, 8, 32, 17)
GUICtrlSetBkColor(-1, 0xFFFBF0)
GUICtrlCreateLabel("Day", 8, 32, 23, 17)
GUICtrlSetBkColor(-1, 0xFFFBF0)
GUICtrlCreateLabel("Month", 8, 56, 34, 17)
GUICtrlSetBkColor(-1, 0xFFFBF0)
$Input1 = GUICtrlCreateInput("Input Persons Name Here", 48, 8, 137, 21, -1, $WS_EX_CLIENTEDGE)
$Input2 = GUICtrlCreateInput("Input Day Here", 48, 32, 137, 21, -1, $WS_EX_CLIENTEDGE)
$Input3 = GUICtrlCreateInput("Input Month Here", 48, 56, 137, 21, -1, $WS_EX_CLIENTEDGE)
GUISetState(@SW_SHOW)

;check to see if the ini exists, if not make a new one
FileChangeDir( @ScriptDir )
$temp = IniRead( "birthdays.ini", "counter", "entries", "-1" )

If $temp < 0 Then
    IniWrite( "birthdays.ini", "counter", "entries", "0" )
EndIf

;execute the check_bday function every 4 hours ( 14400000ms )
AdlibEnable( "check_bday", 14400000 )

While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Button1
        $entries = IniRead( "birthdays.ini", "counter", "entries", "-1" )
        
        $key = "birthday" & $entries
        $value = GUICtrlRead( $Input1 ) & "-" & GUICtrlRead( $Input2 ) & "-" & GUICtrlRead( $Input3 )
        
        $err = IniWrite( "birthdays.ini", "bdays", $key, $value )
        $err += IniWrite( "birthdays.ini", "counter", "entries", $entries + 1 )
        If $err <> 2 Then    
            MsgBox( 4096, "Error", "Error writing to ini file." )
            Exit
        EndIf

        MsgBox( 0, "Record Added", "The new birthday has been added to the ini file!" )
    EndSelect
WEnd
Exit
Func check_bday()
    $bday_info = IniReadSection( "birthdays.ini", "bdays" )

    If @error Then
        MsgBox( "4096", "Error", "Error reading ini file, please make sure file exists and is in same folder as script." )
        Exit
    EndIf
    
    Local $temp
    
    For $iter = 1 To $bday_info[0][0]
        ;temp will be array of name then day then month
        $temp = StringSplit( $bday_info[$iter][1], "-" )
        
        If $temp[3] = @MON And $temp[2] = @MDAY Then
            MsgBox( 0, "HAPPY BIRTHDAY!!!", "The current date is " & @MON & "/" & @MDAY & "/" & @YEAR & @CR & _
            "Dont forget to wish " & $temp[1] & " a happy birthday today!" )
        EndIf
    Next
EndFunc

Let me know how it goes...

EDIT: typo in code :)

"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Documents and Settings\Asus\My Documents\AutoIt\test.au3" /autoit3dir "C:\Program Files\AutoIt3" /UserParams

>Running AU3Check params: from:C:\Program Files\AutoIt3\SciTE\au3check\

+>AU3Check ended.rc:0

>Running:(3.1.1.0):C:\Program Files\AutoIt3\autoit3.exe "C:\Documents and Settings\Asus\My Documents\AutoIt\test.au3"

C:\Documents and Settings\Asus\My Documents\AutoIt\test.au3 (40) : ==> Expected a "=" operator in assignment statement.:

$err += IniWrite( "birthdays.ini", "counter", "entries", $entries + 1 )

$err ^ ERROR

+>AutoIT3.exe ended.rc:0

>Exit code: 0 Time: 14.785

oO, I have no idea what is going on, lawl, all this scripting bussiness is getting to me xD
# MY LOVE FOR YOU... IS LIKE A TRUCK- #
Link to comment
Share on other sites

oO, I have no idea what is going on, lawl, all this scripting bussiness is getting to me xD

Nevermind about that, there was a +infront of the =, i get it, typo, umm, i keep getting the error writing to ini message box, but it does write, and, would the format be in, MONTH = May, June, etc, or would it be in numbers, eg MONTH 11, 12, 4, etc
# MY LOVE FOR YOU... IS LIKE A TRUCK- #
Link to comment
Share on other sites

Nevermind about that, there was a +infront of the =, i get it, typo, umm, i keep getting the error writing to ini message box, but it does write, and, would the format be in, MONTH = May, June, etc, or would it be in numbers, eg MONTH 11, 12, 4, etc

anyone? yes, i know i shouldnt be posting useless posts in a thread which is on the first page, but im very impatient xP, and i also know thats not a real excuse.
# MY LOVE FOR YOU... IS LIKE A TRUCK- #
Link to comment
Share on other sites

Sorry this isn't going to help with the question, but what am I missing my gui's dont look like this

Posted Image they look like this Posted Image anyone know why?

#1, im using a windows skin, and #2 your using, correct me if im wrong, GuiBuilder?

im using the other one, underneath it

# MY LOVE FOR YOU... IS LIKE A TRUCK- #
Link to comment
Share on other sites

#1, im using a windows skin, and #2 your using, correct me if im wrong, GuiBuilder?

im using the other one, underneath it

I just copied the code and ran it. And that's the gui that showed up. How do you use a Windows skin?
Link to comment
Share on other sites

just a quick thing I would probally instead of having them input the date , i would have a calander or a date chooser

thats what i thought, but i couldnt be bothered xP, i just want to finnish this as soon as possible.
# MY LOVE FOR YOU... IS LIKE A TRUCK- #
Link to comment
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
 Share

  • Recently Browsing   0 members

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