Leaderboard
Popular Content
Showing content with the highest reputation on 03/07/2019 in all areas
-
Don't know why it's not working for you, but you can either use: a. _ArrayUnique, to only show unique results (example in the code below. Or b. Just add unique links only #include <Array.au3> #include <IE.au3> Local $aMoreInfo[0] Local Const $ie_newtab = 0x0800 Local $oIE = _IECreate("http://repl.flexlink.com/os/products.htm?clicktype=A", 1) _IELoadWait($oIE, 1, 1) Local $oLinks = _IETagNameGetCollection($oIE, "a") If IsObj($oLinks) Then For $oLink In $oLinks If $oLink.title = "More information" Then If _ArraySearch($aMoreInfo, $oLink.href) = -1 Then _ArrayAdd($aMoreInfo, $oLink.href) EndIf Next EndIf _ArrayDisplay($aMoreInfo) ;~ Local $aUniqueLinks = _ArrayUnique($aMoreInfo) ;~ _ArrayDisplay($aUniqueLinks)2 points
-
You might find it useful to keep Unicode letters and digits as well. Prepend (*UCP) at the pattern to make \w match any Unicode letter or digit or _, and \d any Unicode digit. Fictuous example: Local $title = "영국여사 조쉬엄마의 첫 치맥 먹방 도전!?! ◓ ♬♫\ghuo .*. ỸἇἮὤ ∑ [ທຊکڄຮ] (+조쉬 사춘기 썰)" Local $titley = StringRegExpReplace($title, "(*UCP)[^\w\h-\.!\()]", "") MsgBox(0, "", $titley) If ever you need to filter in or out specific languages or types of Unicode codepoint, you may find the \p<something> construct pretty handy. See help under StringRegexp() for basics or the full official PCRE1 doc https://www.pcre.org/original/doc/html/pcrepattern.html2 points
-
A simple regexp can't do that this way. Not only patterns (named or not) only live while the regex engine scans the subject. PCRE (at least PCRE1 which is implemented in current AutoIt versions) has no support for substitution. The Replace part is an AutoIt construct which can only recognize $1, $2, $3, ... (or equivalently \1, \2, \3, ...) as a sugar for successive capturing groups. Due to the way regex works (try to match the pattern by scanning the subject left to right), you can't exchange the role of $1 and $2 depending on their content or order of matching. Yet there is a simple possibility: give up duplicate pattern numbering! Local $aDate = ["2014/04", "2014-04", "04-2014", "04\2014", "04/2014", "2014\04"] Local $DATE_PATTERN = "(\d{4})[-\/\\](\d{2})|(\d{2})[-\/\\](\d{4})" For $d In $aDate ConsoleWrite($d & " --> " & StringRegExpReplace($d, $DATE_PATTERN, "$1$4-$2$3") & @LF) Next Forcing capture of distinct fix-length subpatterns works, since what isn't matched yields an empty string, which we may concatenate transparently.2 points
-
I create purebasic language functions similar to autolt I let the members of the furom improve the concept with a beginning of idea I included some functions it works very well for the moment I let you modify and give your ideas thank add in your purebasic source code (IncludeFile "AutoitCoding.PB") and program as on autolt it remains full of function to program the concept is to improve the languages remain similar AutoIt Code : 415 kb with UPX Interpreted Language $Time=TimerInit() MsgBox (16,"Autoit",StringIsDigit ("123a")) MsgBox (16,"Autoit",StringIsDigit ("123")) $VarBin=StringToBinary("Hello") MsgBox (64,"Autoit",@Hour) MsgBox (64,"Autoit",@TempDir) MsgBox (64,"Autoit",$VarBin) MsgBox (64,"Autoit",BinaryToString($VarBin)) MsgBox (0,"Autoit",StringLen ("bonjour")) MsgBox (1,"Autoit",@DesktopCommonDir) MsgBox (2,"Autoit",@ProgramFilesDir) Sleep (1000) MsgBox (3,"Autoit",FileGetSize("test.pb")) MsgBox (4,"Autoit",Random (1,10,1)) $Variable=FileGetSize("test.pb") MsgBox (0,"Autoit",$Variable) ;InetGet ("https://jardinage.lemonde.fr/images/dossiers/2018-07/language-chat-170054.jpg","image.jpg") MsgBox (0,"Autoit",StringReplace ("Hella","a","o")) MsgBox (0,"Autoit",StringTrimLeft ("Hello",1)) MsgBox (0,"Autoit",StringTrimRight("Hello",1)) If FileExists ("test.pb") Then MsgBox(0,"Title","the file exist") Else MsgBox(0,"Title","the file does not exist") EndIf MsgBox(0,"Autoit",FileGetTime ("UPX.exe",1,1)) MsgBox(0,"Autoit",FileGetTime ("UPX.exe",1,1)) MsgBox(0,"Autoit",FileGetVersion("UPX.exe")) MsgBox(0,"Autoit",TimerDiff($Time)) If IsAdmin() Then MsgBox(0,"Autoit", "IsAdmin You are administrator !.") Else MsgBox(0,"Autoit", "IsAdmin You are not administrator !.") EndIf MsgBox(0,"Autoit",String (10)) MsgBox(0,"Autoit",Ping ("google.fr")) ;################## StringSplit $Split = StringSplit("ABC*DEFG*JKL","*") MsgBox(0,"Autoit",$Split[1]) MsgBox(0,"Autoit",$Split[2]) MsgBox(0,"Autoit",$Split[3]) ;################## StringSplit IniWrite("setup3.ini", "General", "Title", "AutoIt") $inivar= IniRead("setup3.ini", "General", "Title",Default) MsgBox (0,"Autoit",$inivar) PureBasic Code : Executable Size : 12 kb with UPX Real Compiler ( Your source code is secure ) IncludeFile "AutoitCoding.PB" ;MsgBox (16,"Autoit",StringIsDigit ("123a")) ;StringIs.PB be sure to activate it in AutoitCoding.PB this increases the size of the executable ;MsgBox (16,"Autoit",StringIsDigit ("123")) ;StringIs.PB be sure to activate it in AutoitCoding.PB this increases the size of the executable ;InetGet ("https://jardinage.lemonde.fr/images/dossiers/2018-07/language-chat-170054.jpg","image.jpg") ; InetFonctions be sure to activate it in AutoitCoding.PB this increases the size of the executable ;##################Mouse Dim xy (1) MouseGetPos (xy()) Debug "Pos : X : "+xy(0)+" Y : "+xy(1) Debug WinGetHandle ("Notepad") ;################## ProcessList Dim ProcessName.s(1) ; Create array Dim PID.s(1) ; Create array ProcessList (ProcessName (),PID ()) MsgBox(0,"Autoit","ProcessName: "+ProcessName(10)+" YourPID: "+PID (10)) ;################## ProcessList For i = 0 To ArraySize (ProcessName ()) Debug ProcessName (i)+" PID : "+ PID (i) Next MsgBox (0,"Autoit",ProcessorArch ()) Time$=TimerInit() VarBin$=StringToBinary("Hello") MsgBox (0,"Autoit",ComSpec ()) MsgBox (64,"Autoit",GetCPUName ()) MsgBox (64,"Autoit",CpuSerialNumber ()) MsgBox (64,"Autoit",AutoItVersion ()) MsgBox (64,"Autoit","Hello"+CRLF ()+"Hello") MsgBox (64,"Autoit",Hours ()) MsgBox (64,"Autoit",TempDir ()) MsgBox (64,"Autoit",VarBin$) MsgBox (64,"Autoit",BinaryToString(VarBin$)) MsgBox (48,"Autoit",StringLenS ("bonjour")) MsgBox (1,"Autoit",DesktopCommonDir ()) MsgBox (2,"Autoit",ProgramFilesDir ()) Sleep (1000) MsgBox (3,"Autoit",FileGetSize("test.pb")) MsgBox (4,"Autoit",Randoms (1,10)) Variable$=FileGetSize("test.pb") MsgBox (0,"Autoit",Variable$) MsgBox (0,"Autoit",StringReplace ("Hella","a","o")) MsgBox (0,"Autoit",StringTrimLeft ("Hello",1)) MsgBox (0,"Autoit",StringTrimRight("Hello",1)) If FileExists ("test.pb") MsgBox(0,"Autoit","the file exist") Else MsgBox(0,"Autoit","the file does not exist") EndIf MsgBox(0,"Autoit",FileGetTime ("UPX.exe",1,"%mm/%dd/%yyyy %hh:%ii:%ss")) MsgBox(0,"Autoit",FileGetTime ("UPX.exe",1,"%hh:%ii:%ss")) MsgBox(0,"Autoit",FileGetVersion("UPX.exe",#FV_FileVersion)) MsgBox(0,"Autoit",TimerDiff(Time$)) If IsAdmin() MsgBox(0,"Autoit", "IsAdmin You are administrator !.") Else MsgBox(0,"Autoit", "IsAdmin You are not administrator !.") EndIf MsgBox(0,"Autoit",String(10)) MsgBox(0,"Autoit",Ping ("google.fr")) iLife = 42 If IsNumber(iLife) MsgBox(0, "", "Is Number") Else MsgBox(0, "", "Is not Number") EndIf ;################## StringSplit Dim Split.s(1) ; Create array StringSplit (split(), "ABC*DEFG*JKL", "*") MsgBox(0,"Autoit",Split(0)) MsgBox(0,"Autoit",Split(1)) MsgBox(0,"Autoit",Split(2)) ;################## StringSplit IniWrite("setup3.ini", "General", "Title", "AutoIt") inivar$= IniRead("setup3.ini", "General", "Title") MsgBox (0,"Autoit",inivar$) ;Bonus Function MsgBox(0,"Autoit",HostNameToIp ("google.fr")) there is a slight difference but nothing important I am counting on you to improve the project and add functions ! ( Disadvantage purebasic is paying you can not have all ) Functions compatible : Msgbox Sleep FileGetSize ClipPut ClipGet Randoms DirCopy DirCreate DirRemove StringReplace StringLen Add Fonctions : (11/03/2019) StringTrimLeft StringTrimRight FileCopy FileMove StringUpper StringLower Add Fonctions : (12/03/2019) StringIsFloat StringIsAlpha StringIsDigit StringReverse BinaryToString StringToBinary FileExists Msgbox ADD : MB_ICONERROR = 16 MB_ICONQUESTION = 32 MB_ICONWARNING = 48 MB_ICONINFORMATION=64 You can control the size of the executable Division of executable size by 10 ( 119 kb to 12 kb) ( I separated the functions in several file activated if necessary ) ;IncludeFile "FonctionsIncludes\StringIs.PB" I separated the functions into several activated files If necessary remove ;IncludeFile "FonctionsIncludes\InetFonctions.PB" ; I separated the functions into several activated files If necessary remove Add Functions: (20/03/2019) String IsAdmin TimerDiff (thank @JiBe) TimerInit (thank @JiBe) Ping FileGetVersion add : #FV_FileVersion #FV_FileDescription #FV_LegalCopyright #FV_InternalName #FV_OriginalFilename #FV_ProductName #FV_ProductVersion #FV_CompanyName #FV_LegalTrademarks #FV_SpecialBuild #FV_PrivateBuild #FV_Comments #FV_Language FileGetTime Flag : 0 Last modified (default) 1 Created 2 Last accessed Msgbox ADD : MB_DEFBUTTON2 = 256 Flag MB_DEFBUTTON3 = 512 Flag MB_DEFBUTTON4 = 768 Flag MB_SYSTEMMODAL = 4096 Flag MB_TASKMODAL = 8192 Flag MB_DEFAULT_DESKTOP_ONLY = 131072 Flag MB_RIGHT = 524288 Flag MB_RTLREADING = 1048576 Flag MB_SETFOREGROUND = 65536 Flag MB_TOPMOST = 262144 Flag MB_SERVICE_NOTIFICATION = 2097152 Flag Bonus Functions : HostNameToIp Add Functions: (22/03/2019) ----------------------- ADD Macros : (thank @AZJIO) DesktopCommonDir () MyDocumentsDir () ProgramFilesDir () ScriptFullPath () ScriptName () ScriptDir () ----------------------- OSVersions () Add Functions: (26/03/2019) ----------------------- ADD Macros : TempDir () Hours () Min () Sec () MDAY () MON () Years () LF () CR () CRLF () ----------------------- Functions: Floor Ceiling Stringlen ( Update :Return Number) StringlenS (Temporary function asks for reflection) Add Functions: 06/04/2019 Macro : AutoItVersion () ; it's for fun haha SystemDir () UserProfileDir () AppDataDir () ComSpec () ; Bug fixed UserName () LogonServer () HomeShare () HomeDrive () HomePath () HomeDrive () LocalAppDataDir () UserProfilDir () Bonus Macro : ProcessorsThreadNumber () Functions : Change of procedure in macro (optimization) Optimization of msgbox Fix a constant messagebox Beep StringSplit ( thank @AZJIO ) FileGetAttrib Bonus features : CpuSerialNumber() GetCPUName() Add Functions: 16/04/2019 Optimization UserName () Optimization CpuName () change of the name of the function GetCpuName () ProcessList () : Return PID Return ProcessName ProcessClose (); PID or ProcessName IniWrite () IniRead () Macro : ProcessorArch () DesktopHeights () DesktopWidths () DesktopRefresh () DesktopDepths () AutoItX64 () Add Functions: 19/04/2019 Functions: ( THANK @AZJIO ) IniDelete () DriveGetType() DriveGetLabel() DriveGetSerial() DriveSpaceFree() DriveSpaceTotal() DriveGetFileSystem() Add Functions: 30/04/2019 Minor bug fixes : DriveGetLabel() fixed function thank AZJIO DriveGetFileSystem() fixed function thank AZJIO ADD Functions : BlockInput () thank AZJIO FileGetShortName() FileGetLongName() MouseGetPos () WinGetHandle () Sqrt () Add Functions: 23/05/2019 ProcessExists () ClosePID () IniReadSectionNames() WinWait ();2 in 1 finds the same handle with a title or a partial text WinExists ();2 in 1 finds the same handle with a title or a partial text WinWaitClose ();2 in 1 finds the same handle with a title or a partial text WinWaitActive ();2 in 1 finds the same handle with a title or a partial text WinGetProcess ();2 in 1 finds the same handle with a title or a partial text HandleToHex ();x86 management Imitate autoit HexToHandle () ADD Macro : ScriptDir () Complete rewrite of functions with optimization : ProcessList () ProcessClose () WinGetHandle () Delete function : CountProcess () FileGetSize () ;Old function All the old function are put in the OldFonctions.pb file Add Fonctions : (18/07/2019) WinMinimizeAll() Winkill ();title or a partial text SearchHandle ();Bonus function to simplify your life look for the handle of a window with a title or a text patiel WinSetStade ();title or a partial text or Handle #SW_HIDE = 0 #SW_SHOW = 5 #SW_MINIMIZE = 6 #SW_MAXIMIZE = 3 #SW_RESTORE = 9 #SW_DISABLE = 4 #SW_ENABLE = 1 WinActive () Title or Handle WinList (); With the zero flag you can see the invisible windows and the flag 1 for visible windows more simplify than the original Default option : VisibleWindow = 1 WinSetTitle () Title or Handle Update : WinExists () Handle Management WinGetProcess () Handle Management Add Fonctions : (09/04/2020) IsHWnd (Return 0 or 1) PixelGetColor (x,y) WinSetTrans ;title or a partial text 0 To 255 Optimization of the msgbox function smaller and faster code (old msgbox function put in oldfunction.pb) Msgbox Fix minors bug MouseMoveSpeed Function under construction MouseClick Function under construction HibernateAllowed() Suspend() ShutdownPrivilege() Shutdown (Flag) #SD_LOGOFF=0 #SD_SHUTDOWN=1 #SD_REBOOT=2 #SD_FORCE=4 #SD_POWERDOWN=8 #SD_FORCEHUNG=16 #SD_STANDBY=32 #SD_HIBERNATE=64 ProcessSetPriority (Process.s, priority) #PROCESS_LOW =0 #PROCESS_BELOWNORMAL =1 #PROCESS_NORMAL =2 #PROCESS_ABOVENORMAL =3 #PROCESS_HIGH =4 #PROCESS_REALTIME =5 EnvSet () EnvGet () FileRecycleEmpty() add file in GuiExampleAutoitCoding (Hybrid Code) example method for window GuiExampleAutoitCoding (Hybrid Code) update files start of code to convert autoit to pb in construction Add Fonctions : (01/12/2022) #PB_OS_Windows_11 code upgrade OSVersion() WinActivate(hWnd) adding a new function thank @AZJIO #MB_SERVICE_NOTIFICATION1 I changed the name not compatible with purebasic 6 I added a 1 (msgbox) DriveGetLabel bugfix for version 6 of purebasic DriveGetFileSystem bugfix for version 6 of purebasic ProcessorArch () optimization of the function and addition of flag for Purebasic 6 ARM64 ARM ProcessorArch () the old function is moved to the file Old Functions.pb ProcessorArch () bug fixed stack has been corrupted ProcessorArch () add to file Example.pb InitNetwork remove Deprecated function HostNameToIp optimization of the function and addition of flag 0 HostNameToIp the old function is moved to the file Old Functions.pb Ping () optimization of the function and addition of flag and timeout Ping () fix minor bug flag 0 return ping flag 1 return PingStatus also returns errors 1 = Host disconnected 2 = Host unreachable 3 = Wrong destination 4 = Other errors flag 2 return DataSize timeout = 4000 like the original the setting support written web address and ip address (www.google.com or 127.0.0.1) Ping () the old function is moved to the file Old Functions.pb remove ExampleGui I moved the files in the same folder it is more manageable Add Fonctions : (05/09/2024) New Functions Added: DllOpen Implemented a new function DllCall Implemented a new function DllClose Implemented a new function iniWrite: Implemented a new function for writing to INI files. iniRead: Introduced a revised version of the basic function for reading INI files. CpuIdentifier() Combine some values to create a pseudo-unique identifier Function Rewrite: iniDelete: Updated the iniDelete function to enhance management of sections and keys. Ping improve performance Compatibility improved PureBasic 6.11 LTS Legacy Code Management: Moved obsolete functions to Oldfunctions.pb to streamline current codebase. Moved Macro Username to Oldfunctions.pb Moved Macro Blockinput to Oldfunctions.pb Bug fix : (05/09/2024) Bug fix : corrected IniRead procedure to return string instead of numeric value UPX official website to compress the executable : https://upx.github.io/ PureAutoitInclude.7z1 point
-
Create DLL to Start script if script process closed
FrancescoDiMuro reacted to Jos for a topic
Why? A script can also load at startup. Either way: This is a forum about AutoIt3 scripting not C++ DLL creation. ... and to do this with a script is pretty easy. Jos1 point -
How to pass parameters from xml to auto it script? - (Moved)
Fr33b0w reacted to FrancescoDiMuro for a topic
@Sankesh You can compile your executable as you wish, which you can then copy wherever you want. You don't need to have AutoIt installed on every VM; you just need it on your development one1 point -
@wirebu, what you are asking is not trivial, to put mildly. Nox is not a native Windows application (built with the QT5 framework) hence very unlikely to be automated successfully (if at all), especially in the background. given the powerful _IE* and WebDriver UDF, i would recommend exploring the web browser approach. that is understood, and solutions to that exist - run the browser-based script on a dedicated virtual machine running its own VPN client, for example.1 point
-
Pull line data from text file and subsequent line
FrancescoDiMuro reacted to mikell for a topic
The following assumes that there can be several pdf/user couples present in the .txt file #Include <Array.au3> $txt = "Files opened remotely on servername matching N:\share\Updated Monthly Schedules:" & @crlf & _ @crlf & _ "[10429393] N:\share\Updated Monthly Schedules\Monthly Schedules and Available Shift 2019" & @crlf & _ " User: STEPHENG" & @crlf & _ " Locks: 0" & @crlf & _ " Access: Read " & @crlf & _ "[10429406] N:\share\Updated Monthly Schedules\Monthly Schedules and Available Shift 2019" & @crlf & _ " User: STEPHENG" & @crlf & _ " Locks: 0" & @crlf & _ " Access: Read " & @crlf & _ "[10429409] N:\share\Updated Monthly Schedules\Monthly Schedules and Available Shift 2019\03March 2019" & @crlf & _ " User: STEPHENG" & @crlf & _ " Locks: 0" & @crlf & _ " Access: Read " & @crlf & _ "[10429413] N:\share\Updated Monthly Schedules\Monthly Schedules and Available Shift 2019\03March 2019" & @crlf & _ " User: STEPHENG" & @crlf & _ " Locks: 0" & @crlf & _ " Access: Read " & @crlf & _ "[10430671] N:\share\Updated Monthly Schedules\Monthly Schedules and Available Shift 2019\03March 2019\wal-mart supercenter 16.pdf" & @crlf & _ " User: STEPHENG" & @crlf & _ " Locks: 0" & @crlf & _ " Access: Read " & @crlf & _ "[10568007] N:\share\Updated Monthly Schedules\Monthly Schedules and Available Shifts 2017\June 2017" & @crlf & _ " User: ERICKT" & @crlf & _ " Locks: 0" & @crlf & _ " Access: Read " & @crlf & _ "[10430671] N:\share\Updated Monthly Schedules\Monthly Schedules and Available Shift 2019\03March 2019\wal-mart supercenter 17.pdf" & @crlf & _ " User: ERICKT" & @crlf & _ " Locks: 0" & @crlf & _ " Access: Read " & @crlf & _ "[10568013] N:\share\Updated Monthly Schedules\Monthly Schedules and Available Shifts 2017\June 2017" & @crlf & _ " User: ERICKT" & @crlf & _ " Locks: 0" & @crlf & _ " Access: Read" ; Msgbox(0,"", $txt) Local $s, $a = StringRegExp($txt, '([^\\]+pdf)[^:]+:\h*(\N+)', 3) ;_ArrayDisplay($a) For $i = 0 to UBound($a)-2 step 2 $s &= $a[$i] & " -- " & $a[$i+1] & @crlf Next Msgbox(0,"", $s)1 point -
If you're going to delete elements of an array in a loop, you have to run the loop in reverse. Instead of For $x = 1 To UBound($array) - 1 Use this For $x = UBound($array) - 1 To 1 Step - 11 point
-
You need to go backwards in your loop not forward using Step - 1, although you could also just use: #include <Array.au3> Local $aProcesses = ProcessList("svchost.exe") _ArrayDisplay($aProcesses)1 point
-
@Subz change your code, you still have $iTagInstance += 1 misplaced1 point
-
@danish_draj & @Fr33b0w, Please only report the thread and refrain from comments. Jos1 point
-
@Deye, nice version, simple and concise. ... I post my last version too with some bonus extra: I've rearranged a bit the parameters sequence so to be able to pass not only the year and the month, but also optionally the day. In this way you can search for a weekday starting from any date. If you want to find the instance of a weekday starting from a given date instead of the beginning of the month, just pass also the optional starting day as fifth parameter. The function will return the date of nth weekday you requested. Note if you want you can also search backward instead of forward, just pass a negative instance. This can be useful to find the last weekday of a month for example, just pass the last day of the month as starting date and search backward by passing -1 as instance. I think can be of use sometime... #include <date.au3> Example() Func Example() ; just to simplify the association between the weekdays and the corresponding ISO numbers Local Enum $Monday = 1, $Tuesday, $Wednesday, $Thursday, $Friday, $Saturday, $Sunday ; (1=monday ... 7=sunday) ConsoleWrite('The first Sunday of August is ') ConsoleWrite(_DateTimeFormat(_DateFindWeekDay($Sunday, 1, @YEAR, 8), 1) & @CRLF) ConsoleWrite('The last Sunday of the year is ') ConsoleWrite(_DateTimeFormat(_DateFindWeekDay($Sunday, -1, @YEAR, 12, 31), 1) & @CRLF) ; the following resulting date falls into the next month, so the @extended flag is setted to 1 ConsoleWrite('The fifth Friday of February is ') Local $TargetDate = _DateFindWeekDay($Friday, 5, 2019, 2) Local $extended = @extended ConsoleWrite(_DateTimeFormat($TargetDate, 1) & @TAB & "@extended: " & $extended & @CRLF) ConsoleWrite('The last Monday of this century will be on ') ConsoleWrite(_DateTimeFormat(_DateFindWeekDay($Monday, -1, 2099, 12, 31), 1) & @CRLF) ConsoleWrite('The first Sunday of my life was on ') ConsoleWrite(_DateTimeFormat(_DateFindWeekDay($Sunday, 1, 1962, 5, 2), 1) & @CRLF) EndFunc ;==>Example ; #FUNCTION# ==================================================================================================================== ; Name ..........: _DateFindWeekDay ; Description ...: Find a date by counting a number of weekdays forward or backward starting from passed date ; Syntax ........: _DateFindWeekDay([$iWeekDay = DOW_ISO[, $iInstance = 1[, $iYear = @YEAR[, $iMonth = @MON[, $iDay = 1]]]]]) ; Parameters ....: $iWeekDay - [optional] An integer value. the weekday you want to find (1=Monday...7=Sunday) default is doday's weekday ; $iInstance - [optional] An integer value. the wanted instance of WeekDay. Default is 1. ; $iYear - [optional] An integer value. the year from which to start counting. Default is @YEAR. ; $iMonth - [optional] An integer value. the month from which to start counting @MON. ; $iDay - [optional] An integer value. the day from which to start counting. Default is 1 (starting of month). ; Return values .: The target date in the format "YYYY/MM/DD" ; Remark: If target date falls outside the starting month, the @extended flag is setted to 1 ; Author ........: Chimp ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: _DateFindWeekDay(7, 1) ; Finds the first Sunday of current Month ; =============================================================================================================================== Func _DateFindWeekDay($iWeekDay = _DateToDayOfWeekISO(@YEAR, @MON, @MDAY), $iInstance = 1, $iYear = @YEAR, $iMonth = @MON, $iDay = 1) Local $iDirection = ($iInstance < 0 ? -1 : 1), $aTarget, $aDummyTime Local $iWeekDayOfDate = _DateToDayOfWeekISO($iYear, $iMonth, $iDay) - 1 ; WeekDay (0 to 6 where 0=Monday) Local $iDaysToSkip = Mod($iDirection * 7 + ($iWeekDay - 1 - $iWeekDayOfDate), 7) + (($iInstance + -1 * $iDirection) * 7) _DateTimeSplit(_DateAdd('D', $iDaysToSkip, $iYear & '/' & $iMonth & '/' & $iDay), $aTarget, $aDummyTime) Return SetExtended($iYear <> $aTarget[1] Or $iMonth <> $aTarget[2], StringFormat("%04i/%02i/%02i", $aTarget[1], $aTarget[2], $aTarget[3])) EndFunc ;==>_DateFindWeekDay1 point
-
Thanks Chimp, @ Sticking back to topic, This is should be my last version for this function #include <Date.au3> ; 5 instances of Friday begining of the first instace DaysInMonth of February 2019 should return "Friday, March 1, 2019" $YEAR = @YEAR $February = 2 $Friday = 6 $Monday = 2 For $Instance = 1 To 5 $Date = _DateDayInMonth_Istance($YEAR, $February, $Friday, $Instance) ConsoleWrite("Instance " & $Instance & " - " & _DateTimeFormat($Date, 1) & @LF) $Date = _DateDayInMonth_Istance($YEAR, $February, $Monday, $Instance) ConsoleWrite("Instance " & $Instance & " - " & _DateTimeFormat($Date, 1) & @LF) ConsoleWrite(@LF) Next Func _DateDayInMonth_Istance($iYear = @YEAR, $iMonth = @MON, $iWeekDay = @WDAY, $iInstance = 1) $iWeekDay -= _DateToDayOfWeek($iYear, $iMonth, 1) - 8 Return _DateAdd("d", ($iInstance * 7) - 7, StringFormat("%04i/%02i/%02i", $iYear, $iMonth, $iWeekDay + ($iWeekDay > 7 ? -7 : 0))) EndFunc ;==>_DateDayInMonth_Istance Deye1 point
-
Ahhh, I understand now, thank everyone1 point
-
https://www.autoitscript.com/forum/topic/10198-check-for-capslock-and-turn-off-so-lowercase/1 point
-
I needed a program that could count down to xx days. I found lots of count downer's, but common for them all was that I needed to know the end date, but what I needed was one where I could just add the amount of days. So I ended up creating my own count down, that could do just that. Now I would like to share what I ended up with. I did borrow some of the count down code from this nice count down Stylish Countdown GUI by @billthecreator So what can this countdown do? 1. Countdown to a specific day, that can be chosen either by the amount of days to count down to, or by choosing a date. 2. Edit an existing event. 3. Delete an existing event. 4. On mouse over the Event, the event description is shown as a tip. 5. Play a sound when time is up (if enabled for the event). 6. Show a popup when time is up (if enabled for the event), the popup text is the event description. 7. Save an event as default, so it can be reused. 8. Can be pinned in place, so the gui is unmovable. 9. Can remember the last GUI position (If chosen in the settings) 10. Uses colors on days / time, Black, Green, Yellow and Red. When Less than 5 days to event, the days will turn Red, 6 to 10 days Yellow, 11+ Green The time will change to Green when 0 days and 23 to 13 hours left, Yellow when 12 to 7 hours and Red from 5 to 0, else it's Black When the time is up, the Event name label background will change to Yellow and the text to Red When adding/Editing/Deleting an event the GUI is updated, not by restarting the program, but by deleting and recreating the events. When an event time is up, the event is set as disabled - but will still exist in the event ini file, but it won't be loaded into the GUI when the countdown'er is started. The event can be edited, and restarted or deleted permanently. Some screenshots: #include <Date.au3> #include <ColorConstants.au3> #include <Array.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <ComboConstants.au3> #include <DateTimeConstants.au3> #include <EditConstants.au3> #include <String.au3> #include <GuiComboBox.au3> #include <MsgBoxConstants.au3> #include <WinAPIDlg.au3> #include <Sound.au3> #include <GuiListBox.au3> #include <WinAPISysWin.au3> Opt("GUIOnEventMode", 1) Opt('MustDeclareVars', 1) Opt('GUIResizeMode', $GUI_DOCKALL) ; To prevent ctrls to move when we add a new event OnAutoItExitRegister('MenuItem_ExitClick') ; To save pos at closedown, if savepos is enabled Global $g_iSecs, $g_iMins, $g_iHours, $g_iDays ; Get settings Global $g_sSetFile = @ScriptDir & '\Settings.ini' Global $g_sEventFile = @ScriptDir & '\Events.ini' Global $g_iMaxEvents = IniRead($g_sSetFile, 'Settings', 'MaxEvents', 6) ; Max Number of events Global $g_bPin = StringToType(IniRead($g_sSetFile, 'Settings', 'Pin', False)) ; Pin in place, GUI Can't be moved Global $g_bRemember = StringToType(IniRead($g_sSetFile, 'Settings', 'Remember', False)) ; Remember last position and start at that pos Global $g_iGuiLeft = IniRead($g_sSetFile, 'settings', 'posx', -1) ; Gui Left pos (x) Global $g_iGuiRight = IniRead($g_sSetFile, 'settings', 'posy', -1) ; Gui right pos (y) Global $g_sSoundFile = IniRead($g_sSetFile, 'Settings', 'SoundFile', @WindowsDir & '\media\tada.wav') Global $g_bSoundPlay = StringToType(IniRead($g_sSetFile, 'Settings', 'SoundPlay', True)) Global $g_bPopup = StringToType(IniRead($g_sSetFile, 'Settings', 'popup', True)) ; Do a popup window with event description Global $g_bStartWithWin = StringToType(IniRead($g_sSetFile, 'Settings', 'StartWithWin', True)) ; If the prog should start with windows ; Check if the gui should start at last saved position If $g_bRemember = False Then $g_iGuiRight = -1 ; Default Screen center $g_iGuiLeft = -1 ; Default Screen center EndIf ; Creates an array to hold the end dates of the event(s), it's State (Enabled) and the SectionName of the event. ; this array we uses to calc the countdown, and to prevent the need to keep reopen the event ini file, to get the ; enddate of a given event. Global $g_aEventData[1][3] = [['EndDate', 'Enabled', 'SectionName']] ; Get events Global $g_aEvents = IniReadSectionNames($g_sEventFile) ; Check if we have any Events If Not IsArray($g_aEvents) Then ; If we don't have any events, we creates the array with 1 and Null, 1 to be used to create an empty gui ; Null so we know that there isn't any events Global $g_aEvents[2] = [1, Null] EndIf ; call the EventOnLoad function EventOnLoad() Global $g_idLbl_Days[$g_iMaxEvents + 1], _ $g_idLbl_Hrs[$g_iMaxEvents + 1], _ $g_idLbl_Min[$g_iMaxEvents + 1], _ $g_idLbl_Sec[$g_iMaxEvents + 1], _ $g_idLbl_Event[$g_iMaxEvents + 1] Global $g_iSpace = 80 Global $g_iGuiHeight = ($g_iSpace * $g_aEvents[0]) + 8 #Region ### START Koda GUI section ### Form=D:\Profil\Rex\ISN AutoIt Studio\Projects\Countdown Days\GUI\hCountdownDays.kxf Global $hCountdownDays = GUICreate("CountDown Days", 136, $g_iGuiHeight, $g_iGuiLeft, $g_iGuiRight, $WS_POPUP, $WS_EX_TOOLWINDOW) ; Gui menu Global $hCountdownDayscontext = GUICtrlCreateContextMenu() Global $MenuItem_EventHandling = GUICtrlCreateMenu("Event(s)", $hCountdownDayscontext) Global $MenuItem_AddEvent = GUICtrlCreateMenuItem("Add", $MenuItem_EventHandling) GUICtrlSetOnEvent(-1, "MenuItem_AddEventClick") Global $MenuItem_EditEvent = GUICtrlCreateMenuItem("Edit", $MenuItem_EventHandling) GUICtrlSetOnEvent(-1, "MenuItem_EditEventClick") Global $MenuItem_DeleteEvent = GUICtrlCreateMenuItem("Delete", $MenuItem_EventHandling) GUICtrlSetOnEvent(-1, "MenuItem_DeleteEventClick") Global $MenuItem_Settings = GUICtrlCreateMenuItem("Settings", $hCountdownDayscontext) GUICtrlSetOnEvent(-1, "MenuItem_SettingsClick") Global $MenuItem_Pin = GUICtrlCreateMenuItem("Pin in Place", $hCountdownDayscontext) GUICtrlSetOnEvent(-1, "MenuItem_PinClick") Global $MenuItem_Exit = GUICtrlCreateMenuItem("Exit", $hCountdownDayscontext) GUICtrlSetOnEvent(-1, "MenuItem_ExitClick") GUISetBkColor(0x4E4E4E) Global $idLbl_Move = GUICtrlCreateLabel("", 1, 1, 134, 12, $SS_CENTER, $GUI_WS_EX_PARENTDRAG) GUICtrlSetFont(-1, 6, 400, 0, "MS Sans Serif") GUICtrlSetBkColor(-1, 0x808080) ; Create a label to frame the gui, so it don't look to flat Global $idFrame = GUICtrlCreateLabel('', 0, 0, 136, $g_iGuiHeight, BitOR($SS_SUNKEN, $WS_DISABLED, $SS_SIMPLE)) If $g_aEvents[1] = Null Then UpdateGui(False) ; Update Countdown GUI Else UpdateGui(True) ; Update Countdown GUI EndIf ; check if we needs to tick the pin, and disable the Move label If $g_bPin = True Then GUICtrlSetState($MenuItem_Pin, $GUI_CHECKED) GUICtrlSetState($idLbl_Move, $GUI_DISABLE) EndIf ; Check if we should disable the add event MenuItem If $g_aEvents[0] >= $g_iMaxEvents Then GUICtrlSetState($MenuItem_AddEvent, $GUI_DISABLE) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### #Region ### START Koda GUI section ### Form=D:\Profil\Rex\ISN AutoIt Studio\Projects\Countdown Days\GUI\hAddEvent.kxf Global $hAddEvent = GUICreate("Add Event", 206, 407, -1, -1, BitOR($WS_SYSMENU, $WS_POPUP, $WS_CAPTION)) GUISetOnEvent($GUI_EVENT_CLOSE, "hWnd_Close") Global $idAddEvent = GUICtrlCreateDummy() ; Create a dumme, we use this to calculate the CtrlID of the Controls created after the dummy GUICtrlCreateLabel("Default Events:", 8, 8, 77, 17) ; This would be dummy + 1 in ID GUICtrlCreateCombo("", 8, 24, 185, 25, $CBS_DROPDOWNLIST) GUICtrlSetTip(-1, "Saved default events") GUICtrlSetOnEvent(-1, "idCombo_EventsChange") GUICtrlCreateLabel("Event Name:", 8, 56, 66, 17) GUICtrlCreateInput("", 8, 72, 185, 21) GUICtrlSetLimit(-1, 24) GUICtrlSetTip(-1, "Name of event." & @CRLF & "This is the text that will be shown at the gui." & @CRLF _ & "Max length is 24 chars") GUICtrlCreateLabel("Event description:", 8, 104, 89, 17) GUICtrlCreateEdit("", 8, 120, 185, 89, BitOR($ES_AUTOVSCROLL, $ES_WANTRETURN, $WS_VSCROLL)) GUICtrlSetTip(-1, "Event description." & @CRLF _ & "This wil be shown as a tip upon hovering, and also in the popup (if popup is enabled)") GUICtrlCreateCheckbox("Choose Event date by calendar", 8, 216, 170, 17) GUICtrlSetOnEvent(-1, "idCb_ChoseDateClick") GUICtrlCreateLabel("Days to event:", 8, 240, 73, 17) GUICtrlCreateInput("", 8, 256, 73, 21, BitOR($ES_CENTER, $ES_NUMBER)) GUICtrlSetLimit(-1, 3) GUICtrlSetTip(-1, "Days to the event") GUICtrlCreateLabel("Time of event", 112, 240, 69, 17) GUICtrlCreateDate('', 112, 256, 82, 21, BitOR($DTS_UPDOWN, $DTS_TIMEFORMAT)) GUICtrlSendMsg(-1, $DTM_SETFORMATW, 0, 'HH:mm:ss') ; Set time style GUICtrlCreateLabel("Event date:", 8, 240, 59, 17) GUICtrlSetState(-1, $GUI_HIDE) GUICtrlCreateDate('', 8, 256, 186, 21, 0) GUICtrlSendMsg(-1, $DTM_SETFORMATW, 0, 'yyyy/MM/dd HH:mm:ss') ; Set Date and Time style GUICtrlSetTip(-1, "The end date of the event") GUICtrlSetState(-1, BitOR($GUI_DISABLE, $GUI_HIDE)) ; Diasbled and hidden yy default GUICtrlCreateLabel("Sound to play:", 8, 280, 72, 17) GUICtrlCreateInput('', 8, 296, 160, 21, $ES_READONLY) ; Default sound to play at event end GUICtrlCreateButton("...", 174, 296, 21, 21) GUICtrlSetOnEvent(-1, "idBtn_SoundBrowseClick") GUICtrlCreateCheckbox("Play sound", 8, 328, 73, 17) GUICtrlCreateCheckbox("Popup", 88, 328, 49, 17) GUICtrlCreateCheckbox("Save as default event", 8, 352, 124, 17) GUICtrlSetTip(-1, "Saves the event as a default event, that later can be choosen from the dropdown") GUICtrlCreateButton("&Add event", 8, 376, 75, 21) GUICtrlSetTip(-1, "Adds the events and closes the add event gui") GUICtrlSetOnEvent(-1, "idBtn_AddEventClick") GUICtrlCreateButton("&Close", 120, 376, 75, 21) GUICtrlSetOnEvent(-1, "hWnd_Close") GUISetState(@SW_HIDE) #EndRegion ### END Koda GUI section ### #Region ### START Koda GUI section ### Form=D:\Profil\Rex\ISN AutoIt Studio\Projects\Countdown Days\GUI\hEditEvent.kxf Global $hEditEvent = GUICreate("Edit Event", 206, 407, -1, -1, BitOR($WS_SYSMENU, $WS_POPUP, $WS_CAPTION)) GUISetOnEvent($GUI_EVENT_CLOSE, "hWnd_Close") Global $idEditEvent = GUICtrlCreateDummy() GUICtrlCreateLabel("Choose events to edit:", 8, 8, 110, 17) GUICtrlCreateCombo("", 8, 24, 185, 25, $CBS_DROPDOWNLIST) GUICtrlSetOnEvent(-1, "idCombo_EventsChange") GUICtrlCreateLabel("Event Name:", 8, 56, 66, 17) GUICtrlCreateInput("", 8, 72, 185, 21) GUICtrlSetLimit(-1, 24) GUICtrlSetTip(-1, "Name of event. This is the text that will be shown at the gui. Max length is 24 chars") GUICtrlCreateLabel("Event description:", 8, 104, 89, 17) GUICtrlCreateEdit("", 8, 120, 185, 89, BitOR($ES_AUTOVSCROLL, $ES_WANTRETURN, $WS_VSCROLL)) GUICtrlSetTip(-1, "Event description. This will be shown as a tip upon hovering, and also in the popup (if popup is enabled)") GUICtrlCreateCheckbox("Choose event date by calender", 8, 216, 170, 17) GUICtrlSetOnEvent(-1, "idCb_ChoseDateClick") GUICtrlCreateLabel("Days to event:", 8, 240, 73, 17) GUICtrlCreateInput("", 8, 256, 73, 21, BitOR($ES_CENTER, $ES_NUMBER)) GUICtrlSetLimit(-1, 3) GUICtrlSetTip(-1, "Days to the event, time will be from the time the event is added") GUICtrlCreateLabel("Time of event", 112, 240, 69, 17) GUICtrlCreateDate('', 112, 256, 82, 21, BitOR($DTS_UPDOWN, $DTS_TIMEFORMAT)) GUICtrlSendMsg(-1, $DTM_SETFORMATW, 0, 'HH:mm:ss') GUICtrlSetTip(-1, "Time of the event") GUICtrlCreateLabel("Event date:", 8, 240, 59, 17) GUICtrlSetState(-1, $GUI_HIDE) GUICtrlCreateDate('', 8, 256, 186, 21, 0) GUICtrlSendMsg(-1, $DTM_SETFORMATW, 0, 'yyyy/MM/dd HH:mm:ss') GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlSetState(-1, $GUI_HIDE) GUICtrlSetTip(-1, "Choose the end date of the event") GUICtrlCreateLabel("Sound to play:", 8, 280, 72, 17) GUICtrlCreateInput("", 8, 296, 160, 21, $ES_READONLY) GUICtrlCreateButton("...", 174, 296, 21, 21) GUICtrlSetOnEvent(-1, "idBtn_SoundBrowseClick") GUICtrlCreateCheckbox("Play sound", 8, 328, 73, 17) GUICtrlSetState(-1, $GUI_CHECKED) GUICtrlCreateCheckbox("Popup", 88, 328, 49, 17) GUICtrlSetState(-1, $GUI_CHECKED) GUICtrlCreateCheckbox("Enabled", 8, 352, 60, 17) GUICtrlSetState(-1, $GUI_CHECKED) GUICtrlSetTip(-1, "Enables or disables the event, if disabled it don't show in the countdown gui") GUICtrlCreateButton("&Update", 8, 376, 75, 21) GUICtrlSetTip(-1, "Updates the selected event") GUICtrlSetOnEvent(-1, "idBtn_UpdateEventClick") GUICtrlCreateButton("&Close", 120, 376, 75, 21) GUICtrlSetOnEvent(-1, "hWnd_Close") GUISetState(@SW_HIDE) #EndRegion ### END Koda GUI section ### #Region ### START Koda GUI section ### Form=D:\Profil\Rex\ISN AutoIt Studio\Projects\Countdown Days\GUI\hEditEvent.kxf Global $hDeleteEvent = GUICreate("Delete Event", 206, 318, Default, Default, BitOR($WS_SYSMENU, $WS_POPUP, $WS_CAPTION)) GUISetOnEvent($GUI_EVENT_CLOSE, "hWnd_Close") Global $idDelEvent = GUICtrlCreateDummy() GUICtrlCreateLabel("Choose event to delete:", 8, 8, 122, 16) GUICtrlCreateCombo("", 8, 24, 185, 25, $CBS_DROPDOWNLIST) GUICtrlSetTip(-1, "Event to delete") GUICtrlSetOnEvent(-1, "idCombo_EventsChange") GUICtrlCreateLabel("Event Name:", 8, 56, 66, 16) GUICtrlCreateInput("", 8, 72, 185, 21, $ES_READONLY) GUICtrlCreateLabel("Event description:", 8, 104, 89, 16) GUICtrlCreateEdit("", 8, 120, 185, 89, BitOR($ES_AUTOVSCROLL, $ES_WANTRETURN, $WS_VSCROLL, $ES_READONLY)) GUICtrlCreateLabel("Event date:", 8, 216, 59, 17) GUICtrlCreateInput("", 8, 232, 186, 21, $ES_READONLY) GUICtrlCreateCheckbox("Enabled", 8, 264, 60, 17) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlCreateButton("&Delete", 8, 288, 75, 21) GUICtrlSetTip(-1, "Deletes selected event") GUICtrlSetOnEvent(-1, "idBtn_EventDeleteClick") GUICtrlCreateButton("&Close", 120, 288, 75, 21) GUICtrlSetTip(-1, "Closes the add event, without saving the event.") GUICtrlSetOnEvent(-1, "hWnd_Close") GUISetState(@SW_HIDE) #EndRegion ### END Koda GUI section ### #Region ### START Koda GUI section ### Form=D:\Profil\Rex\ISN AutoIt Studio\Projects\Countdown Days\GUI\hSettings.kxf Global $hSettings = GUICreate("Settings", 203, 327, Default, Default, BitOR($WS_SYSMENU, $WS_POPUP, $WS_CAPTION)) GUISetOnEvent($GUI_EVENT_CLOSE, "hWnd_Close") GUICtrlCreateLabel("Max Number of events:", 8, 12, 114, 17) GUICtrlSetTip(-1, "Max number of events." & @CRLF & "On a 1920x1080 Screen the max would be aprox 13 events.") Global $idInp_Sett_MaxEvents = GUICtrlCreateInput("", 122, 8, 21, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_NUMBER)) GUICtrlSetLimit(-1, 2) Global $idCb_Sett_Remember = GUICtrlCreateCheckbox("Remember last position.", 8, 32, 130, 17) GUICtrlSetTip(-1, "When countdown is closed, it saves the position it was placed, and starts at that position.") Global $idCb_Sett_PlaySound = GUICtrlCreateCheckbox("Play Sound", 8, 56, 74, 17) GUICtrlSetTip(-1, "Plays a sound when the event time is up.") Global $idCb_Sett_Pop = GUICtrlCreateCheckbox("Show popup", 88, 56, 80, 17) GUICtrlSetTip(-1, "Shows a popup windows, when the event time is up." & @CRLF & "The content of the popup windows will be the event description.") Global $idInp_Sett_Sound = GUICtrlCreateInput("", 8, 104, 153, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_READONLY)) GUICtrlSetTip(-1, "Default sound to play when the event time is up.") Global $idCb_Sett_StartWithWin = GUICtrlCreateCheckbox("Start with windows", 8, 80, 110, 17) GUICtrlSetTip(-1, "Start the program with windows") Global $idBtn_Sett_SoundBrowse = GUICtrlCreateButton("...", 168, 104, 21, 21) GUICtrlSetOnEvent(-1, "idBtn_SoundBrowseClick") GUICtrlCreateLabel("Default events:", 8, 136, 76, 17) Global $idList_Sett_DefEvents = GUICtrlCreateList("", 8, 152, 185, 97) GUICtrlSetTip(-1, "Default events that, can be picked from add event.") GUICtrlCreateButton("&Remove", 8, 256, 75, 21) GUICtrlSetTip(-1, "Deletes the selected Default event") GUICtrlSetOnEvent(-1, "idBtn_Sett_RemEventClick") GUICtrlCreateButton("&OK", 8, 296, 75, 21) GUICtrlSetOnEvent(-1, "idBtn_Sett_OKClick") GUICtrlCreateButton("&Close", 120, 296, 75, 21) GUICtrlSetOnEvent(-1, "hWnd_Close") GUISetState(@SW_HIDE) #EndRegion ### END Koda GUI section ### ;~ If $cmdline[0] = 1 Then RelHandle($cmdline[1]) Countdown() AdlibRegister("Countdown", 1000) While 1 Sleep(100) WEnd Func EventOnLoad($bMsg = True) ; This function is used to prevent array subscript dimension range exceeded, and to remove events that is currently disabled. ; Also it checks if there is more events enabled that max events allows, and throws a msg about it - and trims the max events ; to match the MaxEvents allowed ; First we removes the events that is currently disabled Local $sDelRange ; To save the array index where the disabled event is stored For $i = 1 To $g_aEvents[0] ; Check if the event is disabled, using StringToType to convert string to Bool If StringToType(IniRead($g_sEventFile, $g_aEvents[$i], 'Enabled', True)) = False Then ; If the event is disabled we add the index to our save index var and adds a ";" in case that more than one is disabled $sDelRange &= $i & ';' EndIf Next If $sDelRange <> '' Then ; If we had some Disabled events, we remove them from the array _ArrayDelete($g_aEvents, StringTrimRight($sDelRange, 1)) ; And then we update the value of $g_aEvents[0] $g_aEvents[0] = UBound($g_aEvents) - 1 If $g_aEvents[0] = 0 Then ; If there is no enabled events Dim $g_aEvents[2] = [1, Null] ; We updates the array, so we know that there is't any enabled events EndIf EndIf ; Then we check if there is more events that allowed If $g_aEvents[0] > $g_iMaxEvents And $bMsg = True Then ; If there is more events that allowed, we throw a warn - and trims the array to max MsgBox(BitOR($MB_ICONERROR, $MB_SETFOREGROUND, $MB_TOPMOST), 'Error', _ 'The amount of events exceeds the max nr of events' & @CRLF & _ 'Only the first ' & $g_iMaxEvents & ' events will be loaded!') $g_aEvents[0] = $g_iMaxEvents EndIf ; Updates the EventData array ReDim $g_aEventData[UBound($g_aEvents)][3] ; Add enddate to the array For $i = 1 To $g_aEvents[0] $g_aEventData[$i][0] = IniRead($g_sEventFile, $g_aEvents[$i], 'EndDate', _NowCalc()) $g_aEventData[$i][1] = StringToType(IniRead($g_sEventFile, $g_aEvents[$i], 'Enabled', True)) $g_aEventData[$i][2] = $g_aEvents[$i] Next EndFunc ;==>EventOnLoad Func MenuItem_AddEventClick() ; Add default evnets to dropdown Local $aDefEvents = IniReadSectionNames($g_sSetFile) If IsArray($aDefEvents) Then For $i = 1 To $aDefEvents[0] If $aDefEvents[$i] <> 'Settings' Then ; If the name is settings we ignore it ; Add the defaults to the combo and revert the name from hex to string. GUICtrlSetData($idAddEvent + 2, _HexToString($aDefEvents[$i])) EndIf Next EndIf ; Set default sound to play GUICtrlSetData($idAddEvent + 15, $g_sSoundFile) GUICtrlSetTip($idAddEvent + 15, $g_sSoundFile) ; Check if the playsound and popup is enabled in settings CbSetState($idAddEvent + 17, $g_bSoundPlay) CbSetState($idAddEvent + 18, $g_bPopup) ; Set focus to the Event Name input GUICtrlSetState($idAddEvent + 4, $GUI_FOCUS) ; Show the gui GUISetState(@SW_SHOW, $hAddEvent) EndFunc ;==>MenuItem_AddEventClick Func MenuItem_DeleteEventClick() Local $aEvents = IniReadSectionNames($g_sEventFile) If IsArray($aEvents) Then For $i = 1 To $aEvents[0] GUICtrlSetData($idDelEvent + 2, IniRead($g_sEventFile, $aEvents[$i], 'Name', 'Error Reading Name')) Next EndIf GUISetState(@SW_SHOW, $hDeleteEvent) EndFunc ;==>MenuItem_DeleteEventClick Func MenuItem_EditEventClick() ; First we get events from the inifile Local $aEvents = IniReadSectionNames($g_sEventFile) If IsArray($aEvents) Then For $i = 1 To $aEvents[0] GUICtrlSetData($idEditEvent + 2, IniRead($g_sEventFile, $aEvents[$i], 'Name', 'Error Reading Name')) Next EndIf ; Then we ticks of the date checkbox so it shows date picker GUICtrlSetState($idEditEvent + 7, $GUI_CHECKED) ; And hides/disables the Days to evnet / event time input and labels GUICtrlSetState($idEditEvent + 8, $GUI_HIDE) ; Hide the label Days to event GUICtrlSetState($idEditEvent + 9, BitOR($GUI_DISABLE, $GUI_HIDE)) ; Hide the input Days to event GUICtrlSetData($idEditEvent + 9, '') ; Clear the input Days to event GUICtrlSetState($idEditEvent + 10, $GUI_HIDE) ; Hides the label Time to event GUICtrlSetState($idEditEvent + 11, BitOR($GUI_DISABLE, $GUI_HIDE)) ; Hide the TimePicker Time to event ; Show date picker and lable GUICtrlSetState($idEditEvent + 12, $GUI_SHOW) ; Show the label Event date GUICtrlSetState($idEditEvent + 13, BitOR($GUI_ENABLE, $GUI_SHOW)) ; Show the Date time picker ; Then we show the GUI GUISetState(@SW_SHOW, $hEditEvent) EndFunc ;==>MenuItem_EditEventClick Func MenuItem_SettingsClick() ; Update the gui with info's from the settings file, or if no settings file exists, with defaults ; Add default evnets to Listbox (The events that is saved, and can be loaded in add event) Local $aDefEvents = IniReadSectionNames($g_sSetFile) If IsArray($aDefEvents) Then ; If it's an array we continue For $i = 1 To $aDefEvents[0] If $aDefEvents[$i] <> 'Settings' Then ; If the name is settings we ignore it ; Add the defaults to the listbox and convert the name from hex to string. _GUICtrlListBox_AddString($idList_Sett_DefEvents, _HexToString($aDefEvents[$i])) EndIf Next EndIf ; Check if the Remember, playsound, popup and Start with windows is enabled in settings CbSetState($idCb_Sett_Remember, $g_bRemember) CbSetState($idCb_Sett_PlaySound, $g_bSoundPlay) CbSetState($idCb_Sett_Pop, $g_bPopup) CbSetState($idCb_Sett_StartWithWin, $g_bStartWithWin) ; Set default sound GUICtrlSetData($idInp_Sett_Sound, IniRead($g_sSetFile, 'Settings', 'SoundFile', @WindowsDir & '\media\Tada.wav')) ; Set max events GUICtrlSetData($idInp_Sett_MaxEvents, IniRead($g_sSetFile, 'Settings', 'MaxEvents', 6)) ; Show the gui GUISetState(@SW_SHOW, $hSettings) EndFunc ;==>MenuItem_SettingsClick Func MenuItem_ExitClick() ; Check if the program should save it's poition If $g_bRemember = True Then PosSave() Exit EndFunc ;==>MenuItem_ExitClick Func MenuItem_PinClick() ; Get state of MenuItem Pin in place ; If the pin is enabled, the gui can't be moved If BitAND(GUICtrlRead($MenuItem_Pin), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState($MenuItem_Pin, $GUI_UNCHECKED) $g_bPin = False ; Update the var IniWrite($g_sSetFile, 'Settings', 'Pin', False) ; Update the ini file GUICtrlSetState($idLbl_Move, $GUI_ENABLE) ; Enable the label, this allows the gui to be moved Else GUICtrlSetState($MenuItem_Pin, $GUI_CHECKED) $g_bPin = True ; Update the var IniWrite($g_sSetFile, 'Settings', 'Pin', True) ; Update the ini file GUICtrlSetState($idLbl_Move, $GUI_DISABLE) ; Disable the label, preventing the gui to be moved EndIf EndFunc ;==>MenuItem_PinClick Func hWnd_Close() ; First we check if it's Add, Edit or Delete event gui that send the msg Switch WinGetHandle('[ACTIVE]') ; The handle of the current gui Case WinGetHandle($hAddEvent) ; If its Add event Local $iCtrlID = $idAddEvent ; hide the addevent gui GUISetState(@SW_HIDE, $hAddEvent) Case WinGetHandle($hEditEvent) ; If its Edit event Local $iCtrlID = $idEditEvent ; hide the editevent gui GUISetState(@SW_HIDE, $hEditEvent) Case WinGetHandle($hDeleteEvent) ; If its Delete event Local $iCtrlID = $idDelEvent ; hide the Delete event gui GUISetState(@SW_HIDE, $hDeleteEvent) Case WinGetHandle($hSettings) ; If its Settings ; Hide the gui GUISetState(@SW_HIDE, $hSettings) Return EndSwitch ; Clear all ; The first 3 ctrls is the same for all 3 gui's _GUICtrlComboBox_ResetContent($iCtrlID + 2) ; Clear the combo GUICtrlSetData($iCtrlID + 4, '') ; Clear the input Event name GUICtrlSetData($iCtrlID + 6, '') ; Clear the edit event Description ; Now we need to check if we have the edit or update gui If WinGetHandle($hAddEvent) Or WinGetHandle($hEditEvent) = WinGetHandle('[ACTIVE]') Then GUICtrlSetState($iCtrlID + 7, $GUI_UNCHECKED) ; Unchecks the Choose event date by calender checkbox GUICtrlSetData($iCtrlID + 9, '') ; Clear the input Days to event GUICtrlSetState($iCtrlID + 19, $GUI_UNCHECKED) ; Uncheck Save as default / Enabled checkbox Else ; Uncheck the Enabled checkbox at the delete gui GUICtrlSetState($iCtrlID + 19, $GUI_UNCHECKED) ; Uncheck Enabled checkbox EndIf EndFunc ;==>hWnd_Close Func idBtn_Sett_OKClick() ; Read infos and update the settings. ; Get maxEvents Local $iMaxEvents = GUICtrlRead($idInp_Sett_MaxEvents) If $iMaxEvents = '' Then MsgBox(BitOR($MB_ICONERROR, $MB_SETFOREGROUND, $MB_TOPMOST), 'Max number of events', _ "The input Max number of events is empty, but it shouldn't be" & @CRLF & 'Please type number of max allowed events!!') GUICtrlSetState($idInp_Sett_MaxEvents, $GUI_FOCUS) Else IniWrite($g_sSetFile, 'Settings', 'MaxEvents', $iMaxEvents) EndIf ; Write the settings to ini file IniWrite($g_sSetFile, 'Settings', 'Remember', (GUICtrlRead($idCb_Sett_Remember) = $GUI_CHECKED) ? True : False) IniWrite($g_sSetFile, 'Settings', 'SoundPlay', (GUICtrlRead($idCb_Sett_PlaySound) = $GUI_CHECKED) ? True : False) IniWrite($g_sSetFile, 'Settings', 'Popup', (GUICtrlRead($idCb_Sett_Pop) = $GUI_CHECKED) ? True : False) IniWrite($g_sSetFile, 'Settings', 'StartWithWin', (GUICtrlRead($idCb_Sett_StartWithWin) = $GUI_CHECKED) ? True : False) IniWrite($g_sSetFile, 'Settings', 'SoundFile', GUICtrlRead($idInp_Sett_Sound)) ; Check if the program should rember it's last position If GUICtrlRead($idCb_Sett_Remember) = $GUI_CHECKED Then PosSave() ; Check if the program should start with windows If GUICtrlRead($idCb_Sett_StartWithWin) = $GUI_CHECKED Then RegWrite('HKCU\Software\Microsoft\Windows\CurrentVersion\Run', 'CCD', 'REG_SZ', '"' & @ScriptFullPath & '"') Else RegDelete('HKCU\Software\Microsoft\Windows\CurrentVersion\Run', 'CCD') EndIf ; Update the global vars $g_bRemember = (GUICtrlRead($idCb_Sett_Remember) = $GUI_CHECKED) ? True : False $g_bSoundPlay = (GUICtrlRead($idCb_Sett_PlaySound) = $GUI_CHECKED) ? True : False $g_bPopup = (GUICtrlRead($idCb_Sett_Pop) = $GUI_CHECKED) ? True : False $g_bStartWithWin = (GUICtrlRead($idCb_Sett_StartWithWin) = $GUI_CHECKED) ? True : False $g_sSoundFile = GUICtrlRead($idInp_Sett_Sound) GUISetState(@SW_HIDE, $hSettings) EndFunc ;==>idBtn_Sett_OKClick Func idBtn_Sett_RemEventClick() ; First we warn about the removal Local $iStyle = BitOR($MB_YESNO, $MB_SETFOREGROUND, $MB_TOPMOST, $MB_ICONWARNING) Local $sEvent = GUICtrlRead($idList_Sett_DefEvents) Local $iMsgBoxAnswer = MsgBox($iStyle, 'Delete event', 'The event "' & $sEvent & '" will be deletede!' & @CRLF & "Do you want to continue?") Switch $iMsgBoxAnswer Case $IDYES ; Remove the evetn from ini file IniDelete($g_sSetFile, _StringToHex($sEvent)) ; Remove selected from the list box _GUICtrlListBox_DeleteString($idList_Sett_DefEvents, _GUICtrlListBox_FindString($idList_Sett_DefEvents, $sEvent)) Case $IDNO Return EndSwitch EndFunc ;==>idBtn_Sett_RemEventClick Func idCb_ChoseDateClick() ; Handel the Choose by date checkbox for either Add or Edit event gui ; First we check if it's Add or Edit event gui that is asking Switch WinGetHandle('[ACTIVE]') ; The handle of the current gui Case WinGetHandle($hAddEvent) ; If its Add event Local $iCtrlID = $idAddEvent Case WinGetHandle($hEditEvent) ; If its Edit event Local $iCtrlID = $idEditEvent EndSwitch ; Get state of checkbox Local $bChoseDate = (GUICtrlRead($iCtrlID + 7) = $GUI_CHECKED) ? True : False ; Handel state of checkbox Switch $bChoseDate Case True ; Hide, disable and clear days and time input / label GUICtrlSetState($iCtrlID + 8, $GUI_HIDE) ; Hide the label Days to event GUICtrlSetState($iCtrlID + 9, BitOR($GUI_DISABLE, $GUI_HIDE)) ; Hide the input Days to event GUICtrlSetData($iCtrlID + 9, '') ; Clear the input Days to event GUICtrlSetState($iCtrlID + 10, $GUI_HIDE) ; Hides the label Time to event GUICtrlSetState($iCtrlID + 11, BitOR($GUI_DISABLE, $GUI_HIDE)) ; Hide the TimePicker Time to event ; Show date picker and lable GUICtrlSetState($iCtrlID + 12, $GUI_SHOW) ; Show the label Event date GUICtrlSetState($iCtrlID + 13, BitOR($GUI_ENABLE, $GUI_SHOW)) ; Show the Date time picker Case False ; Hide, disable and clear date picker and label GUICtrlSetState($iCtrlID + 12, $GUI_HIDE) ; Hide the label Event date GUICtrlSetState($iCtrlID + 13, BitOR($GUI_DISABLE, $GUI_HIDE)) ; Hide the Date time picker ; Enable, show and set time input / labels GUICtrlSetState($iCtrlID + 8, $GUI_SHOW) ; Show the label Days to event GUICtrlSetState($iCtrlID + 9, BitOR($GUI_ENABLE, $GUI_SHOW)) ; Shows the Input Days to event GUICtrlSetState($iCtrlID + 10, $GUI_SHOW) ; Shows the label Time to event GUICtrlSetState($iCtrlID + 11, BitOR($GUI_ENABLE, $GUI_SHOW)) ; Show time picker EndSwitch EndFunc ;==>idCb_ChoseDateClick Func idBtn_AddEventClick() ; First we handle the inputs etc. ; Read data from gui, and add it to an array Local $sReadName = GUICtrlRead($idAddEvent + 4) ; Read name from Event name input If $sReadName = '' Then MsgBox(BitOR($MB_ICONERROR, $MB_SETFOREGROUND, $MB_TOPMOST), 'Event Name Error', 'The input "Event name" was empty!' & _ @CRLF & 'Please enter type an Event name!!') GUICtrlSetState($idAddEvent + 4, $GUI_FOCUS) Return EndIf ; Get state of checkbox Local $bChoseDate = (GUICtrlRead($idAddEvent + 7) = $GUI_CHECKED) ? True : False ; Handel state of checkbox Switch $bChoseDate Case True ; Get DTS from date picker Local $sDTS = GUICtrlRead($idAddEvent + 13) Case False ; Check that days is not empty Local $sReadDays = GUICtrlRead($idAddEvent + 9) If $sReadDays <> '' Then Local $sDTS = CalcEndDate($sReadDays, GUICtrlRead($idAddEvent + 11)) Else MsgBox(BitOR($MB_ICONERROR, $MB_SETFOREGROUND, $MB_TOPMOST), 'Days Error', 'The input "Days to event" was empty!' & _ @CRLF & 'Please enter number of days!!') GUICtrlSetState($idAddEvent + 9, $GUI_FOCUS) Return EndIf EndSwitch Local $sEvent = @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC ; We use this to prevent events with same SectionNames in the ini file. ; Create an array to hold the Event values Local $aValues[8][2] $aValues[0][0] = 7 ; Number of elements in the array $aValues[0][1] = '' $aValues[1][0] = 'Name' $aValues[1][1] = $sReadName ; Event Name $aValues[2][0] = 'Description' $aValues[2][1] = StringReplace(GUICtrlRead($idAddEvent + 6), @CRLF, ' ') ; Get data from edit $aValues[3][0] = 'EndDate' $aValues[3][1] = $sDTS ; Event end date $aValues[4][0] = 'Sound' $aValues[4][1] = GUICtrlRead($idAddEvent + 15) ; Get sound to play from input sound to play $aValues[5][0] = 'PlaySound' $aValues[5][1] = (GUICtrlRead($idAddEvent + 17) = $GUI_CHECKED) ? True : False ; To play or not play sound at event end $aValues[6][0] = 'Popup' $aValues[6][1] = (GUICtrlRead($idAddEvent + 18) = $GUI_CHECKED) ? True : False ; To show or not to show popup at event end $aValues[7][0] = 'Enabled' $aValues[7][1] = 'True' ; The Event is Enabled by default IniWriteSection($g_sEventFile, $sEvent, $aValues) ; Write data to ini file ; Get state of save as default checkbox If GUICtrlRead($idAddEvent + 19) = $GUI_CHECKED Then ; We dont save all the info, only Days to Event, Sound to play, To play o not play the sound and to show or not to show the popup ; Trim the array from unneeded data _ArrayDelete($aValues, '1;7') ; Remove Name and Enabled $aValues[0][0] = 5 ; Update the number of values left in the array $aValues[2][0] = 'Days' ; Change EndDate to Days ; Get the amount of days to event +1 course the cal is only returing whole days and the event will be in x days and 23:59:xx sec ; There for we needs to ad +1, so it will correspond to the amount of days th euser might have entered in Days to Event $aValues[2][1] = _DateDiff('D', _NowCalc(), $sDTS) + 1 IniWriteSection($g_sSetFile, _StringToHex(GUICtrlRead($idAddEvent + 4)), $aValues) ; Write the info to Settings file EndIf hWnd_Close() ; Close the gui If $g_aEvents[1] = Null Then UpdateGui(True) ; Update Countdown GUI with Msg Else UpdateGui(False) ; Update Countdown GUI without msg EndIf EndFunc ;==>idBtn_AddEventClick Func idBtn_UpdateEventClick() ; First we read the combo to get the index of the selected event Local $iIndex = _GUICtrlComboBox_GetCurSel($idEditEvent + 2) + 1 ; Now we get the data from the inifile Local $aEvents = IniReadSectionNames($g_sEventFile) ; First we handle the inputs etc. ; Read data from gui, and add it to an array Local $sReadName = GUICtrlRead($idEditEvent + 4) ; Read name from Event name input If $sReadName = '' Then MsgBox(BitOR($MB_ICONERROR, $MB_SETFOREGROUND, $MB_TOPMOST), 'Event Name Error', 'The input "Event name" was empty!' & _ @CRLF & 'Please enter type an Event name!!') GUICtrlSetState($idEditEvent + 4, $GUI_FOCUS) Return EndIf ; Get state of checkbox Local $bChoseDate = (GUICtrlRead($idEditEvent + 7) = $GUI_CHECKED) ? True : False ; Handel state of checkbox Switch $bChoseDate Case True ; Get DTS from date picker Local $sDTS = GUICtrlRead($idEditEvent + 13) Case False ; Check that days is not empty Local $sReadDays = GUICtrlRead($idEditEvent + 9) If $sReadDays <> '' Then Local $sDTS = CalcEndDate($sReadDays, GUICtrlRead($idEditEvent + 11)) Else MsgBox(BitOR($MB_ICONERROR, $MB_SETFOREGROUND, $MB_TOPMOST), 'Days Error', 'The input "Days to event" was empty!' & _ @CRLF & 'Please enter number of days!!') GUICtrlSetState($idEditEvent + 9, $GUI_FOCUS) Return EndIf EndSwitch ; Create an array to hold the Event values Local $aValues[8][2] $aValues[0][0] = 7 ; Number of elements in the array $aValues[0][1] = '' $aValues[1][0] = 'Name' $aValues[1][1] = $sReadName ; Event Name $aValues[2][0] = 'Description' $aValues[2][1] = StringReplace(GUICtrlRead($idEditEvent + 6), @CRLF, ' ') ; Get data from edit $aValues[3][0] = 'EndDate' $aValues[3][1] = $sDTS ; Event end date $aValues[4][0] = 'Sound' $aValues[4][1] = GUICtrlRead($idEditEvent + 15) ; Get sound to play from input sound to play $aValues[5][0] = 'PlaySound' $aValues[5][1] = (GUICtrlRead($idEditEvent + 17) = $GUI_CHECKED) ? True : False ; To play or not play sound at event end $aValues[6][0] = 'Popup' $aValues[6][1] = (GUICtrlRead($idEditEvent + 18) = $GUI_CHECKED) ? True : False ; To show or not to show popup at event end $aValues[7][0] = 'Enabled' $aValues[7][1] = (GUICtrlRead($idEditEvent + 19) = $GUI_CHECKED) ? True : False ; If enabled or not enabled IniWriteSection($g_sEventFile, $aEvents[$iIndex], $aValues) ; Write data to ini file hWnd_Close() ; Close the gui UpdateGui(False) ; Update Countdown GUI EndFunc ;==>idBtn_UpdateEventClick Func idBtn_EventDeleteClick() ; Deletes the selected Event from the Events.ini file and if it's current active in the CountDown GUI ; refreshes the gui to remove it from that also ; First we warn the user that the event will be deletede If MsgBox(BitOR($MB_YESNO, $MB_TOPMOST, $MB_SETFOREGROUND, $MB_ICONWARNING), 'Delete Event', 'The Event ' & GUICtrlRead($idDelEvent + 2) & _ ' will be deletede!' & @CRLF & 'Do you want to continue?') = $IDNO Then Return ; Read the combo, to get the index of the selected Event Local $iIndex = _GUICtrlComboBox_GetCurSel($idDelEvent + 2) + 1 ; Add +1 to the index ; Now we get the sectionnames from the ini file Local $aEvents = IniReadSectionNames($g_sEventFile) ; Saves the sectionname that we need to delete Local $sEventToDelete = $aEvents[$iIndex] ; We deletes the event from the ini file IniDelete($g_sEventFile, $aEvents[$iIndex]) ; Closes the Delete event gui GUISwitch($hDeleteEvent) hWnd_Close() ; Check if the event is active in the CountDownGUI, by checking if it's located in the EventData array. ; We search for the "SectionName" in the aEventData array, at colum 3, sins Col 1 holds the enddate and col 2 holds Enabled If _ArraySearch($g_aEventData, $sEventToDelete, 0, 0, 0, 0, 1, 3) <> -1 Then UpdateGui(False) ; Check if Max events is lessere that current enabled events EventOnLoad(False) If $g_aEvents[0] < $g_iMaxEvents Then GUICtrlSetState($MenuItem_AddEvent, $GUI_ENABLE) EndFunc ;==>idBtn_EventDeleteClick Func idBtn_SoundBrowseClick() ; First we check if it's Add, Edit Event or Settings gui that is asking Switch WinGetHandle('[ACTIVE]') Case WinGetHandle($hAddEvent) ; If its Add event Local $iCtrlID = $idAddEvent Case WinGetHandle($hEditEvent) ; If its Edit event Local $iCtrlID = $idEditEvent Case WinGetHandle($hSettings) ; If it Settings Local $iCtrlID = $idInp_Sett_Sound - 15 ; We have a ctrlid for this, so we subtracts 15 from the id to match our input. EndSwitch ; Display an open dialog to select a list of file(s). Local $iExStyle = BitOR($OFN_PATHMUSTEXIST, $OFN_FILEMUSTEXIST) Local $sAudioFile = _WinAPI_OpenFileDlg('', @WorkingDir, 'Audio (*.wav;*.mp3)', 1, '', '', $iExStyle) ; We only add if there is something to add If $sAudioFile <> '' Then GUICtrlSetData($iCtrlID + 15, $sAudioFile) EndFunc ;==>idBtn_SoundBrowseClick Func idCombo_EventsChange() ; Here we handle the combo changes for Add,Edit and Delete events ; First we check if it's Add or Edit event gui that is asking Switch WinGetHandle('[ACTIVE]') ; Get winhandl from active GUI Case WinGetHandle($hAddEvent) ; If it's Add event ; If we have the Add Event gui ; First we read the combo Local $sRead = GUICtrlRead($idAddEvent + 2) ; Now we get the default event data from the settings ini file Local $aData = IniReadSection($g_sSetFile, _StringToHex($sRead)) ; Add the data to the inputs GUICtrlSetData($idAddEvent + 4, $sRead) ; Add Name of event to input GUICtrlSetData($idAddEvent + 6, $aData[1][1]) ; Add Description to the edit GUICtrlSetData($idAddEvent + 9, $aData[2][1]) ; Add number of days to input GUICtrlSetData($idAddEvent + 15, $aData[3][1]) ; Add sound to input ; Set the state of Soundplay CbSetState($idAddEvent + 17, StringToType($aData[4][1])) ; Set the state of popup checkbox CbSetState($idAddEvent + 18, StringToType($aData[5][1])) Case WinGetHandle($hEditEvent) ; If it's Edit event ; We have the edit event gui ; First we read the combo Local $iIndex = _GUICtrlComboBox_GetCurSel($idEditEvent + 2) + 1 ; Now we get the data from the inifile Local $aEvents = IniReadSectionNames($g_sEventFile) Local $aData = IniReadSection($g_sEventFile, $aEvents[$iIndex]) ; Add the data to the inputs GUICtrlSetData($idEditEvent + 4, $aData[1][1]) ; Add the name to Event Name input GUICtrlSetData($idEditEvent + 6, $aData[2][1]) ; Add Description GUICtrlSetData($idEditEvent + 13, $aData[3][1]) ; Add end date of event GUICtrlSetData($idEditEvent + 15, $aData[4][1]) ; Add the sound GUICtrlSetTip($idEditEvent + 15, $aData[4][1]) ;Update the state of the checkboxes CbSetState($idEditEvent + 17, StringToType($aData[5][1])) ; PlaySound checkbox CbSetState($idEditEvent + 18, StringToType($aData[6][1])) ; Popup Checkbox CbSetState($idEditEvent + 19, StringToType($aData[7][1])) ; Enabled checkbox Case WinGetHandle($hDeleteEvent) ; If it's Delete event ; We have the edit event gui ; First we read the combo Local $iIndex = _GUICtrlComboBox_GetCurSel($idDelEvent + 2) + 1 ; Now we get the data from the inifile Local $aEvents = IniReadSectionNames($g_sEventFile) Local $aData = IniReadSection($g_sEventFile, $aEvents[$iIndex]) ; Add the data to the inputs GUICtrlSetData($idDelEvent + 4, $aData[1][1]) ; Add the name to Event Name input GUICtrlSetData($idDelEvent + 6, $aData[2][1]) ; Add Description GUICtrlSetData($idDelEvent + 8, $aData[3][1]) ; Add end date of event CbSetState($idDelEvent + 9, StringToType($aData[7][1])) ; Enabled checkbox EndSwitch EndFunc ;==>idCombo_EventsChange Func UpdateGui($bStart = True) ; Adds events to the main gui ; Check if we have an event to add to the gui If $g_aEvents[1] = Null And $bStart = False Then Return ; If we don't have any events ; If the function is called with False, we deletes all controls If $bStart = False Then ; Delete existing controls, so we can recreate them For $i = 1 To $g_aEvents[0] GUICtrlDelete($g_idLbl_Event[$i]) ; Delete the Event Name Label GUICtrlDelete($g_idLbl_Days[$i]) ; Deletes the label Days Counter GUICtrlDelete($g_idLbl_Days[$i] + 1) ; Deletes the label Days GUICtrlDelete($g_idLbl_Hrs[$i]) ; Deletes the label Hrs counter GUICtrlDelete($g_idLbl_Hrs[$i] + 1) ; Deletes the label : after hrs GUICtrlDelete($g_idLbl_Min[$i]) ; Deletes the label min counter GUICtrlDelete($g_idLbl_Min[$i] + 1) ; Deletes the label : after min GUICtrlDelete($g_idLbl_Sec[$i]) ; Deletes the label sec counter GUICtrlDelete($g_idLbl_Sec[$i] + 1) ; Deletes the label we use as frame around the time counter GUICtrlDelete($g_idLbl_Sec[$i] + 2) ; Deletes the Group we use as spacer GUICtrlDelete($g_idLbl_Sec[$i] + 3) ; Deletes the label we use as a frame for the gui Next EndIf $g_aEvents = IniReadSectionNames($g_sEventFile) ; reload the array ; Check if there is any events If Not IsArray($g_aEvents) Then Dim $g_aEvents[2] = [1, Null] Return EndIf ; Trims disabled events EventOnLoad(False) ; We call the function with false to prevent the msg box about too many events. ; Just to be shure If $g_aEvents[1] = Null Then Return ; Updates the global GUIHeight $g_iGuiHeight = ($g_iSpace * $g_aEvents[0]) + 8 ; Switch to the CCD gui, else the labels would be created on the last active gui GUISwitch($hCountdownDays) For $i = 1 To $g_aEvents[0] ; Adds the events to the Countdown gui Local $sEventName = StringLeft(IniRead($g_sEventFile, $g_aEvents[$i], 'Name', ''), 24) $g_idLbl_Event[$i] = GUICtrlCreateLabel($sEventName, 8, 14 + (($i - 1) * $g_iSpace), 119, 20, $SS_CENTER) GUICtrlSetFont(-1, 12, 400, 0, "Arial Narrow") GUICtrlSetColor(-1, 0xFFFFFF) ; Navy blue GUICtrlSetTip(-1, SplitText(IniRead($g_sEventFile, $g_aEvents[$i], 'Description', ''), 45)) $g_idLbl_Days[$i] = GUICtrlCreateLabel("", 31, 34 + (($i - 1) * $g_iSpace), 32, 24, $SS_RIGHT) GUICtrlSetFont(-1, 14, 800, 0, "Arial Narrow") GUICtrlCreateLabel("Days", 65, 34 + (($i - 1) * $g_iSpace), 34, 24) GUICtrlSetFont(-1, 14, 400, 0, "Arial Narrow") $g_idLbl_Hrs[$i] = GUICtrlCreateLabel("", 22, 56 + (($i - 1) * $g_iSpace), 18, 24, $SS_CENTER) GUICtrlSetFont(-1, 14, 800, 0, "Arial Narrow") GUICtrlCreateLabel(":", 46, 56 + (($i - 1) * $g_iSpace), 8, 24) GUICtrlSetFont(-1, 14, 800, 0, "Arial Narrow") $g_idLbl_Min[$i] = GUICtrlCreateLabel("", 56, 56 + (($i - 1) * $g_iSpace), 18, 24, $SS_CENTER) GUICtrlSetFont(-1, 14, 800, 0, "Arial Narrow") GUICtrlCreateLabel(":", 80, 56 + (($i - 1) * $g_iSpace), 8, 24) GUICtrlSetFont(-1, 14, 800, 0, "Arial Narrow") $g_idLbl_Sec[$i] = GUICtrlCreateLabel("", 90, 56 + (($i - 1) * $g_iSpace), 18, 24, $SS_CENTER) GUICtrlSetFont(-1, 14, 800, 0, "Arial Narrow") ; Create a static lable to frame the Time countdown GUICtrlCreateLabel("", 16, 56 + (($i - 1) * $g_iSpace), 102, 24, BitOR($SS_GRAYFRAME, $WS_DISABLED, $SS_SUNKEN)) ; We add a horizontal line as a spacer between the events, but only if we have more that one. But we don't add one after the last If $i >= 1 And $i < $g_aEvents[0] And $g_aEvents[0] > 1 Then GUICtrlCreateGroup("", 0, 84 + (($i - 1) * $g_iSpace), 135, 9) GUICtrlCreateGroup("", -99, -99, 1, 1) EndIf $g_idLbl_Event[0] = $i Next ; Resizes the Frame label GUICtrlSetPos($idFrame, 0, 0, 136, $g_iGuiHeight) ; Get the position of the Countdown gui Local $aWinPos = WinGetPos($hCountdownDays) ; Updates the height of the Countdown gui, using the pos we got, and the new height using the updated global guiheight _WinAPI_SetWindowPos($hCountdownDays, $HWND_NOTOPMOST, $aWinPos[0], $aWinPos[1], 136, $g_iGuiHeight, $SWP_NOMOVE) ; Finaly we checks if we have exceeded or maxed out the allowed amounts of Events. ; If we have we disables the add event MenuItem, thereby preventing the user to add more events, until ; an Event is either disabled or deleted, making up space for a new one. If $g_aEvents[0] >= $g_iMaxEvents Then GUICtrlSetState($MenuItem_AddEvent, $GUI_DISABLE) EndFunc ;==>UpdateGui Func CbSetState($iCtrlID, $bEnabled) Switch $bEnabled ; Popup checkbox Case True GUICtrlSetState($iCtrlID, $GUI_CHECKED) Case False GUICtrlSetState($iCtrlID, $GUI_UNCHECKED) EndSwitch EndFunc ;==>CbSetState Func PosSave() Local $aPos = WinGetPos($hCountdownDays) IniWrite($g_sSetFile, 'Settings', 'Posx', $aPos[0]) IniWrite($g_sSetFile, 'Settings', 'Posy', $aPos[1]) EndFunc ;==>PosSave Func Countdown() If $g_aEvents[1] = Null Then Return ; If we don't have any events For $i = 1 To $g_aEvents[0] ; cycle through events Local $iGetSec = _DateDiff('s', _NowCalc(), $g_aEventData[$i][0]) ; grab seconds of difference from now to future date If $iGetSec <= 0 And $g_aEventData[$i][1] = True Then EventHandle($g_aEvents[$i], $i) EndIf Ticks_To_Time($iGetSec, $g_iDays, $g_iHours, $g_iMins, $g_iSecs) ; convert seconds to days/hours/minutes/seconds ; set color and data Switch $g_iDays Case 0 To 5 GUICtrlSetDataAndColor($g_idLbl_Days[$i], $g_iDays, 1) ; Red Case 6 To 10 GUICtrlSetDataAndColor($g_idLbl_Days[$i], $g_iDays, 2) ; Yellow Case Else GUICtrlSetDataAndColor($g_idLbl_Days[$i], $g_iDays, 3) ; Green EndSwitch ; If days = 0 we want to change the timer colors If $g_iDays = 0 Then Switch $g_iHours Case 0 To 6 GUICtrlSetDataAndColor($g_idLbl_Hrs[$i], $g_iHours, 1) ; Red GUICtrlSetDataAndColor($g_idLbl_Min[$i], $g_iMins, 1) ; Red GUICtrlSetDataAndColor($g_idLbl_Sec[$i], $g_iSecs, 1) ; Red Case 7 To 12 GUICtrlSetDataAndColor($g_idLbl_Hrs[$i], $g_iHours, 2) ; Yellow GUICtrlSetDataAndColor($g_idLbl_Min[$i], $g_iMins, 2) ; Yellow GUICtrlSetDataAndColor($g_idLbl_Sec[$i], $g_iSecs, 2) ; Yellow Case 13 To 23 GUICtrlSetDataAndColor($g_idLbl_Hrs[$i], $g_iHours, 3) ; Green GUICtrlSetDataAndColor($g_idLbl_Min[$i], $g_iMins, 3) ; Green GUICtrlSetDataAndColor($g_idLbl_Sec[$i], $g_iSecs, 3) ; Green EndSwitch Else ; If not we just keep them black GUICtrlSetDataAndColor($g_idLbl_Hrs[$i], $g_iHours) ; Black GUICtrlSetDataAndColor($g_idLbl_Min[$i], $g_iMins) ; Black GUICtrlSetDataAndColor($g_idLbl_Sec[$i], $g_iSecs) ; Black EndIf Next EndFunc ;==>Countdown Func EventHandle($sEvent, $iIndex) ; Here we handles the event when it's time is up o_O ; First we disable the event, to prevent it from caling this function more than once. IniWrite($g_sEventFile, $sEvent, 'Enabled', False) ; Set False in the ini file $g_aEventData[$iIndex][1] = False ; Update the EventData array from True to false ; We need to check if the we should play a sound and / or throw a popup Local $aData = IniReadSection($g_sEventFile, $sEvent) ; Error checker If @error Then MsgBox(BitOR($MB_ICONERROR, $MB_SETFOREGROUND, $MB_TOPMOST), 'Error reading event data', 'An error happend when trying to read the event data!' _ & @CRLF & 'The program will now close!!') Exit EndIf ; Check if a sound should be played If StringToType($aData[5][1]) = True Then SoundPlay($aData[4][1]) ; Check if a popup should be displayed If StringToType($aData[6][1]) = True Then ; Disable the on event mode, else the GuiGetMsg won't work Opt("GUIOnEventMode", 0) ; Create the popup window Local $iStyle = BitOR($WS_SYSMENU, $WS_POPUP, $DS_SETFOREGROUND, $WS_CAPTION) Local $iExStyle = BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW) Local $hPopup = GUICreate($aData[1][1], 405, 285, Default, Default, $iStyle, $iExStyle) Local $idEdit_Popup = GUICtrlCreateEdit("", 11, 8, 385, 233, BitOR($ES_CENTER, $ES_READONLY, $ES_WANTRETURN, $WS_VSCROLL)) ; Set the Event description test to the edit GUICtrlSetData(-1, @CRLF & SplitText($aData[2][1]), 45) ;~ GUICtrlSetBkColor(-1, 0x4E4E4E) GUICtrlSetFont(-1, 18, 800, 0, "Arial Narrow") ; Boost the font size Local $idBtn_OK = GUICtrlCreateButton("OK", 165, 256, 75, 21, $BS_DEFPUSHBUTTON) GUISetState(@SW_SHOW) While 1 Local $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE SoundPlay('') ; Kill the sound if any GUIDelete($hPopup) ; Delete the gui ExitLoop ; And exit loop Case $idBtn_OK SoundPlay('') ; Kill the sound if any GUIDelete($hPopup) ; Delete the gui ExitLoop ; And exit loop EndSwitch WEnd Opt("GUIOnEventMode", 1) ; Reenable OnEventMode EndIf ; Set background label of the event to Yellow and text to Red - Indicate that the event is up GUICtrlSetColor($g_idLbl_Event[$iIndex], $COLOR_RED) ; Red GUICtrlSetBkColor($g_idLbl_Event[$iIndex], $COLOR_YELLOW) ; Yellow GUICtrlSetData($g_idLbl_Sec[$iIndex], '00') ; And set sec to 00 just becorse EndFunc ;==>EventHandle Func Ticks_To_Time($iSeconds, ByRef $idays, ByRef $iHours, ByRef $iMins, ByRef $iSecs) ; second conversion. ; modified: added days. added format style, to use 00 for time If Number($iSeconds) > 0 Then $idays = Int($iSeconds / 86400) $iSeconds = Mod($iSeconds, 86400) $iHours = StringFormat("%02d", Int($iSeconds / 3600)) $iSeconds = Mod($iSeconds, 3600) $iMins = StringFormat("%02d", Int($iSeconds / 60)) $iSecs = StringFormat("%02d", Mod($iSeconds, 60)) Return 1 Else Return SetError(1, 0, 0) EndIf EndFunc ;==>Ticks_To_Time Func GUICtrlSetDataAndColor($hWnd, $iCount, $iColor = 0) ; Set Day(s), Hour(s), Min(s), Sec(s) and color to the countdown labels Local $dRed, $dYellow, $dGreen, $dBlack Switch $iColor ; Check if we chould use a color Case 0 ; Black <- Default color $dBlack = 0x000000 Case 1 ; Red $dRed = 0xFF0000 Case 2 ; Yellow $dYellow = 0xFFFF00 Case 3 ; Green $dGreen = 0x008000 EndSwitch If GUICtrlRead($hWnd) <> $iCount Or GUICtrlRead($hWnd) = '' Then ; if data is different then change. helps with flickering GUICtrlSetData($hWnd, $iCount) GUICtrlSetColor($hWnd, $dRed & $dYellow & $dGreen & $dBlack) EndIf EndFunc ;==>GUICtrlSetDataAndColor Func CalcEndDate($idays, $sTime) ; Calculates a new date by adding a specified number of Days to an initial date Return _DateAdd('D', $idays, @YEAR & '/' & @MON & '/' & @MDAY & ' ' & $sTime) EndFunc ;==>CalcEndDate Func StringToType($vData) ; Converts a string to bool, Number or KeyWord Local $aData = StringRegExp($vData, "(?i)\bTrue\b|\bFalse\b|\bNull\b|\bDefault\b|\d{1,}", 3) If Not IsArray($aData) Then Return $vData Switch $aData[0] Case 'True' Return True Case 'False' Return False Case 'Null' Return Null Case 'Default' Return Default Case Else Return Number($aData[0]) EndSwitch EndFunc ;==>StringToType Func SplitText($sString, $iLenght = 45) #cs This splits a large text up into cunks at N lengt, at the last space within the nLength specified, and seperated with a @CRLF eg. 'A child asked his father, "How were people born?" So his father said, "Adam and Eve made babies, then their babies became adults and made babies, and so on." Would be formated as this: A child asked his father, "How were people born?" So his father said, "Adam and Eve made babies, then their babies became adults and made babies, and so on." #ce Local $sResult = StringRegExpReplace($sString, ".{1," & $iLenght - 1 & "}\K(\s{1,2}|$)", @CRLF) Return $sResult EndFunc ;==>SplitText1 point
-
How to pass parameters from xml to auto it script? - (Moved)
Fr33b0w reacted to FrancescoDiMuro for a topic
@Sankesh It depends from how your string are going to be formatted. If the format they would always have is this (as it seems) : Then you can use something like this: #include <Array.au3> #include <StringConstants.au3> Global $strFileContent = '<entry key="JSqlAccessJdbcUrl">jdbc:oracle:thin:@//CLRCSWPIQIN0041:1521/PIQ72</entry>' $arrResult = StringRegExp($strFileContent, '<entry key="JSqlAccessJdbcUrl">jdbc:oracle:thin:@[\/]{1,}([^:]+):\d+\/([^<]+)<\/entry>', $STR_REGEXPARRAYGLOBALMATCH) If IsArray($arrResult) Then _ArrayDisplay($arrResult) ; $arrResult[0] = CLRCSWPIQIN0041 ; $arrResult[1] = PIQ721 point -
The following works for me. Note the use of _WD_WaitElement to allow the web page to completely load. #include "wd_core.au3" #include "wd_helper.au3" _WD_Option('Driver', 'chromedriver.exe') _WD_Option('Port', 9515) _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"') _WD_Startup() $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true }}}}' $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_Navigate($sSession, "http://artsandculture.google.com/story/fQJiFTYiVkj2Ig") $sSelector = "//img[@class='XkWAb-LmsqOc']" _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, $sSelector) $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $sSelector, '', True) _WD_DeleteSession($sSession) _WD_Shutdown()1 point
-
Going by the character which my browser claims to be in between F and i, it is a Zero-width non-joiner character in unicode (code point 8204), it is used in some languages to represent more complex writing systems1 point
-
With a bit broader range of removal: StringRegExpReplace('Final', '[\x{200B}-\x{200D}]', '') Yet removing ZWJ (U+0200D) may change semantic of Unicode flux in some languages. You may also discover other such special codepoints, depending on the nature of the input text.1 point
-
Does anyone use this UDF? If yes: What have you tried so far? Import events or contacts? Does the UDF fit your needs or do you miss something? Should I enhance documentation (wiki, inline documentation ...)? If no: The UDF does not provide the function you are looking for. Which one? The function you tested does not work properly. Any errors? ... Something else ...?1 point
-
If you're unsure about which compile option was used to produce a given SQLite DLL you can run the " PRAGMA compile_options;" statement by use of _SQLite_GetTable(). The result is an array of compile options used.1 point
-
this is a possible example what i spoken #include <IE.au3> #include <MsgBoxConstants.au3> #include <StringConstants.au3> #include <InetConstants.au3> #include <WinAPI.au3> #include <WinAPIsysinfoConstants.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #include <Misc.au3> #include <INet.au3> ;#include <Excel.au3> #include <File.au3> #include <Array.au3> #include <Date.au3> #include <Misc.au3> #include <Debug.au3> Local $path = "https://www.immobiliare.it/ricerca.php?idCategoria=1&idContratto=1&idTipologia=&sottotipologia=&idTipologiaStanza=&idFasciaPrezzo=&idNazione=IT&idRegione=&idProvincia=&idComune=&idLocalita=&idAreaGeografica=&prezzoMinimo=&prezzoMassimo=&balcone=&balconeOterrazzo=&boxOpostoauto=&stato=&terrazzo=&bagni=&mappa=&foto=&superficie=&superficieMinima=&superficieMassima=&raggio=&locali=&localiMinimo=&localiMassimo=&criterio=rilevanza&ordine=desc&map=0&tipoProprieta=&arredato=&inAsta=&noAste=&aReddito=&fumatore=&animali=&franchising=&flagNc=&gayfriendly=&internet=&sessoInquilini=&vacanze=&categoriaStanza=&fkTipologiaStanza=&ascensore=&classeEnergetica=&verticaleAste=&occupazioneInquilini=&pag=1&vrt=43.84357086564766,10.488960742950441;43.84241015467616,10.494132041931154;43.84333872526002,10.493659973144533;43.84487083512528,10.49524784088135;43.84627910342516,10.49275875091553;43.8465421828286,10.49123525619507;43.845830318235556,10.490291118621828;43.84578389198876,10.488703250885011" $oIE = _IECreate($path, 0, 1, 1, 1) ; <--- 0011 invisible explorer <--- 0111 visible explorer _IELoadWait($oIE, 1, 1) $sGHtmlPag = _IEBodyReadHTML($oIE) Local $aLLinkInserz = StringRegExp($sGHtmlPag, '(?i)<a title=".+?" id=".+?" href="(.*?)"', 3) _ArrayDisplay($aLLinkInserz) for $i=0 To ubound ($aLLinkInserz) -1 ; this is a simple for with array ; here you can open in tab (but i dont like )---> url 1...... to 10 --> $aLLinkInserz[$i] ; or open in new window ; and do much more ...... ; enjoy. Next1 point
-
count how many hypertext have in a page put in array and cicle with for1 point
-
You had a problem in your _FFTabClose line, but otherwise looks fine to me. Try running the following in Scite and post the complete results from the output window -- #Include <FF.au3> _FFConnect() Sleep(2000) If _FFIsConnected() Then $tabs=_FFGetLength("tabs") ConsoleWrite("$tabs=" & $tabs & @CRLF) If $tabs > 4 Then _FFTabClose("last", 'key') EndIf EndIf1 point