Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/25/2022 in all areas

  1. Hum hum $file1 = @scriptdir & "\01.08.2022.txt" $file2 = @scriptdir & "\1.08.2022.txt" $file3 = @scriptdir & "\1.8.2022.txt" $file4 = @scriptdir & "\1/8/2022.txt" $res1 = Execute("'" & StringRegExpReplace($file1, '(\d?\d)\D(\d?\d)\D(\d{4})(\.txt)$', "$3' & StringFormat('%02i', '$2') & StringFormat('%02i', '$1') & '$4' & '") & "'") Msgbox(0,"1", $res1) $res2 = Execute("'" & StringRegExpReplace($file2, '(\d?\d)\D(\d?\d)\D(\d{4})(\.txt)$', "$3' & StringFormat('%02i', '$2') & StringFormat('%02i', '$1') & '$4' & '") & "'") Msgbox(0,"2", $res2) $res3 = Execute("'" & StringRegExpReplace($file3, '(\d?\d)\D(\d?\d)\D(\d{4})(\.txt)$', "$3' & StringFormat('%02i', '$2') & StringFormat('%02i', '$1') & '$4' & '") & "'") Msgbox(0,"3", $res3) $res4 = Execute("'" & StringRegExpReplace($file4, '(\d?\d)\D(\d?\d)\D(\d{4})(\.txt)$', "$3' & StringFormat('%02i', '$2') & StringFormat('%02i', '$1') & '$4' & '") & "'") Msgbox(0,"4", $res4)
    1 point
  2. Hi @NMS & @kurtykurtyboy A few months ago, we discussed this overlapping controls issue with @jpm in Trac Ticket #3877 A workable solution is to create the background pic control with a $WS_CLIPSIBLINGS style, changing this line of code in NMS script... ; GUICtrlCreatePic('C:\Windows\Web\Wallpaper\Windows\img0.jpg', 0, 0, 80, 100) ...to this : #include <StaticConstants.au3> ... GUICtrlCreatePic('C:\Windows\Web\Wallpaper\Windows\img0.jpg', 0, 0, 80, 100, BitOR($GUI_SS_DEFAULT_PIC, $WS_CLIPSIBLINGS)) Now the button is immediately visible when the GUI is displayed Hope it helps
    1 point
  3. @mucitbey I just read your new thread where you're asking this : In case you want to apply this request to Zedna's script just above, you could do it by commenting this line... ; $sFilePath = @ScriptDir & '\' & $sDate & '.txt' ...and replace it with this code : $sDate2 = (StringLen($sDate) = 10) ? $sDate : ('0' & $sDate) ; '1.08.2022' => '01.08.2022' $sFilePath = @ScriptDir & '\' & _ StringRight($sDate2, 4) & StringMid($sDate2, 4, 2) & StringLeft($sDate2, 2) & _ '.txt' ; "20220801.txt" or "20220825.txt" As date day isn't always 2 characters long in 'Data.txt' (date can be '1.08.2022' or '25.08.2022') then we have to force it to always be 2 characters long in the output file name. A RegEx code should be possible too, I'll leave it to RegEx experts
    1 point
  4. Zedna

    Rearrange multiple filenames.

    @Subz optimized version of your script without unneccessary _ArrayColInsert(): #include <File.au3> Global $g_sSourceDir = @ScriptDir & "\Original" Global $g_sTargetDir = @ScriptDir & "\Modify" _FileCopyRename($g_sSourceDir, $g_sTargetDir) Func _FileCopyRename($_sSourceDir = $g_sSourceDir, $_sTargetDir = $g_sTargetDir) Local $aTargetFile Local $aFileList = _FileListToArray($_sSourceDir, "*.txt", 1, 0) If @error Then Exit For $i = 1 To $aFileList[0] $aTargetFile = StringSplit($aFileList[$i], ".") ;~ If Array count equals 4 <Day>, <Month>, <Year>, <extension> If $aTargetFile[0] = 4 Then $sNewName = $aTargetFile[3] & $aTargetFile[2] & $aTargetFile[1] & "." & $aTargetFile[4] FileMove($_sSourceDir & "\" & $aFileList[$i], $_sTargetDir & "\" & $sNewName, 9) EndIf Next EndFunc
    1 point
  5. genius257

    Timer

    Here's my suggestion. In the end it works the same as the solution by @Gianni, but in my opinion less flicker on the controls and better readability. #include <GUIConstantsEx.au3> #include "Timer.au3" Opt("GuiOnEventMode", 1) #Region Timer globals Global $aiTimer[4] = [Null, Null, Null, Null] Global $ahTimer[4] = [Null, Null, Null, Null] Global $afTimer[4] = [0.0, 0.0, 0.0, 0.0] #EndRegion Timer globals #Region GUI Global $iFgColor = 0xFF0000 Func _GUICtrlCreateLabel($text, $left, $top, $width, $height) Local $ctrlID = GUICtrlCreateLabel($text, $left, $top, $width, $height) GUICtrlSetFont($ctrlID, 15, 800, 0, "Segoe UI") GUICtrlSetColor($ctrlID, $iFgColor) GUICtrlSetBkColor($ctrlID, $GUI_BKCOLOR_TRANSPARENT) Return $ctrlID EndFunc Func _GUICtrlCreateLabel2($text, $left, $top, $width, $height) Local $ctrlID = GUICtrlCreateLabel($text, $left, $top, $width, $height) GUICtrlSetFont(-1, 14) GUICtrlSetColor($ctrlID, $iFgColor) GUICtrlSetBkColor($ctrlID, $GUI_BKCOLOR_TRANSPARENT) Return $ctrlID EndFunc Global $Name = GUICreate("AutoIt", 690, 176, 263, 271) GUICtrlCreatePic('background.jpg', 0, 0, 0, 0) GUICtrlSetState(-1, $GUI_DISABLE) Global $Work = _GUICtrlCreateLabel("Time1", 56, 24, 55, 32) $Time = _GUICtrlCreateLabel2(" 00:00:00.0", 25, 60, 200, 25) $Button1 = GUICtrlCreateButton("Start/Stop", 20, 90, 60, 25) GUICtrlSetOnEvent(-1, "ToggleTimer1") $Button2 = GUICtrlCreateButton("Restart", 80, 90, 60, 25) GUICtrlSetOnEvent(-1, "ResetTimer1") Global $Idle = _GUICtrlCreateLabel("Time2", 208, 24, 39, 32) $Time1 = _GUICtrlCreateLabel2(" 00:00:00.0", 170, 60, 200, 25) $Button3 = GUICtrlCreateButton("Start/Stop", 170, 90, 60, 25) GUICtrlSetOnEvent(-1, "ToggleTimer2") $Button4 = GUICtrlCreateButton("Restart", 230, 90, 60, 25) GUICtrlSetOnEvent(-1, "ResetTimer2") Global $Meeting = _GUICtrlCreateLabel("Time3", 560, 24, 83, 32) $Time2 = _GUICtrlCreateLabel2(" 00:00:00.0", 350, 60, 200, 25) $Button5 = GUICtrlCreateButton("Start/Stop", 350, 90, 60, 25) GUICtrlSetOnEvent(-1, "ToggleTimer3") $Button6 = GUICtrlCreateButton("Restart", 410, 90, 60, 25) GUICtrlSetOnEvent(-1, "ResetTimer3") Global $Education = _GUICtrlCreateLabel("Time4", 360, 24, 98, 32) $Time3 = _GUICtrlCreateLabel2(" 00:00:00.0", 540, 60, 200, 25) $Button7 = GUICtrlCreateButton("Start/Stop", 540, 90, 60, 25) GUICtrlSetOnEvent(-1, "ToggleTimer4") $Button8 = GUICtrlCreateButton("Restart", 600, 90, 60, 25) GUICtrlSetOnEvent(-1, "ResetTimer4") GUISetState(@SW_SHOW) GUISetOnEvent($GUI_EVENT_CLOSE, "MyExit") #EndRegion GUI While 1 Sleep(10) WEnd Func MyExit() Exit EndFunc Func Timer($ctrlID, $index) GUICtrlSetData($ctrlID, " "&_Time_Format($afTimer[$index] + TimerDiff($ahTimer[$index]))) EndFunc Func ToggleTimer($ctrlID, $index) If $ahTimer[$index] = Null Then $ahTimer[$index] = TimerInit() $aiTimer[$index] = setInterval("Timer", 100, $ctrlID, $index) Else $afTimer[$index] += TimerDiff($ahTimer[$index]) clearInterval($aiTimer[$index]) $ahTimer[$index] = Null EndIf EndFunc Func ResetTimer($index) $ahTimer[$index] = TimerInit() $afTimer[$index] = 0.0 EndFunc Func ToggleTimer1() ToggleTimer($Time, 0) EndFunc Func ToggleTimer2() ToggleTimer($Time1, 1) EndFunc Func ToggleTimer3() ToggleTimer($Time2, 2) EndFunc Func ToggleTimer4() ToggleTimer($Time3, 3) EndFunc Func ResetTimer1() ResetTimer(0) EndFunc Func ResetTimer2() ResetTimer(1) EndFunc Func ResetTimer3() ResetTimer(2) EndFunc Func ResetTimer4() ResetTimer(3) EndFunc Func _Time_Format($ms) Local $totsec1 = Int($ms / 1000) ; ms to sec Local $hr1 = Int($totsec1 / 3600) ; hours Local $mn1 = Int(($totsec1 - ($hr1 * 3600)) / 60) ; minutes Local $sc1 = Int(($totsec1 - ($hr1 * 3600) - ($mn1 * 60))) ; seconds Local $tn1 = Int((Int($ms / 100) - ($hr1 * 36000) - ($mn1 * 600) - ($sc1 * 10))) ; tenths of a second Return StringFormat("%02s:%02s:%02s.%01s", $hr1, $mn1, $sc1, $tn1) EndFunc ;==>_Time_Format Timer.au3
    1 point
  6. @pixelsearch nice, here is your script little optimized, not needed "If $i = 0 Then ..." #include <Array.au3> #include <File.au3> #include <GUIConstantsEx.au3> Global $aInFile _FileReadToArray("Data.txt", $aInFile, $FRTA_NOCOUNT) Global $iLines = UBound($aInFile) Global $bFile _FileReadToArray("Users.txt", $bFile, $FRTA_NOCOUNT, "=") GUICreate("_mucitbey_", 430, 500, -1, -1) $lv = GUICtrlCreateListView("#|Card ID|[]|Date|Clock|User", 10, 10, 410, 480) $sDate = '' $hFileOpen = 0 For $i = 0 To $iLines - 1 $aTemp = StringSplit($aInFile[$i], ", ", $STR_NOCOUNT) $user = GetUser($aTemp[1]) $sLine = $aTemp[0] &"|"& $aTemp[1] &"|"& $aTemp[2] &"|"& $aTemp[3] &"|"& $aTemp[4] &"|"& $user GUICtrlCreateListViewItem($sLine, $lv) If $aTemp[4] > "08:10:00" And $aTemp[4] < "16:50:00" Then GUICtrlSetBkColor(-1, 0xC0FFFF) If $sDate <> $aTemp[3] Then ; If date changed => close old date txt file, then open new date txt file If $hFileOpen <> 0 Then FileClose($hFileOpen) $sDate = $aTemp[3] $sFilePath = @ScriptDir & '\' & $sDate & '.txt' $hFileOpen = FileOpen($sFilePath, $FO_OVERWRITE) If $hFileOpen = -1 Then Exit MsgBox(0, "FileOpen error", "Date = " & $sDate) EndIf FileWriteLine($hFileOpen, $sLine) Next If $hFileOpen <> 0 Then FileClose($hFileOpen) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUIDelete() Exit EndSwitch WEnd Func GetUser($ID) Local $iIndex = _ArraySearch($bFile, $ID) If $iIndex <> -1 Then Return $bFile[$iIndex][1] Else Return "Undefined ID" EndIf EndFunc
    1 point
  7. StringRegExpReplace($text, '[^[:print:]]', '')
    1 point
  8. my bad, one small error in the code I gave you... You have to declare the $olMailItem before running the script, and it's value must be 0 so....... full code Local $olMailItem = 0 $objOutlook = ObjCreate("Outlook.Application") $OutlookMailItem = $objOutlook.CreateItem($olMailItem) ; $OutlookMailItem.To = "" $OutlookMailItem.Subject = "Script!" $OutlookMailItem.HTMLBody = ("say whatever you want here to appear in the body.") ;$OutlookMailItem.Attachments.Add(whateverfile here) $OutlookMailItem.Display Exit
    1 point
×
×
  • Create New...