Leaderboard
Popular Content
Showing content with the highest reputation on 08/07/2025 in Posts
-
Hour AM/PM ( yes, one more of these )
Numeric1 and one other reacted to argumentum for a topic
; #FUNCTION# ==================================================================================================================== ; Name...........: HourAmPm ; Description....: Converts a time in 24-hour format to AM/PM format. ; Syntax.........: HourAmPm( $sDateTime [, $sAmPm = "AM|PM" [, $iTrimRight = 0]] ) ; Parameters.....: $sDateTime - The time (with date or not) string with "HH:" in it. ; $sAmPm - [optional] The AM/PM representation (default is "AM|PM"). ; $iTrimRight - [optional] The number of characters to trim from the right of the result (default is 0). ; $iNoDate - [optional] Whether to omit the date from the output. Defaults to False. ; Return values .: Success: Returns the formatted date and time in AM/PM format. ; Failure: None. ; Author ........: argumentum ; Modified ......: ; Remarks .......: This function takes a 24-hour time string, converts it to AM or PM format, and returns the result with optional trimming. ; Related .......: ; Link ..........: https://www.autoitscript.com/forum/index.php?showtopic=213061 ; Example .......: MsgBox(64, "Converted Time", HourAmPm("12/31/1999 18:59:59")) ; =============================================================================================================================== Func HourAmPm($sDateTime, $sAmPm = Default, $iTrimRight = Default, $iNoDate = Default) Local $aAmPm = StringSplit((StringInStr($sAmPm, "|") ? $sAmPm : "AM|PM"), "|"), $sFormat = $aAmPm[2] Local $iHourPos = StringInStr($sDateTime, ":"), $sHour = StringMid($sDateTime, $iHourPos - 2, 2) Local $sDate = StringLeft($sDateTime, $iHourPos - 3), $sTime = StringTrimLeft($sDateTime, $iHourPos - 1) If $sHour < 12 Then $sFormat = $aAmPm[1] ; https://www.autoitscript.com/forum/index.php?showtopic=213061 $sHour = Mod($sHour, 12) If Not $sHour Then $sHour = 12 Return StringTrimRight((Int($iNoDate) ? "" : $sDate) & StringRight('0' & $sHour, 2) & $sTime, Int($iTrimRight)) & " " & $sFormat EndFunc ;==>HourAmPm ...am always looking for these ( because am disorganized ) and when I find them they are more than needed so, I decided to simplify it and flexibly-cate** it. All that's needed is the hour, the rest of the date-time string should be anything as long as there is a "HH:" in it. ; Examples: ConsoleWrite('- ' & HourAmPm("18:59") & @CRLF) ; - 06:59 PM ConsoleWrite('- ' & HourAmPm("18:59:59.999") & @CRLF) ; - 06:59:59.999 PM ConsoleWrite('- ' & HourAmPm("1999/12/31 18:59:59.999") & @CRLF) ; - 1999/12/31 06:59:59.999 PM ConsoleWrite('- ' & HourAmPm("1999/12/31 18:59:59.999", Default, 7) & @CRLF) ; - 1999/12/31 06:59 PM ConsoleWrite('- ' & HourAmPm("1999/12/31 18:59:59", Default, 3) & @CRLF) ; - 1999/12/31 06:59 PM ConsoleWrite('- ' & HourAmPm("12/31/1999 18:59", "a|p") & @CRLF) ; - 12/31/1999 06:59 p ConsoleWrite('- ' & HourAmPm("1999/12/31 18:59:59.999", Default, 7, True) & @CRLF) ; - 06:59 PM Don't remember seeing this approach anywhere so I decided to share it **flexibly-cate [verb] To make it flexible2 points -
Move Gui with gif animation by button
Davidyese and one other reacted to pixelsearch for a topic
I was about to answer what follows, but @ioa747 was faster Help file, function GUIGetMsg : If the GUIOnEventMode option is set to 1 then the return from GUIGetMsg is always 0 and the @error is set to 1. You can't use at same time : Opt('GUIOnEventMode', 1) ... GUIGetMsg() ; will not work when GUIOnEventMode option is set to 12 points -
Since you have Opt('GUIOnEventMode', 1) GUIGetMsg() does not read it at all (In my example I do not want to use #include "GIFAnimation.au3" and I disabled it for that - because I haven't read/analyzed it yet) The basic changes you need to make are declare the event in the $hGUI Global $hGUI = GUICreate('', $aGIFDimension[0], $aGIFDimension[1], -1, -1, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST)) GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_DragMe") ; *** <--- 1 disable the event from $cButton ;~ GUICtrlSetOnEvent(-1, "_DragMe") ; *** <--- 2 disabling the entire ;~ Switch GUIGetMsg() ; *** <--- 3 from the main loop and in _DragMe() clean the part ;~ Switch GUIGetMsg() ; *** <--- 4 and leave only the $cInfo = GUIGetCursorInfo($hGUI) If $cInfo[4] = $cButton Then ... EndIf ; https://www.autoitscript.com/forum/topic/213062-move-gui-with-gif-animation-by-button/#findComment-1545090 #AutoIt3Wrapper_Au3Check_Parameters=-w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #NoTrayIcon #include <Constants.au3> #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> ;~ #include "GIFAnimation.au3" Opt('GUIOnEventMode', 1) Global Const $SC_DRAGMOVE = 0xF012 ; Flag to show if GUI was moved Global $fMoved = False Global $sFile = @ScriptDir & "\gif.gif" HotKeySet('{ESC}', '_Exit') ; Get dimension of the GIF ;~ Global $aGIFDimension = _GIF_GetDimension($sFile) Global $hGUI = GUICreate('', 600, 300, -1, -1, $WS_POPUP) ;, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST)) GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_DragMe") ; *** <--- 1 ;~ _WinAPI_SetLayeredWindowAttributes($hGUI, 0xABCDEF) Global $cButton = GUICtrlCreateButton('Drag me', 225, 100, 100, 100) ;~ GUICtrlSetOnEvent(-1, "_DragMe") ; *** <--- 2 Global $bButtonQuit = GUICtrlCreateButton("EXIT", 225, 200, 100, 20) GUICtrlSetOnEvent(-1, "_Exit") ; GIF job ;~ Global $hGIF = _GUICtrlCreateGIF($sFile, "", 120, -75) ; Additional processing of some windows messages (for example) ;~ GUIRegisterMsg(133, "_Refresh") ; WM_NCPAINT ;~ GUIRegisterMsg(15, "_ValidateGIFs") ; WM_PAINT Global $iPlay = 1 ; Make GUI transparent ;~ GUISetBkColor(345) ; some random color ;~ _WinAPI_SetLayeredWindowAttributes($hGui, 345, 255) ; making the GUI transparent ;~ _WinAPI_SetParent($hGui, 0) GUISetState(@SW_SHOW, $hGUI) ; Loop till end While 1 Sleep(500) ;~ Switch GUIGetMsg() ; *** <--- 3 ;~ Case $GUI_EVENT_PRIMARYDOWN ;~ ; Check mouse is over button ;~ $cInfo = GUIGetCursorInfo($hGUI) ;~ If $cInfo[4] = $cButton Then ;~ ; Clear the flag ;~ $fMoved = False ;~ ; Get initial positions of mouse and GUI ;~ $aInit_Pos = MouseGetPos() ;~ $aWin_Pos = WinGetPos($hGUI) ;~ ; Wait until mouse button released ;~ Do ;~ ; Check if mouse still pressed ;~ $cInfo = GUIGetCursorInfo($hGUI) ;~ ; Get current mouse position ;~ $aCurr_Pos = MouseGetPos() ;~ ; How far has mouse moved ;~ $iDiff_X = $aInit_Pos[0] - $aCurr_Pos[0] ;~ $iDiff_Y = $aInit_Pos[1] - $aCurr_Pos[1] ;~ ; Move GUI ;~ WinMove($hGUI, "", $aWin_Pos[0] - $iDiff_X, $aWin_Pos[1] - $iDiff_Y) ;~ Until Not $cInfo[2] ;~ ; See if mouse moved while it was pressed - allow for 5 pixel margin ;~ If (Abs($aCurr_Pos[0] - $aInit_Pos[0]) > 5) Or (Abs($aCurr_Pos[1] - $aInit_Pos[1]) > 5) Then ;~ ; If moved then set flag ;~ $fMoved = True ;~ EndIf ;~ EndIf ;~ EndSwitch WEnd Func _Exit() Exit EndFunc ;==>_Exit Func _DragMe() ;~ _GIF_PauseAnimation($sFile) ;~ Switch GUIGetMsg() ; *** <--- 4 ;~ Case $GUI_EVENT_PRIMARYDOWN ; Check mouse is over button $cInfo = GUIGetCursorInfo($hGUI) If $cInfo[4] = $cButton Then ; Clear the flag $fMoved = False ConsoleWrite("$fMoved=" & $fMoved & @CRLF) ; Get initial positions of mouse and GUI $aInit_Pos = MouseGetPos() $aWin_Pos = WinGetPos($hGUI) ; Wait until mouse button released Do ; Check if mouse still pressed $cInfo = GUIGetCursorInfo($hGUI) ; Get current mouse position $aCurr_Pos = MouseGetPos() ; How far has mouse moved $iDiff_X = $aInit_Pos[0] - $aCurr_Pos[0] $iDiff_Y = $aInit_Pos[1] - $aCurr_Pos[1] ; Move GUI WinMove($hGUI, "", $aWin_Pos[0] - $iDiff_X, $aWin_Pos[1] - $iDiff_Y) Until Not $cInfo[2] ; See if mouse moved while it was pressed - allow for 5 pixel margin If (Abs($aCurr_Pos[0] - $aInit_Pos[0]) > 5) Or (Abs($aCurr_Pos[1] - $aInit_Pos[1]) > 5) Then ; If moved then set flag $fMoved = True EndIf EndIf ;~ EndSwitch EndFunc ;==>_DragMe Func _Refresh($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam ;~ _GIF_RefreshGIF($hGIF) EndFunc ;==>_Refresh Func _ValidateGIFs($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam ;~ _GIF_ValidateGIF($hGIF) EndFunc ;==>_ValidateGIFs2 points
-
Hour AM/PM ( yes, one more of these )
ioa747 reacted to argumentum for a topic
1 point -
Dear ioa747 Thanks a lot for your help1 point
-
1 point
-
1 point
-
A Non-Strict JSON UDF (JSMN)
argumentum reacted to TheXman for a topic
@DonChunior Using your example, the correct syntax would be: $iCount = Json_Get($Data, '."@odata.count"') ;Using dot-notation or $iCount = Json_Get($Data, '["@odata.count"]') ;Using bracket-notation If key names contain special characters, such as periods, the key names should be wrapped in double quotes.1 point -
Hour AM/PM ( yes, one more of these )
ioa747 reacted to argumentum for a topic
The function header is thanks to your "press F10" toy @ioa7471 point -
Hour AM/PM ( yes, one more of these )
ioa747 reacted to argumentum for a topic
And !, I don't disagree. But I've been here for so long that my brain has a hard time..., feeling, what time it is. As far as time formats, the one that comes out of AutoIt's Date.au3 UDF is YYYY/MM/DD HH:MM:SS and this HourAmPm() is just for that scenario. I have become personally fond of the YYYY/MM/DD format and that !, should be mandatory everywhere too I added the "( yes, one more )" to the title, because there are a bunch of all encompassing AM/PM functions in the forum that I found to be "overengineered". I use this in my personal stuff: and is not American or any counties standard. Is AutoIt's standard that I liked, plus the AM/PM I did think of that ( $sSign = "AM/PM" ) , but I'll replace $iSignUpper with $sSign = "AM/PM", as it does make it more usable. That I'll change.1 point -
Thanks. Nitpick: if hours is a single digit, a preceding space is eaten. I seem to recall that H, M & S format is 2 digit in all cases. "2025-08-07 0:0:0" returns "2025-08-0712:0:0 AM" but should probably be "2025-08-07 12:00:00 AM" Not that I use AM/PM ridiculous convention. 24h format, like metric units, should be mandatory everywhere.1 point
-
GUICtrlCreateListView Problem loading data, first line of column # is deleted
angel83 reacted to pixelsearch for a topic
Good news I found a way to display the vertical line constantly while dragging the horizontal scrollbar, with very few flickering. To do this : 1) Add the extended style $LVS_EX_DOUBLEBUFFER to your line _GUICtrlListView_SetExtendedListViewStyle(...) 2) In the code of my preceding post, please change one line as indicated below : ; If BitAND($wParam, 0xFFFF) = 0x4 Then ; LoWord . $SB_THUMBPOSITION = 0x4 . Msdn : "the user has dragged the scroll box (thumb) and released the mouse button" If BitAND($wParam, 0xFFFF) = 0x5 Then ; LoWord . $SB_THUMBTRACK = 0x5 . Msdn : "the user is dragging the scroll box"1 point -
Running web apps without opening browser? - (Moved)
argumentum reacted to photonbuddy for a topic
I saw this, but because it was downloading a file, I made the false assumption that it wouldn't work. To make matters worse, I then was informed of wget, and went about installing that, and it worked fine. I didn't put it all together until just now. This also works, as does InetRead() Yep. I have full remote access, but I need something to run automatically in case I forget to run the link. To expand, that link re-adds scheduled programs. I have someone in the house who likes to delete scheduled recordings ... Finally, it took a while to return here, as wget resolved my issue, and there were no e-mail notifications telling me there had been replies. My bad for not coming back😔1 point -
DwmColorBlurMica
argumentum reacted to WildByDesign for a topic
First post has been updated with version 1.1.4. This adds a 1-click menu option to the Special Handling menu of the GUI for adding transparent background, tab row and tabs to Windows Terminal. That allows Immersive UX to apply all of the backdrop materials or blur behind to Terminal. I also added some messaging to the user for the patch/unpatch operations for VSCode, VSCodium and Windows Terminal so that the user is aware of what is being done.1 point -
AutoIt error getting current time?
Trong reacted to argumentum for a topic
Ok !. The the trac entry is marked as fixed1 point