Jump to content

Latest Modified Folder


Hyflex
 Share

Recommended Posts

I have two things I need help with regarding folder times...

1) I need a macro to look in a folder:

C:SharingDropboxTDRTRDataT
inside this folder there are loads of folders, I need it to find the folder what was last created/modified and copy the contents of that folder to:
C:SharingDropboxTDRTRDataIM
and overwrite all files

2) I need another macro to look at the folder

C:SharingDropboxTDRTRDataIM
if it was edited/modified (new contents = modified?) within the last 2 hours then it needs to run some macros I have done already.
Link to comment
Share on other sites

What code do you have so far? What have you tried? Look at _RecFileListToArray to get the files/folders that you're interested in, and them FileGetTime for when it was created/modified last. FileMove to move them.

We don't write the code for you, you need to make an effort and then if you have problems you can't figure out ask for help. Don't just ask someone to do it for you.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

  • Moderators

XxXGoD,

It's the folder time I'm having trouble with... there isn't anything for this

Are you sure? :D

FileGetTime works on folders too! :oops:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Ok, I have that bit working but i cant see what I'm doing wrong with the following:

If you notice I'm trying $True instead of True or = "True" (I've tried all three)

While 1
    
    Sleep(100)      ; Default Delay
    
    $MDC= IniRead(@ScriptDir & "Settings.ini", "Morning", "DC", "False")
    $MorningHour = IniRead(@ScriptDir & "Settings.ini", "Morning", "Hours", "05")
    $MorningMinutes = IniRead(@ScriptDir & "Settings.ini", "Morning", "Minutes", "30")
    $MorningSeconds = IniRead(@ScriptDir & "Settings.ini", "Morning", "Seconds", "00")
    
    $EDC= IniRead(@ScriptDir & "Settings.ini", "Evening", "DC", "False")
    $Data= IniRead(@ScriptDir & "Settings.ini", "Evening", "Data", "False")
    $EveningHour = IniRead(@ScriptDir & "Settings.ini", "Evening", "Hours", "05")
    $EveningMinutes = IniRead(@ScriptDir & "Settings.ini", "Evening", "Minutes", "30")
    $EveningSeconds = IniRead(@ScriptDir & "Settings.ini", "Evening", "Seconds", "00")
    
    $Notifcations = IniRead(@ScriptDir & "Settings.ini", "Dev", "Notifcations", "True")
    $NotifcationTime = IniRead(@ScriptDir & "Settings.ini", "Dev", "Notifcation Time", "5")
    $SleepDelay = IniRead(@ScriptDir & "Settings.ini", "Dev", "Sleep Delay", "500")
    $NotifcationMessage = IniRead(@ScriptDir & "Settings.ini", "Dev", "Notifcation Message", "A macro is just about to start")
    $True = "True"
    
    If $MDC= $True Then
        If @HOUR = $MorningHour Then
            If @Min = $MorningMinutes Then
                If @SEC = $MorningSeconds Then
                    MDC()
                EndIf
            EndIf
        EndIf
        
        If $Notifcations = $True Then
            If @HOUR = $MorningHour Then
                If @Min = $MorningMinutes -$NotifcationTime Then
                    If @SEC = $MorningSeconds Then
                        NotificationWarning()
                    EndIf
                EndIf
            EndIf
        EndIf
    EndIf
    
    If $EDC = $True Or $Data = $True Then
        If @HOUR = $EveningHour Then
            If @Min = $EveningMinutes Then
                If @SEC = $EveningSeconds Then
                    If $EDC = $True Then
                        EDC()
                    EndIf
                    If $Data = $True Then
                        Data()
                    EndIf
                EndIf
            EndIf
        EndIf
        
        If $Notifcations = $True Then
            If @HOUR = $EveningHour Then
                If @Min = $EveningMinutes -$NotifcationTime Then
                    If @SEC = $EveningSeconds Then
                        NotificationWarning()
                    EndIf
                EndIf
            EndIf
        EndIf
    EndIf
    
WEnd
Link to comment
Share on other sites

  • Moderators

XxXGoD,

I presume you are trying to fire the functions at the time set in the ini file - and have a notification beforehand. Do the functions you call rewrite the inifile to reset the Boolean (True/False) values? I think you could streamline the code a lot by only reading the likely changed values within the loop - the actual times can be read once and then stored. :oops:

