Jump to content

Recommended Posts

Posted (edited)

Do you want dates or days ?

@WDAY

Numeric day of week. Range is 1 to 7 which corresponds to Sunday through Saturday.

Then you could use

If @WDAY = 1 or @WDAY = 7 then Exit
If you dont want it in the weekends. Edited by Maffe811

[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Posted

I need @YEAR @MON @MDAY something like:

if @YEAR @MON @MDAY = $calendar then

....

If It is possible.

Posted

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GuiButton.au3>
#include <Array.au3>
#include <GuiMonthCal.au3>
#include <DateTimeConstants.au3>
#include <GuiImageList.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Global $min, $hour, $mins, $hours, $Button1, $Button3, $MonthCal1, $path_source, $PageControl1, $TabSheet1, $TabSheet2, $TabSheet3, $msg, $list, $calendar, $open, $file, $iconfile_to_use, $array, $name, $newname, $hImage

_Main()

Func _Main()
    Local $Combo1, $Combo2, $Combo3, $Combo4
    GUICreate('Basic launcher', 515, 275, 211, 148)
    $PageControl1 = GUICtrlCreateTab(96, 8, 417, 265)

    GUICtrlSetResizing(-1, $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)

    $Button1 = GUICtrlCreateButton('Go', 16, 112, 75, 25, $WS_GROUP)
    $TabSheet3 = GUICtrlCreateTabItem("fileopen")
    $path_source = GUICtrlCreateInput("", 152, 143, 197, 21)
    $Button3 = GUICtrlCreateButton("", 209, 102, 85, 35, $WS_GROUP)

    $TabSheet2 = GUICtrlCreateTabItem("timer")
    $Combo1 = GUICtrlCreateCombo('starting min', 136, 184, 145, 25)
    GUICtrlSetData(-1, '1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59')
    $Combo2 = GUICtrlCreateCombo('starting hour', 136, 72, 145, 25)
    GUICtrlSetData(-1, '01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24')
    $Combo3 = GUICtrlCreateCombo('ending min', 320, 184, 145, 25)
    GUICtrlSetData(-1, '1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59')
    $Combo4 = GUICtrlCreateCombo('ending hour', 320, 72, 145, 25)
    GUICtrlSetData(-1, '01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24')
    $TabSheet1 = GUICtrlCreateTabItem("calendar")

    GUICtrlSetState(-1, $GUI_SHOW)
    $MonthCal1 = GUICtrlCreateMonthCal("", 176, 48, 271, 186)
    _GUICtrlMonthCal_SetToday($MonthCal1, @YEAR, @MON, @MDAY)
    GUICtrlCreateTabItem("")

    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE

                MsgBox(0, "", "end")
                Exit


            Case $Combo1;Min
                IniWrite(@ScriptDir & '\A.ini', 'section', '1', GUICtrlRead($Combo1))
                ConsoleWrite(GUICtrlRead($Combo1) & @CRLF)

            Case $Combo2;Hour
                IniWrite(@ScriptDir & '\A.ini', 'section', '2', GUICtrlRead($Combo2))
                ConsoleWrite(GUICtrlRead($Combo2) & @CRLF)

            Case $Combo3;Min
                IniWrite(@ScriptDir & '\A.ini', 'section', '3', GUICtrlRead($Combo3))
                ConsoleWrite(GUICtrlRead($Combo3) & @CRLF)

            Case $Combo4;Hour
                IniWrite(@ScriptDir & '\A.ini', 'section', '4', GUICtrlRead($Combo4))
                ConsoleWrite(GUICtrlRead($Combo4) & @CRLF)
            Case $Button3

                imag()




            Case $Button1
                GUICtrlSetData($Button1, 'Started')
                While Function()
                    Switch GUIGetMsg()
                        Case $GUI_EVENT_CLOSE
                            ExitLoop


                    EndSwitch

                         IniWrite(@ScriptDir & '\A.ini', 'section', 'calendar',GUICtrlRead($MonthCal1))
                        ConsoleWrite(GUICtrlRead($MonthCal1) & @CRLF)


                WEnd
        EndSwitch
    WEnd
EndFunc   ;==>_Main


Func Function()
    $min = IniRead('A.ini', 'section', '1', '')
    $hour = IniRead('A.ini', 'section', '2', '')
    $calendar = IniRead('A.ini', 'section', 'calendar', '')
    $open = IniRead('\A.ini', 'section', 'open', '')

    Sleep(50)
    If @MIN = Number($min) And @HOUR = Number($hour)  Then
        If ProcessExists('notepad.exe') Then
            MsgBox(0, 'Attention Time now is ' & @HOUR & ':' & @MIN, '===  Notepad is running.  ===' & @CRLF & @CRLF & 'Starting ' & _
                    $hour & ':' & $min & @CRLF & 'Ending  ' & $hours & ':' & $mins, 5)
        Else
            Run('NotePad.exe')
        EndIf
    EndIf
EndFunc   ;==>Function
Close()
Func Close()
    $mins = IniRead('A.ini', 'section', '3', '')
    $hours = IniRead('A.ini', 'section', '4', '')
    Sleep(50)
    If ProcessExists('NotePad.exe') Then
        If @MIN = Number($mins) And @HOUR = Number($hours) Then
            clos()
        EndIf
    EndIf
EndFunc   ;==>Close



Func imag()
    $file = FileOpenDialog("Select file", @ProgramFilesDir & "", "Application (*.exe)", 1 + 4)
    While 1
        If @error Then
            GUICtrlSetData($path_source, "")
        Else
            $iconfile_to_use = $file
            $array = StringSplit($iconfile_to_use, '\', 1)
            $name = $array[$array[0]]
            $newname = StringReplace($name, ".exe", "")
            $hImage = _GUIImageList_Create(32, 32, 5, 3, 6)
            _GUIImageList_AddIcon($hImage, $iconfile_to_use, 0, True)
            _GUICtrlButton_SetImageList($Button3, $hImage, 4)
            GUICtrlSetData($path_source, $file)
            IniWrite(@ScriptDir & '\A.ini', 'section', 'open',
                        GUICtrlRead($path_source))
            ConsoleWrite(GUICtrlRead($path_source) & @CRLF)


        EndIf
        ExitLoop

    WEnd

EndFunc   ;==>imag

Func clos()
    GUICtrlSetData($Button1, 'Ending !!!')
    Sleep(13)
    $list = ProcessList('NotePad.exe')
    ProcessClose($list[1][1])

    Sleep(10)
    MsgBox(0, '', 'Closing everything !', 6)
EndFunc   ;==>clos

Posted

This is the script what I want to fix Guys.

Forget the firs one that is too messy .

So Problems :

1 If I press the $Button1 will working.

This is the main problem:

If I press $Button3 before Button1 not working.

Something wrong with the loop.

I can not fix It .

2 I also would like to use something like:

if @YEAR @MON @MDAY = $calendar then

...

3 Is It possible to Run application from ini or input (fileopen)??

Please help If you can.

Posted (edited)

about the loop problem...

Case $Button1
                GUICtrlSetData($Button1, 'Started')
                While Function()
                    Switch GUIGetMsg()
                        Case $GUI_EVENT_CLOSE
                            ExitLoop
                    EndSwitch
                    IniWrite(@ScriptDir & '\A.ini', 'section', 'calendar', GUICtrlRead($MonthCal1))
                    ConsoleWrite(GUICtrlRead($MonthCal1) & @CRLF)
                WEnd

I think here is your problem, i never see the ConsoleWrite Line executing. and i don`t know why you create the While loop

I guess this will work...

Case $Button1
                GUICtrlSetData($Button1, 'Started')
                Function()
                IniWrite(@ScriptDir & '\A.ini', 'section', 'calendar', GUICtrlRead($MonthCal1))
                consoleWrite(GUICtrlRead($MonthCal1) & @CRLF)

This also seems to me rare

While 1
        If @error Then
            GUICtrlSetData($path_source, "")
        Else
;.....Rest of the code

You will never catch an error from a While loop. Also in the same Loop you do an exitloop, then... Why did you create a loop in first instance if you will get out of it in the first loop?

maybe deleting the condition and the loop.(The script work anyway, but it have a couple of useless lines).

Func imag()
    $file = FileOpenDialog("Select file", @ProgramFilesDir & "", "Application (*.exe)", 1 + 4)
    If Not @error Then
        GUICtrlSetData($path_source, "")
        $iconfile_to_use = $file
        $array = StringSplit($iconfile_to_use, '\', 1)
        $name = $array[$array[0]]
        $newname = StringReplace($name, ".exe", "")
        $hImage = _GUIImageList_Create(32, 32, 5, 3, 6)
        _GUIImageList_AddIcon($hImage, $iconfile_to_use, 0, True)
        _GUICtrlButton_SetImageList($Button3, $hImage, 4)
        GUICtrlSetData($path_source, $file)
        IniWrite(@ScriptDir & '\A.ini', 'section', 'open', GUICtrlRead($path_source))
        ConsoleWrite(GUICtrlRead($path_source) & @CRLF)
    Else
        GUICtrlSetData($path_source, "")
        ; also you need to change the icon from the button here.
    EndIf
EndFunc   ;==>imag

It seems a big script, maybe you can use GUICtrlCreateDate() Function. see the example in the halp file.

Edited by monoscout999
Posted

Thank you monoscout999

I tried Your way but unfortunately not working.

If I press $Button3 after will not run the notepad ($Button1). :)

Posted

Thank you monoscout999

I tried Your way but unfortunately not working.

If I press $Button3 after will not run the notepad ($Button1). :)

beacuse i dont fix that ;)

I have adapted your Funciotn() func, to my modifications, adding a global $check to find out if the function that collect the data has been passed.

Try it now(still is a little bugged... but maybe you can fix it)

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GuiButton.au3>
#include <Array.au3>
#include <GuiMonthCal.au3>
#include <DateTimeConstants.au3>
#include <GuiImageList.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Global $min, $hour, $mins, $hours, $Button1, $Button3, $MonthCal1, $path_source, $PageControl1, $TabSheet1, $TabSheet2, $TabSheet3, $msg, $list, $calendar, $open, $file, $iconfile_to_use, $array, $name, $newname, $hImage
Global $check = False
_Main()
Close()
Func _Main()
    Local $Combo1, $Combo2, $Combo3, $Combo4
    GUICreate('Basic launcher', 515, 275, 211, 148)
    $PageControl1 = GUICtrlCreateTab(96, 8, 417, 265)
    GUICtrlSetResizing(-1, $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
    $Button1 = GUICtrlCreateButton('Go', 16, 112, 75, 25, $WS_GROUP)
    $TabSheet3 = GUICtrlCreateTabItem("fileopen")
    $path_source = GUICtrlCreateInput("", 152, 143, 197, 21)
    $Button3 = GUICtrlCreateButton("", 209, 102, 85, 35, $WS_GROUP)
    $TabSheet2 = GUICtrlCreateTabItem("timer")
    $Combo1 = GUICtrlCreateCombo('starting min', 136, 184, 145, 25)
    GUICtrlSetData(-1, '1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59')
    $Combo2 = GUICtrlCreateCombo('starting hour', 136, 72, 145, 25)
    GUICtrlSetData(-1, '01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24')
    $Combo3 = GUICtrlCreateCombo('ending min', 320, 184, 145, 25)
    GUICtrlSetData(-1, '1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59')
    $Combo4 = GUICtrlCreateCombo('ending hour', 320, 72, 145, 25)
    GUICtrlSetData(-1, '01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24')
    $TabSheet1 = GUICtrlCreateTabItem("calendar")
    GUICtrlSetState(-1, $GUI_SHOW)
    $MonthCal1 = GUICtrlCreateMonthCal("", 176, 48, 271, 186)
    _GUICtrlMonthCal_SetToday($MonthCal1, @YEAR, @MON, @MDAY)
    GUICtrlCreateTabItem("")
    GUISetState(@SW_SHOW)
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                MsgBox(0, "", "end")
                Exit

            Case $Combo1;Min
                IniWrite(@ScriptDir & '\A.ini', 'section', '1', GUICtrlRead($Combo1))
                ConsoleWrite(GUICtrlRead($Combo1) & @CRLF)

            Case $Combo2;Hour
                IniWrite(@ScriptDir & '\A.ini', 'section', '2', GUICtrlRead($Combo2))
                ConsoleWrite(GUICtrlRead($Combo2) & @CRLF)

            Case $Combo3;Min
                IniWrite(@ScriptDir & '\A.ini', 'section', '3', GUICtrlRead($Combo3))
                ConsoleWrite(GUICtrlRead($Combo3) & @CRLF)

            Case $Combo4;Hour
                IniWrite(@ScriptDir & '\A.ini', 'section', '4', GUICtrlRead($Combo4))
                ConsoleWrite(GUICtrlRead($Combo4) & @CRLF)
            Case $Button3
                imag()

            Case $Button1
                GUICtrlSetData($Button1, 'Started')
                Function()
                IniWrite(@ScriptDir & '\A.ini', 'section', 'calendar', GUICtrlRead($MonthCal1))
                ConsoleWrite(GUICtrlRead($MonthCal1) & @CRLF)

        EndSwitch
        If $check Then
            If @MIN = Number($min) And @HOUR = Number($hour) Then
                If ProcessExists('notepad.exe') Then
                    MsgBox(0, 'Attention Time now is ' & @HOUR & ':' & @MIN, '===  Notepad is running.  ===' & @CRLF & @CRLF & 'Starting ' & _
                            $hour & ':' & $min & @CRLF & 'Ending  ' & $hours & ':' & $mins, 5)
                Else
                    Run('NotePad.exe')
                EndIf
            EndIf
        EndIf
    WEnd
EndFunc   ;==>_Main

Func Function()
    $min = IniRead('A.ini', 'section', '1', '')
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : IniRead(''A.ini'', ''section'', ''1'', '''') = ' & IniRead('A.ini', 'section', '1', '') & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
    $hour = IniRead('A.ini', 'section', '2', '')
    $calendar = IniRead('A.ini', 'section', 'calendar', '')
    $open = IniRead('\A.ini', 'section', 'open', '')
    $check = True
    Return $check
EndFunc   ;==>Function

Func Close()
    $mins = IniRead('A.ini', 'section', '3', '')
    $hours = IniRead('A.ini', 'section', '4', '')
    Sleep(50)
    If ProcessExists('NotePad.exe') Then
        If @MIN = Number($mins) And @HOUR = Number($hours) Then
            clos()
        EndIf
    EndIf
EndFunc   ;==>Close

Func imag()
    $file = FileOpenDialog("Select file", @ProgramFilesDir & "", "Application (*.exe)", 1 + 4)
    If Not @error Then
        GUICtrlSetData($path_source, "")
        $iconfile_to_use = $file
        $array = StringSplit($iconfile_to_use, '\', 1)
        $name = $array[$array[0]]
        $newname = StringReplace($name, ".exe", "")
        $hImage = _GUIImageList_Create(32, 32, 5, 3, 6)
        _GUIImageList_AddIcon($hImage, $iconfile_to_use, 0, True)
        _GUICtrlButton_SetImageList($Button3, $hImage, 4)
        GUICtrlSetData($path_source, $file)
        IniWrite(@ScriptDir & '\A.ini', 'section', 'open', GUICtrlRead($path_source))
        ConsoleWrite(GUICtrlRead($path_source) & @CRLF)
    Else
        GUICtrlSetData($path_source, "")
        ; also you need to change the icon from the button here.
    EndIf
EndFunc   ;==>imag


Func clos()
    GUICtrlSetData($Button1, 'Ending !!!')
    Sleep(13)
    $list = ProcessList('NotePad.exe')
    ProcessClose($list[1][1])

    Sleep(10)
    MsgBox(0, '', 'Closing everything !', 6)
EndFunc   ;==>clos
Posted

Thank you monoscout999

Im not lucky still same problem

and this red msg:

@@ Debug(83) : IniRead('A.ini', 'section', '1', '') =

>Error code: 0

Would you be so kind to try It.

Fileopen click on the button, and after that try the timer section to launch notepad.

It is not working for me. :)

Posted (edited)

and this red msg:

@@ Debug(83) : IniRead('A.ini', 'section', '1', '') =

>Error code: 0

This is the console debug, If you use SciTe, just press ALT + D in a line and it will be writen above that line, is useful to check the script working and detect errors.

If you wanna learn for real maybe you can start from the beggining... do a snnipet of the function of your script and start adding one by one the features you want, you need to check every step to control that the script still work, by example: If i was you i`ll start with something like this.

READ MY WHOLE ANSWER BEFORE RUN IT!

; When i want to run the program
$min = @MIN + 1 ; A minute before run this script
$hour = @HOUR
; What day i want to run the program
$mday = @MDAY
$mon = @MON
;~ $year = @YEAR ; It seems a litle useless using the Year :S

While True
    If _CheckTime() then Run("notepad.exe")
WEnd

Func _CheckTime()
    If $min = @MIN and $hour = @HOUR and $mday = @MDAY and $mon = @MON Then return true
EndFunc

OPS!!! If you run that something unexpected will happen, when one minute pass, notepad will be open many times until one minute pass again, well then i think a way to fix that and also add a hotkey for emergency exit, maybe i will remove the hotkey later when the script is done.

The way to fix the multiple runnings of notepad can be:

Add a varible to check when the function pass and control the acces to the function with this variable.

or

Setting the time variables to force the condition check of the function to return false.

I have a feeling for the second one, one reason is that maybe when the program is fully functional, i will use this feature to change the day for future runnings. second, that don´t create another variable.

$min = @MIN + 1 ; A minute before run this script
$hour = @HOUR
; What day i want to run the program
$mday = @MDAY
$mon = @MON
;~ $year = @YEAR ; It seems a litle useless using the Year :S

While True
    If _CheckTime() then Run("notepad.exe")
WEnd

Func _CheckTime()
    If $min = @MIN and $hour = @HOUR and $mday = @MDAY and $mon = @MON Then
        $mday += 7 ; This is equal to $day = $day + 7, so i set the next day for running a week later
    return true
    EndIf
EndFunc
Func _exit()
    Exit
EndFunc

It seems working, but.... :) What happend if we are in the day 29 and we add 7? the month have 31 days, so we have to find some solution to this situation.

Well i left to you to solve it, if you want. This is a day in a life of monoscout999, i do the things this way, maybe it can help you if you get messy with your script. I don`t care if you do it this way or if you continue your way, my tip is: do one step at the time, start from the main part and expand to all other areas of your program.

I hope be helpful.

Edited by monoscout999

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...