But the main problem is the loop itself and your use of a mixture of numbers and strings in the comparisons - I have tried to show how you might avoid that. I have also used 1/0 in place of True/False - that always poses problems with ini files. :)

You might also have a problem using the simple subtraction to get the Notification time - what happens if the minutes go back past the hour? :D

This works for me - you will need to adjust the default times to local at your location. Then you should see the minutes and the actions tick up on the SciTE console:

#include <Date.au3>

$MDC = Number(IniRead(@ScriptDir & "Settings.ini", "Morning", "DC", 1)) ; Use 1/0 rather than True/False
$MorningHour = IniRead(@ScriptDir & "Settings.ini", "Morning", "Hours", "20")
$MorningMinutes = IniRead(@ScriptDir & "Settings.ini", "Morning", "Minutes", "10")
$MorningSeconds = IniRead(@ScriptDir & "Settings.ini", "Morning", "Seconds", "00")
$MorningTime = $MorningHour & ":" & $MorningMinutes & ":" & $MorningSeconds
ConsoleWrite("-AM Time: " & $MorningTime & @CRLF)

$EDC = Number(IniRead(@ScriptDir & "Settings.ini", "Evening", "DC", 0))
$Data = Number(IniRead(@ScriptDir & "Settings.ini", "Evening", "Data", 0))
$EveningHour = IniRead(@ScriptDir & "Settings.ini", "Evening", "Hours", "20")
$EveningMinutes = IniRead(@ScriptDir & "Settings.ini", "Evening", "Minutes", "15")
$EveningSeconds = IniRead(@ScriptDir & "Settings.ini", "Evening", "Seconds", "00")
$EveningTime = $EveningHour & ":" & $EveningMinutes & ":" & $EveningSeconds
ConsoleWrite("-PM Time: " & $EveningTime & @CRLF)

$Notifcations = Number(IniRead(@ScriptDir & "Settings.ini", "Dev", "Notifcations", 1))
$NotifcationTime = Number(IniRead(@ScriptDir & "Settings.ini", "Dev", "Notifcation Time", 2)) ; Altered for testing
$SleepDelay = IniRead(@ScriptDir & "Settings.ini", "Dev", "Sleep Delay", "500")
$NotifcationMessage = IniRead(@ScriptDir & "Settings.ini", "Dev", "Notifcation Message", "A macro is just about to start")

; Simple subtraction will not work if the minutes would go back before the hour - so we need to be a bit more demanding
; Here we use _DateAdd to take off the minutes - but that means we need to add the YYY/MM/DD and then remove it afterwards.  Good fun this!!!!!!
$MorningNotification = StringRegExpReplace(_DateAdd("n", -1 * $NotifcationTime, @YEAR & "/" & @MON & "/" & @MDAY & " " & $MorningTime), ".*(dd:dd:dd)", "$1")
ConsoleWrite("-AM Notification: " & $MorningNotification & @CRLF)
$EveningNotification = StringRegExpReplace(_DateAdd("n", -1 * $NotifcationTime, @YEAR & "/" & @MON & "/" & @MDAY & " " & $EveningTime), ".*(dd:dd:dd)", "$1")
ConsoleWrite("-PM Notification: " & $EveningNotification & @CRLF)

$iMin = @MIN ; Just for testing <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

While 1

    Sleep(1000) ; Default Delay

    ; Just create the time once
    $sNow = @HOUR & ":" & @MIN & ":" & @SEC

    If $iMin <> @MIN Then                      ; Just for testing <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        $iMin = @MIN                           ; Just for testing <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        ConsoleWrite("Now = " & $sNow & @CRLF) ; Just for testing <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    EndIf                                      ; Just for testing <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

    If $MDC Then
        If $sNow = $MorningTime Then
            ;MDC()
            ConsoleWrite("MDC Running" & @CRLF)
            ; Simulating the changes to the values
            $MDC = 0
            $EDC = 1
        EndIf

        If $sNow = $MorningNotification Then
            ;NotificationWarning()
            ConsoleWrite("Morning Warning" & @CRLF)
        EndIf
    EndIf

    If $EDC Or $Data Then
        If $sNow = $EveningTime Then
            If $EDC Then
                ;EDC()
                ConsoleWrite("EDC Running" & @CRLF)
                $MDC = 1
                $EDC = 0
            EndIf
            If $Data Then
                ;Data()
                ConsoleWrite("Data Running" & @CRLF)
            EndIf
        EndIf

        If $sNow = $EveningNotification Then
            ;NotificationWarning()
            ConsoleWrite("Evening Warning" & @CRLF)
        EndIf
    EndIf

WEnd

Please ask if you have any questions - or if it does not behave as I thought you required. :rip:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

XxXGoD,

You PM'd me saying you did not understand the above. Let me try to explain in more detail, although without knowledge of the rest of your code I am having to assume quite a lot. :D

- 1. You were reading the inifile each time you went through the loop, which seeemed a bit excessive in a 100ms loop. It would be far more elegant to read the inifile when the script opens, place the data into variables and use them while the script runs, and then rewrite the (possibly amended) data to the inifile when the script exits. So I moved all the IniRead commands outside the loop - depending on the rest of your script that may not be a good idea, but I can only go on the code that you posted. :(

- 2. You were usng 3 If statements each time you wanted to check the time - more efficient to use just the one. So I combined the data from the ini files into a single HH:MM:SS format string. In the loop (which I ran at only 1000ms as we only look for a second difference) I did the same with @HOUR & ":" & @MIN & ":" & @SEC. Now I can use a single If statement to check if the actual time matches the required time from the inifile data. :D

- 3. Using Boolean (True/False) values in inifiles is never a good idea - as you discovered. It has to do with datatypes and I am not getting into that here. Suffice to say that using 1/0 is just as good and causes fewer problems - although you will note I used the Number function to force the value into number format. This is needed because IniRead returns a string - a string is true if it exists; we want a number so that it is true only if it is non-zero. I told you datatypes were complex! :oops:

- 4. You could run into problems when calculating your notification time. You were using simple subtraction, but what happens if you need to take off 5minutes from 18:02:00? Under your scheme we would get 18:-03:00 - not sure that you would get the correct match! So I used _DateAdd - let me break down the line I used:

; Take off the required time

$MorningNotification = _DateAdd("n", -1 * $NotifcationTime, @YEAR & "/" & @MON & "/" & @MDAY & " " & $MorningTime)

; Note that we need to add a date to the time to get the correct format for _DateAdd - we do this using the date macros

; But this returns a string containing the date - so we need to remove it.  There are any number of ways to do this, but I used an SRE

$MorningNotification = StringRegExpReplace($MorningNotification, ".*(\d\d:\d\d:\d\d)", "$1")

; All I do here is look for the time part of the date/time strign and extract it

; We could also use

$MorningNotification = StringMid($MorningNotification, 12)

; or

$MorningNotification = StringRight($MorningNotification, 8)

; I did say there were lots of ways to do this!!

- 5. And so the loop itself. We test if the flag was set by the inifile and then whether the time is correct. If these both match then we simulate running your functions. Again I have no idea what these functions do, but I have assumed that they amend the flags so that the script toggles between the morning and evening functions - hence the resetting of the flags which I have assumed takes place within the functions. :(

- 6. "Just for testing <<<<<<<<" These lines were just to print out the time each time we went through the loop so I could check that it worked correctly. You can remove them without problem. :rip:

That is a clear an explanation as I can give of the changes I made to your script. Without more details of the rest of the script (which you have said is confidential) I cannot really help any more. I hope you understand that it is extremely difficult to offer advice in coding when you have litle or no idea of what is happening outside the very limited snippet of code that you have provided. :)

M23

P.S. A note to other readers - do NOT send PMs asking for more help on an open thread. It is against the Forum Rules - just use the thread itself. If you are receiving help from one of the longer-term members they are very unlikely to just drop you without any explanation - and we do keep an eye on the threads to which we have contributed. Have you ever checked out the "Content I Follow" link? :(

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Hey,

Thank you very much Melba23, Sorry for the PM I am just used to forums where someone posts then they vanish :D

You explaned that wonderfully, I understand that quite well and I never knew about the StringRight/Mid...etc

I added:

$Date = @MDAY & "/" & @Mon & "/" & StringRight(@YEAR, 2)
which is pretty neat however I'm sure you're going to say there is already a way to do a short date like: 17/11/11

I have I think one more thing to add and that is some sort of onscreen Log what updates the macros running, I dont mind if I have to have two macros running... for example

Macro 1 sends text to a text file: "log.txt" and macro 2 reads and disaplys

Any suggestions on how to do this? I don't want to have one of those GUI's what are kinda ugly I'd like something neat IRC style or something like that, I tried looking through the documentation for some nice gui's but cant find out how to do it

Link to comment
Share on other sites

  • Moderators

XxXGoD,

Glad you liked it - it took long enough to type! :rip:

Do not use that short date variable in _DateAdd - you need the full YYYY/MM/DD version in there. :oops:

As to the GUI, I woudl have though that a GUI with a BitOR($WS_POPUPWINDOW, $WS_CAPTION) style would serve nicely - it just has a closure [X]. And then you could use a list to fill it - appending the data to the list as required. :D

Give it a try - you know where we are if you run into trouble. And we will not run away overnight. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Liked it, I loved it and I appreciate it a lot, I was in awe when reading it to see how much effort you went to :D

The reason I'm using the short date variable as shown is because it needs to be sent into a program autoit is interacting with.

ClipPut($Date)
    ClipGet()
    Send("^v")

What do you mean by "a list fill it"

Edited by XxXGoD
Link to comment
Share on other sites

  • Moderators

XxXGoD,

I mean something like this: :D

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListBox.au3>

; Create the GUI wioth just an [X]
$hGUI = GUICreate("Test", 200, 200, Default, Default, BitOR($WS_POPUPWINDOW, $WS_CAPTION) )

; Create list within it
$hList = _GUICtrlListBox_Create($hGUI, "", 0, 0, 200, 300, BitOR($LBS_NOSEL, $WS_VSCROLL))

GUISetState()

; These are just for the autofill
$iBegin = TimerInit()
$iItemCount = 0

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

    ; This autofills the list every second, but the same code could used to add lines when you wish
    If TimerDiff($iBegin) > 1000 Then
        ; Increase the item count
        $iItemCount += 1
        ; Insert the item into the list - -1 means at the end
        _GUICtrlListBox_InsertString($hList, "Item " & $iItemCount, -1)
        ; Now get the count of lines in the list
        $iLineCount = _SendMessage($hList, 0x18B, 0, 0) ; $LB_GETCOUNT
        ; And scroll down to teh last once
        _SendMessage($hList, 0x197, $iLineCount - 1, 0) ; $LB_SETTOPINDEX
        ; This  is just for the autofill timer
        $iBegin = TimerInit()
    EndIf

WEnd

As you can see it fills up and autoscrolls down quite nicely. :oops:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

You sir are a genius, I'll post a finished macro with the exception of parts once its done again you'll prolly find parts done poorly but at the moment it's working much better than I expected.

I have it running 24/7 on a VM so it does what I need it to do at 05:30 in the morning and 17:30 in the afternoon saves me several hours of work.

Link to comment
Share on other sites

Trying to add some more code for the GUI but it's erroring out all the time.

$hGUI = GUICreate("test", 720, 390, 1500, Default, BitOR($WS_POPUPWINDOW, $WS_CAPTION)) ; Works fine
$hList = _GUICtrlListBox_Create($hGUI, "", 0, 0, 720, 490, BitOR($LBS_NOSEL, $WS_VSCROLL)) ; Works fine

$hStatus = _GUICtrlStatusBar_Create($hGUI) ; Error
_GUICtrlStatusBar_SetMinHeight($hStatus, 20) ; Error
$hPicture = GUICtrlCreatePic("", 580, 0, 150, 50) ; Error

GUISetState() ; Works fine

I'm trying to make a status bar apear (I don't know if I can intergrate that into my script yet.

As for the CreatePic I am trying to put a logo in the top right of the GUI and hyperlink it eventually.

Edited by XxXGoD
Link to comment
Share on other sites

  • Moderators

XxXGoD,

What makes you think that you are not creating a status bar or a pic control? :D

Both work fine for me - try adding a bit of text or colour to them and see if it works then: :rip:

$hStatus = _GUICtrlStatusBar_Create($hGUI, -1, "Hi there!")
_GUICtrlStatusBar_SetMinHeight($hStatus, 20)
$hPicture = GUICtrlCreatePic("C:\Program Files\AutoIt3\Examples\GUI\AdvancedImagesGreen.bmp", 580, 0, 150, 50)

Be careful about putting the pic control over the list control - AutoIt does not like overlapping controls very much. I would suggest either lowering the top or shrinking the width of the list to avoid overlap if you can. :oops:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Hey,

I don't know I was trying to get it to add and I was getting errors. I'll try the "Hi There" part in a second and yeah I can get the picture bit working now.

In the following code, I've removed a bunch of parts but basically why do the notifications work but not the actual "DataExports()" or "DECFIL()" macros.

There is also an issue with the XGLog (at bottom) the FileClose will close after writing but it doesnt re-open and add the new lines of data later on.... (I'm not at home right now but if I add the $XGLogfile = FileOpen("XG Bot Logfile.txt", 1) part to the top of that function surely it should work then?

#include <Date.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListBox.au3>

Opt("TrayOnEventMode", 1)
Opt("TrayMenuMode", 1)
Opt("TrayAutoPause", 0)
TraySetClick(8)

$RunDECFIL = TrayCreateItem("Run DECFIL")
TrayItemSetOnEvent(-1, "DECFIL")
$RunDataExports = TrayCreateItem("Run Data Exports")
TrayItemSetOnEvent(-1, "DataExports")
$RunExit = TrayCreateItem("Exit")
TrayItemSetOnEvent(-1, "Terminate")

$hGUI = GUICreate("XG Bot", 720, 390, 1500, Default, BitOR($WS_POPUPWINDOW, $WS_CAPTION))
$hList = _GUICtrlListBox_Create($hGUI, "", 0, 0, 720, 490, BitOR($LBS_NOSEL, $WS_VSCROLL))

$XGLogfile = FileOpen("XG Bot Logfile.txt", 1)

$MorningDECFIL =  Number(IniRead(@ScriptDir & "XG Bot Settings.ini", "Morning", "DECFIL", 1))
$MorningHour =  IniRead(@ScriptDir & "XG Bot Settings.ini", "Morning", "Hours", "20")
$MorningMinutes =  IniRead(@ScriptDir & "XG Bot Settings.ini", "Morning", "Minutes", "10")
$MorningTime = $MorningHour & ":" & $MorningMinutes & ":" & "00"

$EveningDECFIL =  Number(IniRead(@ScriptDir & "XG Bot Settings.ini", "Evening", "DECFIL", 0))
$DataExports =  Number(IniRead(@ScriptDir & "XG Bot Settings.ini", "Evening", "Data", 0))
$EveningHour =  IniRead(@ScriptDir & "XG Bot Settings.ini", "Evening", "Hours", "20")
$EveningMinutes =  IniRead(@ScriptDir & "XG Bot Settings.ini", "Evening", "Minutes", "15")
$EveningTime = $EveningHour & ":" & $EveningMinutes & ":" & "00"

$SleepDelay =  IniRead(@ScriptDir & "XG Bot Settings.ini", "Developer", "Sleep Delay", "500")
$Notifications =  Number(IniRead(@ScriptDir & "XG Bot Settings.ini", "Developer", "Notifcations", 1))
$NotificationTime =  Number(IniRead(@ScriptDir & "XG Bot Settings.ini", "Developer", "Notifcation Time", 1))
$NotificationMessage =  IniRead(@ScriptDir & "XG Bot Settings.ini", "Developer", "Notifcation Message", "A macro is just about to start")

$MorningNotification = StringRegExpReplace(_DateAdd("n", -1 * $NotificationTime, @YEAR & "/" & @MON & "/" & @MDAY & " " & $MorningTime), ".*(dd:dd:dd)", "$1")
$EveningNotification = StringRegExpReplace(_DateAdd("n", -1 * $NotificationTime, @YEAR & "/" & @MON & "/" & @MDAY & " " & $EveningTime), ".*(dd:dd:dd)", "$1")

$XGDate = @MDAY & "/" & @MON & "/" & StringRight(@YEAR, 2) & " - " & @HOUR & ":" & @MIN & " - "
$ExportDate = @MDAY - 1 & "/" & @MON & "/" & StringRight(@YEAR, 2)

$iBegin = TimerInit()

XGLog("XG Bot - Started")
XGLog("AM Time: " & $MorningTime)
XGLog("PM Time: " & $EveningTime)
XGLog("AM Notification: " & $MorningNotification)
XGLog("AM Notification: " & $EveningNotification)

GUISetState()

While 1

Sleep(100)

Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
EndSwitch

If TimerDiff($iBegin) > 100 Then
$iLineCount = _SendMessage($hList, 0x18B, 0, 0) ; $LB_GETCOUNT
_SendMessage($hList, 0x197, $iLineCount - 1, 0) ; $LB_SETTOPINDEX
$iBegin = TimerInit()
EndIf

$sNow = @HOUR & ":" & @MIN & ":" & @SEC
$XGDate = @MDAY & "/" & @MON & "/" & StringRight(@YEAR, 2) & " - " & @HOUR & ":" & @MIN & " - "
$ExportDate = @MDAY - 1 & "/" & @MON & "/" & StringRight(@YEAR, 2)

If $MorningDECFIL Then
If $sNow = $MorningTime Then
XGLog("Morning DECFIL Running")
DECFIL()
XGLog("Morning DECFIL Complete")
$MorningDECFIL = 0
$EveningDECFIL = 1
EndIf

If $sNow = $MorningNotification Then
XGLog("Morning Notification Running")
NotificationWarning()
XGLog("Morning Notification Complete")
EndIf
EndIf

If $EveningDECFIL Or $DataExports Then
If $sNow = $EveningTime Then
If $DataExports Then
XGLog("Evening DECFIL Running")
DECFIL()
XGLog("Evening DECFIL Complete")
$DataExports = 1
$EveningDECFIL = 0
EndIf
If $DataExports Then
XGLog("Evening Data Export Running")
DataExports()
XGLog("Evening Data Export Complete")
EndIf
EndIf

If $sNow = $EveningNotification Then
XGLog("Evening Notification Running")
NotificationWarning()
XGLog("Evening Notifications Complete")
EndIf
EndIf

WEnd

Func DECFIL()

;Code Removed
Sleep(100)

EndFunc   ;==>DECFIL

Func DataExports()

;Code removed
Sleep(100)
EndFunc   ;==>DataExports

Func NotificationWarning()
Sleep(1000)
$MousePos = MouseGetPos()
ToolTip($NotificationMessage, $MousePos[0], $MousePos[1], "Warning", 2)
TrayTip("Warning", $NotificationMessage, 5, 2)
Sleep(50000)
ToolTip("", 0, 0, "")
EndFunc   ;==>NotificationWarning

Func XGLog($XGLog)
ConsoleWrite($XGDate & $XGLog & @CRLF)
_GUICtrlListBox_InsertString($hList, $XGDate & $XGLog, -1)
FileWrite($XGLogfile, $XGDate & $XGLog & @CRLF)
FileClose($XGLogfile) ; <-- Need fix
; Usage: XGLog("Hello")
EndFunc   ;==>XGLog

Func Terminate()
Exit 0
EndFunc   ;==>Terminate
Link to comment
Share on other sites

  • Moderators

XxXGoD,

The 2 functions both fire for me - why do you think they do not? :D

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

XxXGoD,

This could get tricky to debug as I am getting all the XGLog lines written in the list and the macros fire when I click the trayitems. :oops:

Add the following to the script to see if it is hanging somewhere - you get the currently executing line when you put your mouse over the tray icon: :rip:

Opt("TrayIconDebug", 1)

I get Line 60: Sleep(100) which is what I would expect. :D

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Thanks for your patience Melba, its much appreciated I bet you think ahh this damn kid :D lol

Do you get four XGLog lines written in the log file when you start the program?

I'll add that when I get home, I wish I could step through the macro like you can with VBA(Excel).

Could the error be happening because the macro is busy at the time the macro is supposed to start... ?

Link to comment
Share on other sites

  • Moderators

XxXGoD,

Thanks for your patience Melba, its much appreciated

I enjoy the problem solving - keeps the little grey cells active! :D

Do you get four XGLog lines written in the log file when you start the program?

I get 5: the "Started" and then the 4 times. :rip:

I wish I could step through the macro

Well, all I have done is to check that the trayitems call the correct functions - as I do not have the macros themselves I can do no more. :oops:

But you can see which lines are being actioned. If you download the Beta version of AutoIt3Wrapper then you can use syntax like thisL

#AutoIt3Wrapper_run_debug_mode=y

$test = 1
#AutoIt3Wrapper_run_debug=Off
$test = 2
#AutoIt3Wrapper_run_debug=On
$test = 3
#AutoIt3Wrapper_run_debug=Off
$test = 4

which gives you this result in the SciTE console:

Line: @error-@extended: Line syntax
0001: 0-0: #AutoIt3Wrapper_run_debug_mode=y
0003: 0-0: $test = 1
0007: 0-0: $test = 3

So you can see how a section of code flows as it runs. :D

But perhaps we can leave that until we have tried the simpler methods. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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