Jump to content

All Activity

This stream auto-updates

  1. Today
  2. ; ; AutoIt 3x ; #Include <Date.au3> ;~ #include<_My_DATE.au3> ; my date, time conventions, etc. #NoTrayIcon ; AutoIt's icon doesn't show in systray TraySetIcon("Shell32.dll", 147) ; changes the icon displayed in the systray AutoItSetOption("WinTitleMatchMode", 2) ; this allows partial window titles to be valid! ;------------------------------------------------------------------------------------------------------------------------- #Region --- CodeWizard generated code Start --- ;InputBox features: Title=Yes, Prompt=Yes, Default Text=Yes, Width=250, Height=125 If Not IsDeclared("sInputBoxAnswer1") Then Local $sInputBoxAnswer1 ;===================================================================================================== $BoxTitle1 = "Create folder:" $LineTitle1 = "1. Number for next folder -- (i.e., ''2'', ''14'', or ''99'', etc. ...):" $BoxWidth1 = "525" $BoxHeight1 = "125" ;===================================================================================================== $sInputBoxAnswer1 = InputBox($BoxTitle1, $LineTitle1 & @CRLF & @CRLF, ""," ", $BoxWidth1, $BoxHeight1, Default, Default) ; width, heigh, left ("Default" centers box), top ("Default" centers box). Select Case @Error = 0 ;OK - The string returned is valid ;~ ClipPut($sInputBoxAnswer1) ; No needed , use the $sInputBoxAnswer1 ⚠️ $sInputBoxAnswer1 = StringFormat("%03i", $sInputBoxAnswer1) ; Here you are formatting. ⚠️ Case @Error = 1 ;The Cancel button was pushed Exit ; finished Case @Error = 3 ;The InputBox failed to open Exit ; finished EndSelect #EndRegion --- CodeWizard generated code End --- If Not IsDeclared("sInputBoxAnswer2") Then Local $sInputBoxAnswer2 ;===================================================================================================== $BoxTitle2 = "Create folder:" $LineTitle2 = "2. yymmdd.ddd" & @CRLF & "(Today's date by default; but change, as needed in yymmdd.ddd format.):" $BoxWidth2 = "525" $BoxHeight2 = "145" ;===================================================================================================== ;~ $sInputBoxAnswer2 = InputBox($BoxTitle2, $LineTitle2 & @CRLF & @CRLF, $YrDate_Short," ", $BoxWidth2, $BoxHeight2, Default, Default) ; width, heigh, left ("Default" centers box), top ("Default" centers box). $sInputBoxAnswer2 = InputBox($BoxTitle2, $LineTitle2 & @CRLF & @CRLF, _DTFormat(_NowCalc(), "yyMMdd.ddd"), " ", $BoxWidth2, $BoxHeight2, Default, Default) ; width, heigh, left ("Default" centers box), top ("Default" centers box). Select Case @Error = 0 ;OK - The string returned is valid ;~ ClipPut($sInputBoxAnswer2) ; No needed , use the $sInputBoxAnswer2 ⚠️ Case @Error = 1 ;The Cancel button was pushed Exit ; finished Case @Error = 3 ;The InputBox failed to open Exit ; finished EndSelect #EndRegion --- CodeWizard generated code End --- If Not IsDeclared("sInputBoxAnswer3") Then Local $sInputBoxAnswer3 ;===================================================================================================== $BoxTitle3 = "Create folder:" $LineTitle3 = "3. Name for folder -- (i.e., Pliers, etc.):" $BoxWidth3 = "525" $BoxHeight3 = "125" ;===================================================================================================== #Region --- CodeWizard generated code Start --- ;InputBox features: Title=Yes, Prompt=Yes, Default Text=Yes, Width=250, Height=125 If Not IsDeclared("sInputBoxAnswer") Then Local $sInputBoxAnswer3 $sInputBoxAnswer3 = InputBox($BoxTitle3, $LineTitle3 & @CRLF & @CRLF, ""," ", $BoxWidth3, $BoxHeight3, Default, Default) ; width, heigh, left ("Default" centers box), top ("Default" centers box). Select Case @Error = 0 ;OK - The string returned is valid ;============================================================================== $PathAndFldrName = @ScriptDir & "\" & $sInputBoxAnswer1 & "." & $sInputBoxAnswer2 & "- " & $sInputBoxAnswer3 & " [rd" ;============================================================================== ;~ $Title1 = ClipGet() & ", _ _._ _- " & $sInputBoxAnswer3 & "- PRODUCT DETAILS.txt" $Title1 = $sInputBoxAnswer2 & ", _ _._ _- " & $sInputBoxAnswer3 & "- PRODUCT DETAILS.txt" $LineText1 = "Seller:" & @TAB & @TAB & @TAB & "." & @CRLF & _ "* FULFILLED By:" & @TAB & "." & @CRLF & _ "Product:" & @TAB & @TAB & @TAB & "." & @CRLF & _ "Price:" & @TAB & @TAB & @TAB & "$ #.#" & @CRLF & @CRLF & @CRLF & _ "Price:" & @TAB & @TAB & @TAB & "$ #.#" & @CRLF & @CRLF & @CRLF & _ "--------------------------------" & @CRLF & _ "Source URL:" & @TAB & "." & @CRLF & _ "--------------------------------" & @CRLF & @CRLF & @CRLF & _ "Details:" & @TAB & @CRLF & "*******" & @CRLF & @CRLF & "." ;------------------------------------------------------------------------------ ;~ $Title2 = ClipGet() & ", _ _._ _- " & $sInputBoxAnswer3 & "- [SOURCE URL FOR PRODUCT(S) (drag pg here4 2create)].url" $Title2 = $sInputBoxAnswer2 & ", _ _._ _- " & $sInputBoxAnswer3 & "- [SOURCE URL FOR PRODUCT(S) (drag pg here4 2create)].url" $LineText2 = "" ;------------------------------------------------------------------------------ ;~ $Title3 = ClipGet() & ", _ _._ _- " & $sInputBoxAnswer3 & "- screencapture of order page.jpg" $Title3 = $sInputBoxAnswer2 & ", _ _._ _- " & $sInputBoxAnswer3 & "- screencapture of order page.jpg" $LineText3 = "" ;============================================================================== DirCreate($PathAndFldrName) Sleep(50) FileWrite($PathAndFldrName & "\" & $Title1, $LineText1) Sleep(50) FileWrite($PathAndFldrName & "\" & $Title2, $LineText2) Sleep(50) FileWrite($PathAndFldrName & "\" & $Title3, $LineText3) Case @Error = 1 ;The Cancel button was pushed Exit ; finished Case @Error = 3 ;The InputBox failed to open Exit ; finished EndSelect #EndRegion --- CodeWizard generated code End --- ; #FUNCTION# ==================================================================================================================== ; Name...........: _DTFormat ; Description....: Formats a given date/time string according to the specified format. ; Syntax.........: _DTFormat($sDate, $sFormat [, $iLcid = $LOCALE_USER_DEFAULT]) ; Parameters.....: $sDate - The date string to be formatted "[YYYY/MM/DD][ HH:MM:SS [ tt]]". ; $sFormat - A string containing the desired format for the date and time. ; Supported tokens are: Date and/or Time ; Date: ; d, dd = day; ddd, dddd = day of week; M= month; y = year ; Time: ; h= hour m= minute ; s = second (long time only) ; tt= AM. or P.M. ; h/H = 12/24 hour ; hh, mm, ss = display leading zero ; h, m, s = do not display leading zero ; Tokens can be separated by '|' to specify different formats for date and time. ; $iLcid - [optional] The locale identifier. Defaults to the user's default locale (default is $LOCALE_USER_DEFAULT). ; e.g. German = 1031, English = 1033 ; Return values .: Success: Returns the formatted date string. ; Failure: Returns an empty string and set the @error flag to non-zero. ; @error: ; 1 - Error date is not valid. ; 2 - Error in splitting the date string ; 3 - Error in encoding SystemTime ; 4 - Error in time formatting ; 5 - Error in date formatting ; Author ........: ioa747 ; Modified ......: ; Remarks .......: This function uses the Windows API to format date and time according to the specified locale. ; Related .......: _Date_Time_EncodeSystemTime, _WinAPI_GetDateFormat, _WinAPI_GetTimeFormat, _WinAPI_GetLocaleInfo ; Link ..........: https://learn.microsoft.com/en-us/windows/win32/intl/day--month--year--and-era-format-pictures ; https://www.autoitscript.com/forum/topic/213249-free-style-datetimeformat/#comment-1546499 ; Example .......: MsgBox(0, "Formatted Date", _DTFormat("2023/10/05 14:30:00", "MM/DD/YYYY|, HH:MM:SS")) ; =============================================================================================================================== Func _DTFormat($sDate, $sFormat, $iLcid = $LOCALE_USER_DEFAULT) Local $asDatePart[4], $asTimePart[4] Local $sTempDate = "", $sTempTime = "" Local $sAM, $sPM, $sTempString = "" Local $bDate = True ; If there is no date, add a dummy one (2000/01/01) If StringInStr($sDate, "/") = 0 And Not @error Then $bDate = False $sDate = "2000/01/01 " & $sDate Else ; Verify If InputDate is valid If Not _DateIsValid($sDate) Then Return SetError(1, 0, "") ; Error date is not valid. EndIf ; Split the date and time into arrays _DateTimeSplit($sDate, $asDatePart, $asTimePart) If @error Then Return SetError(2, @error, "") ; Error in splitting the date string Local $aPart = StringSplit($sFormat, "|") If $bDate Then $sTempDate = $aPart[1] $sTempTime = "" If $aPart[0] = 2 Then $sTempTime = $aPart[2] Else $sTempTime = $aPart[1] EndIf ; If time parts exist, check for AM/PM and convert to 24-hour format If $asTimePart[0] > 1 Then ; Get locale's AM designator, or AM $sTempString = _WinAPI_GetLocaleInfo($iLcid, $LOCALE_S1159) ; AM designator. If Not @error And Not ($sTempString = '') Then $sAM = $sTempString Else $sAM = "AM" EndIf ; Get locale's PM designator, or PM $sTempString = _WinAPI_GetLocaleInfo($iLcid, $LOCALE_S2359) ; PM designator. If Not @error And Not ($sTempString = '') Then $sPM = $sTempString Else $sPM = "PM" EndIf ; Convert 12-hour clock (with PM) to 24-hour clock If (StringInStr($sDate, 'pm') > 0) Or (StringInStr($sDate, $sPM) > 0) Then If $asTimePart[1] < 12 Then $asTimePart[1] += 12 ; Convert 12-hour clock (with AM) to 24-hour clock (handle 12 AM midnight case) ElseIf (StringInStr($sDate, 'am') > 0) Or (StringInStr($sDate, $sAM) > 0) Then If $asTimePart[1] = 12 Then $asTimePart[1] = 0 EndIf EndIf ; Remove ' tt' if hour is in format H/24 hour If StringInStr($sTempTime, "H", 1) > 0 Then $sTempTime = StringReplace($sTempTime, " tt", "") ; Encode a system time structure (required by WinAPI date/time functions) Local $tSystem = _Date_Time_EncodeSystemTime($asDatePart[2], $asDatePart[3], $asDatePart[1], $asTimePart[1], $asTimePart[2], $asTimePart[3]) If @error Then Return SetError(3, @error, "") ; Error in encoding SystemTime Local $sfinalTime = _WinAPI_GetTimeFormat($iLcid, $tSystem, 0, $sTempTime) If @error Then Return SetError(4, @error, "") ; Error in time formatting ; Force AM/PM if the format string contains 'tt' but regional settings didn't include it If StringInStr($sTempTime, "tt") Then If (StringInStr($sfinalTime, 'pm') = 0) And (StringInStr($sfinalTime, $sPM) = 0) And _ (StringInStr($sfinalTime, 'am') = 0) And (StringInStr($sfinalTime, $sAM) = 0) Then If $asTimePart[1] < 12 Then $sfinalTime &= " " & $sAM Else $sfinalTime &= " " & $sPM EndIf EndIf EndIf Local $sResult = "" If $sTempDate <> "" Then $sResult &= _WinAPI_GetDateFormat($iLcid, $tSystem, 0, $sTempDate) If @error Then Return SetError(5, @error, "") ; Error in date formatting If $sTempTime <> "" Then $sResult &= $sfinalTime Return $sResult EndFunc ;==>_DTFormat
  3. "D:\New AutoIt v3 Script.au3"(5,9) : error: can't open include file <_My_DATE.au3>. #include<_My_DATE.au3> ~~~~~~~~^ "D:\New AutoIt v3 Script.au3"(40,84) : warning: $YrDate_Short: possibly used before declaration. $sInputBoxAnswer2 = InputBox($BoxTitle2, $LineTitle2 & @CRLF & @CRLF, $YrDate_Short, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ "D:\New AutoIt v3 Script.au3"(40,84) : error: $YrDate_Short: undeclared global variable. $sInputBoxAnswer2 = InputBox($BoxTitle2, $LineTitle2 & @CRLF & @CRLF, $YrDate_Short, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ D:\New AutoIt v3 Script.au3 - 2 error(s), 1 warning(s) !>10:10:33 AU3Check ended. Press F4 to jump to next error. rc:2
  4. maybe your antivirus is deleting it? because the file is in 'autoit-opencv-4.12.0-com-v2.8.0.7z' "C:\Users\ioa747\Downloads\autoit-opencv-4.12.0-com-v2.8.0\autoit_opencv_com4120.dll"
  5. WarMan, thanks for respone.. i had download the 2 file and install then. i had got "opencv_world4120.dll and another. but i can not found file "autoit_opencv_com4120.dll" in every path... opencv_world4120.dll"autoit_opencv_com4120.dll"?
  6. Thank you! You guys are the best. I use Koda, but I'm just not good with doing complex things with it. This is great code. It doesn't have the path items already in it that my code does, but this is impressive. Thank you!
  7. Great! So that part of the question is okay, then. I just don't know how to add that StringFormat (with %03i) shown in the example (found in the 2nd code block) into my script that I posted in the 1st code block above. Thank you!
  8. @auto-it-tous
  9. sorry! who can tell me.. where to get file "autoit_opencv_com4120.dll"? i can not found it. _OpenCV_Open("opencv-4.12.0-windows\opencv\build\x64\vc16\bin\opencv_world4120.dll", "autoit-opencv-com\autoit_opencv_com4120.dll")
  10. Hello! Happy Advent! I shock myself sometimes <g>, I just started editing a file that had 2 inputboxes that I'd made up using the CodeWizard tool some years back (though I don't remember much from that far back <g>!). But I went and added another inputbox and darned if it doesn't work and work without hiccuping!!! <lol> MIracle I managed to do it <g>. Anyway, it's for creating folders. But I don't know how to apply the StringFormat to the leading number that will be inserted at the beginning of the created folder name. The user input for the folder number is in inputbox 1. Here is my code: ; ; AutoIt 3x ; #Include <Date.au3> #include<_My_DATE.au3> ; my date, time conventions, etc. #NoTrayIcon ; AutoIt's icon doesn't show in systray TraySetIcon("Shell32.dll", 147) ; changes the icon displayed in the systray AutoItSetOption("WinTitleMatchMode", 2) ; this allows partial window titles to be valid! ;------------------------------------------------------------------------------------------------------------------------- #Region --- CodeWizard generated code Start --- ;InputBox features: Title=Yes, Prompt=Yes, Default Text=Yes, Width=250, Height=125 If Not IsDeclared("sInputBoxAnswer1") Then Local $sInputBoxAnswer1 ;===================================================================================================== $BoxTitle1 = "Create folder:" $LineTitle1 = "1. Number for next folder -- (i.e., ''2'', ''14'', or ''99'', etc. ...):" $BoxWidth1 = "525" $BoxHeight1 = "125" ;===================================================================================================== $sInputBoxAnswer1 = InputBox($BoxTitle1, $LineTitle1 & @CRLF & @CRLF, ""," ", $BoxWidth1, $BoxHeight1, Default, Default) ; width, heigh, left ("Default" centers box), top ("Default" centers box). Select Case @Error = 0 ;OK - The string returned is valid ClipPut($sInputBoxAnswer1) Case @Error = 1 ;The Cancel button was pushed Exit ; finished Case @Error = 3 ;The InputBox failed to open Exit ; finished EndSelect #EndRegion --- CodeWizard generated code End --- If Not IsDeclared("sInputBoxAnswer2") Then Local $sInputBoxAnswer2 ;===================================================================================================== $BoxTitle2 = "Create folder:" $LineTitle2 = "2. yymmdd.ddd" & @CRLF & "(Today's date by default; but change, as needed in yymmdd.ddd format.):" $BoxWidth2 = "525" $BoxHeight2 = "145" ;===================================================================================================== $sInputBoxAnswer2 = InputBox($BoxTitle2, $LineTitle2 & @CRLF & @CRLF, $YrDate_Short," ", $BoxWidth2, $BoxHeight2, Default, Default) ; width, heigh, left ("Default" centers box), top ("Default" centers box). Select Case @Error = 0 ;OK - The string returned is valid ClipPut($sInputBoxAnswer2) Case @Error = 1 ;The Cancel button was pushed Exit ; finished Case @Error = 3 ;The InputBox failed to open Exit ; finished EndSelect #EndRegion --- CodeWizard generated code End --- If Not IsDeclared("sInputBoxAnswer3") Then Local $sInputBoxAnswer3 ;===================================================================================================== $BoxTitle3 = "Create folder:" $LineTitle3 = "3. Name for folder -- (i.e., Pliers, etc.):" $BoxWidth3 = "525" $BoxHeight3 = "125" ;===================================================================================================== #Region --- CodeWizard generated code Start --- ;InputBox features: Title=Yes, Prompt=Yes, Default Text=Yes, Width=250, Height=125 If Not IsDeclared("sInputBoxAnswer") Then Local $sInputBoxAnswer3 $sInputBoxAnswer3 = InputBox($BoxTitle3, $LineTitle3 & @CRLF & @CRLF, ""," ", $BoxWidth3, $BoxHeight3, Default, Default) ; width, heigh, left ("Default" centers box), top ("Default" centers box). Select Case @Error = 0 ;OK - The string returned is valid ;============================================================================== $PathAndFldrName = @ScriptDir & "\" & $sInputBoxAnswer1 & "." & $sInputBoxAnswer2 & "- " & $sInputBoxAnswer3 & " [rd" ;============================================================================== $Title1 = ClipGet() & ", _ _._ _- " & $sInputBoxAnswer3 & "- PRODUCT DETAILS.txt" $LineText1 = "Seller:" & @TAB & @TAB & @TAB & "." & @CRLF & _ "* FULFILLED By:" & @TAB & "." & @CRLF & _ "Product:" & @TAB & @TAB & @TAB & "." & @CRLF & _ "Price:" & @TAB & @TAB & @TAB & "$ #.#" & @CRLF & @CRLF & @CRLF & _ "Price:" & @TAB & @TAB & @TAB & "$ #.#" & @CRLF & @CRLF & @CRLF & _ "--------------------------------" & @CRLF & _ "Source URL:" & @TAB & "." & @CRLF & _ "--------------------------------" & @CRLF & @CRLF & @CRLF & _ "Details:" & @TAB & @CRLF & "*******" & @CRLF & @CRLF & "." ;------------------------------------------------------------------------------ $Title2 = ClipGet() & ", _ _._ _- " & $sInputBoxAnswer3 & "- [SOURCE URL FOR PRODUCT(S) (drag pg here4 2create)].url" $LineText2 = "" ;------------------------------------------------------------------------------ $Title3 = ClipGet() & ", _ _._ _- " & $sInputBoxAnswer3 & "- screencapture of order page.jpg" $LineText3 = "" ;============================================================================== DirCreate($PathAndFldrName) Sleep(50) FileWrite($PathAndFldrName & "\" & $Title1, $LineText1) Sleep(50) FileWrite($PathAndFldrName & "\" & $Title2, $LineText2) Sleep(50) FileWrite($PathAndFldrName & "\" & $Title3, $LineText3) Case @Error = 1 ;The Cancel button was pushed Exit ; finished Case @Error = 3 ;The InputBox failed to open Exit ; finished EndSelect #EndRegion --- CodeWizard generated code End --- [Now before anyone says, I'm sure it's ugly to you guys and it could probably be done waaayyyy better than this. But this is at my level and I can understand it <g>.] In other scripts that I have, I can ensure they keep the same naming convention in terms of number length by using StringFormat. An example I have of a line of working code can be seen here below. But I'm lost as how to apply it to the script above in the section dealing with $sInputBoxAnswer1 re the folder name. I think for 3 places with leading 0 -- to ensure the output is like this - 009, 054, 099, 125, etc. -- the code below with "StringFormat("%02i"," might need %03i, instead of %02i, no? ClipPut($YrDate_Short & "." & StringFormat("%02i", $number) & "- ") Thank you for any help in advance!
  11. Yesterday
  12. I feel you. Life can be a pain, literally. I get "distracted" ( to give it a name ) with my aging body, and ADHD, and the fears that make me OCD. Topped with memory issues and, am a mess. In others I got to identify when someone is going though things. Depression is one am painlessly familiar with. Painlessly because in the battle with it I lost the factors that makes it painful and by now I can know everything that ills the one going though depression but, there is nothing another can do when the one depressed chooses to either hide it, or not actively ask for help humbly. Is good to see you back. As far as "the dark mode", the way is supposed to be: you choose a theme, and that's the theme. Period. This per-program theme ?!?!. M$ is a ... misguided bunch, or a marketing genius that makes one exited because the next version will have a, less incomplete theme. In my case, I use "after market" themes and that takes care of dark mode for me, in my PC. When in a GUI, all controls that can be dark-moded, then I can offer dark mode, else, no dark mode ( say, GUICtrlCreateDate() is used ). Again, is good to see you back.
  13. Hello. I was trying your penultimate script above and could improve it a bit (no more Adib but $HDN_ENDTRACK changed to $HDN_ITEMCHANGED, added _GUICtrlHeader_Destroy) etc... The problem with a separate header control is that you'll have to add plenty of code in your script to get (nearly) the same results as a native Listview control (which takes care of its native header items), this means sorting listview columns by clicking their headers, changing header items order by dragging a header item at the left or right of another, double-clicking a header separator etc...) For example, in my script below, please notice what will happen when you enlarge a header item : an horizontal scrollbar will appear in the listview. Now when you scroll horizontally, the headers items won't align the listview columns, so you'll have to take care of this part too etc... Of course all these points could be fixed with additional code, it's up to you to decide if you're ready to add all this code to avoid flicker. #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> ; DPI DllCall("User32.dll", "bool", "SetProcessDpiAwarenessContext" , "HWND", "DPI_AWARENESS_CONTEXT" -2) Opt("MustDeclareVars", 1) ;0=no, 1=require pre-declaration Global $g_hGUI, $g_hChild Global $g_hHeader, $g_idListview Example() Func Example() $g_hGUI = GUICreate("Example", 400, 400, -1, -1, $WS_OVERLAPPEDWINDOW, $WS_EX_COMPOSITED) GUISetBkColor(0x202020) GUISetState(@SW_SHOW, $g_hGUI) $g_hChild = GUICreate("ChildWindow", 320, 320, 40, 40, $WS_CHILD, -1, $g_hGUI) GUISetBkColor(0x606060) $g_hHeader = _GUICtrlHeader_Create($g_hChild) _GUICtrlHeader_AddItem($g_hHeader, "Column1", 100) _GUICtrlHeader_AddItem($g_hHeader, "Column2", 100) _GUICtrlHeader_AddItem($g_hHeader, "Column3", 100) $g_idListview = GUICtrlCreateListView("col1|col2|col3 ", 0, 24, 320, 295, BitOR($GUI_SS_DEFAULT_LISTVIEW, $LVS_NOCOLUMNHEADER), BitOR($LVS_EX_DOUBLEBUFFER, $LVS_EX_FULLROWSELECT)) For $i = 1 To 30 GUICtrlCreateListViewItem("item" & $i & "|item" & $i & "|item" & $i, $g_idListview) Next ; resize listview columns to match header widths _resizeLVCols() GUISetState(@SW_SHOW, $g_hChild) ; get rid of dotted rectangle on listview, when an item got the focus GUICtrlSendMsg($g_idListview, $WM_CHANGEUISTATE, 65537, 0) GUIRegisterMsg($WM_NOTIFY, WM_NOTIFY) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd _GUICtrlHeader_Destroy($g_hHeader) ; added GUIDelete($g_hChild) GUIDelete($g_hGUI) EndFunc ;==>Example Func _resizeLVCols() For $i = 0 To _GUICtrlHeader_GetItemCount($g_hHeader) - 1 _GUICtrlListView_SetColumnWidth($g_idListview, $i, _GUICtrlHeader_GetItemWidth($g_hHeader, $i)) Next EndFunc ;==>_resizeLVCols Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam) Local $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) Local $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $g_hHeader Switch $iCode Case $HDN_ITEMCHANGED, $HDN_ITEMCHANGEDW _resizeLVCols() EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY
  14. @pixelsearch Thanks to your previous __WinAPI_Set_Window_Style / _WinAPI_SetWindowLong work, I've got the ListView drag-to-reorder columns working. Part of the trick involved removing LVS_NOCOLUMNHEADER and adding it back after the column reorder. The dragging of columns to reorder columns ended up very smooth. After this, I have to implement the sorting of column items. That should be easy. EDIT: Also, I need to get the height of the header control because it is different depending on the DPI that the user has set. I will probably look into using _GUICtrlHeader_GetItemRect for that but have not tried yet. #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <WinAPISysWin.au3> ; DPI DllCall("User32.dll", "bool", "SetProcessDpiAwarenessContext" , "HWND", "DPI_AWARENESS_CONTEXT" -2) Opt("MustDeclareVars", 1) ;0=no, 1=require pre-declaration Global $g_hGUI, $g_hChild Global $g_hHeader, $idListview, $aOrder, $hListView Global $idLVi_Item1, $idLVi_Item2, $idLVi_Item3 Example() Func Example() $g_hGUI = GUICreate("Example", 400, 400, -1, -1, $WS_OVERLAPPEDWINDOW, $WS_EX_COMPOSITED) GUISetBkColor(0x202020) GUISetState(@SW_SHOW, $g_hGUI) $g_hChild = GUICreate("ChildWindow", 320, 320, 40, 40, $WS_CHILD, -1, $g_hGUI) GUISetBkColor(0x606060) $g_hHeader = _GUICtrlHeader_Create($g_hChild) _GUICtrlHeader_AddItem($g_hHeader, "Column0", 100) _GUICtrlHeader_AddItem($g_hHeader, "Column1", 100) _GUICtrlHeader_AddItem($g_hHeader, "Column2", 100) $idListview = GUICtrlCreateListView("col1|col2|col3 ", 0, 24, 320, 320, BitOR($GUI_SS_DEFAULT_LISTVIEW, $LVS_NOCOLUMNHEADER), BitOR($LVS_EX_DOUBLEBUFFER, $LVS_EX_FULLROWSELECT, $LVS_EX_HEADERDRAGDROP)) $hListView = GUICtrlGetHandle($idListview) $idLVi_Item1 = GUICtrlCreateListViewItem("col0-item1|col1-item1|col2-item1", $idListview) $idLVi_Item2 = GUICtrlCreateListViewItem("col0-item2|col1-item2|col2-item2", $idListview) $idLVi_Item3 = GUICtrlCreateListViewItem("col0-item3|col1-item3|col2-item3", $idListview) ; resize listview columns to match header widths _resizeLVCols() ;AdlibRegister("_resizeLVCols") GUIRegisterMsg($WM_NOTIFY, WM_NOTIFY) GUISetState(@SW_SHOW, $g_hChild) GUICtrlSendMsg($idListview, $WM_CHANGEUISTATE, 65537, 0) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete($g_hChild) GUIDelete($g_hGUI) EndFunc ;==>Example Func _resizeLVCols() _GUICtrlListView_SetColumnWidth($idListview, 0, _GUICtrlHeader_GetItemWidth($g_hHeader, 0)) _GUICtrlListView_SetColumnWidth($idListview, 1, _GUICtrlHeader_GetItemWidth($g_hHeader, 1)) _GUICtrlListView_SetColumnWidth($idListview, 2, _GUICtrlHeader_GetItemWidth($g_hHeader, 2)) GUICtrlSendMsg($idListview, $WM_CHANGEUISTATE, 65537, 0) EndFunc Func _reorderLVCols() ; remove LVS_NOCOLUMNHEADER from listview __WinAPI_Set_Window_Style($hListView, $LVS_NOCOLUMNHEADER, _ False, _ ; True (add) or False (remove)... False) ; True = ...the extended style or False = style $aOrder = _GUICtrlHeader_GetOrderArray($g_hHeader) _GUICtrlListView_SetColumnOrderArray($idListview, $aOrder) ; add LVS_NOCOLUMNHEADER back to listview __WinAPI_Set_Window_Style($hListView, $LVS_NOCOLUMNHEADER, _ True, _ ; True (add) or False (remove)... False) ; True = ...the extended style or False = style EndFunc Func _resizeLVColsAdlib() _resizeLVCols() AdlibUnRegister("_resizeLVColsAdlib") EndFunc Func _reorderLVColsAdlib() _reorderLVCols() AdlibUnRegister("_reorderLVColsAdlib") EndFunc Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam) Local $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) Local $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $g_hHeader Switch $iCode Case $HDN_BEGINDRAG ; Sent by a header control when a drag operation has begun on one of its items ;_WM_NOTIFY_DebugEvent("$HDN_BEGINDRAG", $tagNMHEADER, $lParam, "IDFrom,,Item,Button") Return False ; To allow the header control to automatically manage drag-and-drop operations ; Return True ; To indicate external (manual) drag-and-drop management allows the owner of the ; control to provide custom services as part of the drag-and-drop process Case $HDN_ENDTRACK, $HDN_ENDTRACKW AdlibRegister("_resizeLVColsAdlib", 5) ;_resizeLVCols() Case $HDN_ENDDRAG ; Sent by a header control when a drag operation has ended on one of its items ;_WM_NOTIFY_DebugEvent("$HDN_ENDDRAG", $tagNMHEADER, $lParam, "IDFrom,,Item,Button") AdlibRegister("_reorderLVColsAdlib", 5) Return False ; To allow the control to automatically place and reorder the item ; Return True ; To prevent the item from being placed EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func __WinAPI_Set_Window_Style($hWnd, $i_Style, $b_Add, $b_exStyle = False) ; compacted code (from Kafu's original) If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) Local $iIndex = $b_exStyle ? $GWL_EXSTYLE : $GWL_STYLE ; $iIndex as named by msdn & help file Local $i_Style_Old = _WinAPI_GetWindowLong($hWnd, $iIndex) If $b_Add Then If BitAND($i_Style_Old, $i_Style) Then Return ; style already applied _WinAPI_SetWindowLong($hWnd, $iIndex, BitOR($i_Style_Old, $i_Style)) Else ; remove If Not BitAND($i_Style_Old, $i_Style) Then Return ; style not set _WinAPI_SetWindowLong($hWnd, $iIndex, BitXOR($i_Style_Old, $i_Style)) EndIf Local $iRet = _WinAPI_SetWindowPos($hWnd, $HWND_TOP, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOACTIVATE, $SWP_NOMOVE, $SWP_NOSIZE, $SWP_NOZORDER)) ; +++ If Not $iRet Then MsgBox($MB_TOPMOST, "_WinAPI_SetWindowPos", "Error = " & _WinAPI_GetLastError() & " Message = " & _WinAPI_GetLastErrorMessage()) EndFunc ;==>__WinAPI_Set_Window_Style
  15. I think the Status: 0 has to do with the double quotes, for starters, change $RUN_LOGON_PROFILE to $RUN_LOGON_NOPROFILE, as suggested in the help file, which is the light version, to see how it's going as for the Domain, I don't know anything
  16. @ioa747 It looks like your computer is not in a domain. I wonder if that is the underlying issue for me. In that the environment I'm operating in is a domain environment and the admin is a domain user. Another key difference is that the user's computer is not 25H2 Thanks for the feedback.
  17. As an example of an x86 application, I chose Au3Info.exe and it worked normally without double quotes even though the path has blank characters Here I must emphasize that at the beginning I entered the 4-digit 'Hello PIN' and it did not work, I had to enter the Admin Password With Windows 11 Pro, Version: 25H2 #AutoIt3Wrapper_UseX64=y #include <AutoItConstants.au3> RunAsAdmin() Func RunAsAdmin() ; Change the username and password to the appropriate values for your system. Local $sUserName = "ElevateUser" Local $sDomain = @ComputerName Local $sPassword = "ElevatePassword" Local $sProgram = "C:\Program Files (x86)\AutoIt3\Au3Info.exe" Local $Status $Status = FileExists($sProgram) ConsoleWrite("Program:" & $sProgram & @CRLF) ConsoleWrite("Status: " & $Status & @CRLF) ; Run Notepad with the window maximized. Notepad is run under the user previously specified. Local $iPID = RunAs($sUserName, $sDomain, $sPassword, $RUN_LOGON_PROFILE, $sProgram, "", @SW_SHOWMAXIMIZED) ConsoleWrite("PID: " & $iPID & @CRLF) EndFunc ;==> RunAsAdmin Output : Program:C:\Program Files (x86)\AutoIt3\Au3Info.exe Status: 1 PID: 6756
  18. @pixelsearch It looks like I was wildly wrong about WS_EX_MDICHILD being required to make this work. Thank you for this finding. So it looks like all that is needed is WS_POPUP. This is a good and interesting finding. Anyway, my curiosity got the better of me and I have discovered a way to do ListViews on a GUI that has WS_EX_COMPOSITED without having to do WS_POPUP. It works well in WS_CHILD which would represent how GUIFrame UDF does it. Also this is flicker-free. So basically it is the LV header that is not playing nice. I disabled the LV header with LVS_NOCOLUMNHEADER and created my own header with _GUICtrlHeader_Create in the WS_CHILD window. Now, the trick is synchronizing the width of the header items with the width of the listview columns. Sorting and dragging columns can likely be added later quite easily. If you uncomment my AdlibRegister you will see that it works quick well (the column resizing when you resize the header items). But my WM_NOTIFY methods to resize are always one step behind. This is something that I still have to figure out. I assume that when it triggers, it still has the previous width of the header item. EDIT: I fixed the listview/header sync with an Adlib registered in WM_NOTIFY which seems to work smoothly. #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> ; DPI DllCall("User32.dll", "bool", "SetProcessDpiAwarenessContext" , "HWND", "DPI_AWARENESS_CONTEXT" -2) Opt("MustDeclareVars", 1) ;0=no, 1=require pre-declaration Global $g_hGUI, $g_hChild Global $g_hHeader, $idListview Global $idLVi_Item1, $idLVi_Item2, $idLVi_Item3 Example() Func Example() $g_hGUI = GUICreate("Example", 400, 400, -1, -1, $WS_OVERLAPPEDWINDOW, $WS_EX_COMPOSITED) GUISetBkColor(0x202020) GUISetState(@SW_SHOW, $g_hGUI) $g_hChild = GUICreate("ChildWindow", 320, 320, 40, 40, $WS_CHILD, -1, $g_hGUI) GUISetBkColor(0x606060) $g_hHeader = _GUICtrlHeader_Create($g_hChild) _GUICtrlHeader_AddItem($g_hHeader, "Column1", 100) _GUICtrlHeader_AddItem($g_hHeader, "Column2", 100) _GUICtrlHeader_AddItem($g_hHeader, "Column3", 100) $idListview = GUICtrlCreateListView("col1|col2|col3 ", 0, 24, 320, 320, BitOR($GUI_SS_DEFAULT_LISTVIEW, $LVS_NOCOLUMNHEADER), BitOR($LVS_EX_DOUBLEBUFFER, $LVS_EX_FULLROWSELECT)) $idLVi_Item1 = GUICtrlCreateListViewItem("item1|item1|item1", $idListview) $idLVi_Item2 = GUICtrlCreateListViewItem("item2|item2|item2", $idListview) $idLVi_Item3 = GUICtrlCreateListViewItem("item3|item3|item3", $idListview) ; resize listview columns to match header widths _resizeLVCols() ;AdlibRegister("_resizeLVCols") GUIRegisterMsg($WM_NOTIFY, WM_NOTIFY) GUISetState(@SW_SHOW, $g_hChild) GUICtrlSendMsg($idListview, $WM_CHANGEUISTATE, 65537, 0) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete($g_hChild) GUIDelete($g_hGUI) EndFunc ;==>Example Func _resizeLVCols() _GUICtrlListView_SetColumnWidth($idListview, 0, _GUICtrlHeader_GetItemWidth($g_hHeader, 0)) _GUICtrlListView_SetColumnWidth($idListview, 1, _GUICtrlHeader_GetItemWidth($g_hHeader, 1)) _GUICtrlListView_SetColumnWidth($idListview, 2, _GUICtrlHeader_GetItemWidth($g_hHeader, 2)) GUICtrlSendMsg($idListview, $WM_CHANGEUISTATE, 65537, 0) EndFunc Func _resizeLVColsAdlib() _resizeLVCols() AdlibUnRegister("_resizeLVColsAdlib") EndFunc Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam) Local $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) Local $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $g_hHeader Switch $iCode Case $HDN_ENDTRACK, $HDN_ENDTRACKW AdlibRegister("_resizeLVColsAdlib", 5) ;_resizeLVCols() EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY
  19. Hi everyone, @WildByDesign I Did Not follow up the Changes in Win11 25H2. In fact, i just realized I'm still in 23H2, and my System would not find any Upgrades to higher versions. Looks like I have to do a in-place upgrade or smth. I’ll take a closer look at the changes for Windows 11 25H2, and many thanks for your improvements. Although I don’t yet fully understand why the checkbox icons for the ListView are necessary. Right now, I'm working on a v0.04 thanks to @argumentum great work with the preliminary implementation of text color in the ListView header, along with many other improvements. @argumentum You are right about me hitting a wall, but it’s more that I’ve been hitting a wall in real life. Back in early 2024, my sister had a motorbike accident and lost the love of her life. Since then, she was never the same again. The doctors didn’t recognize the signs quickly enough, which ultimately led to me losing her due to her severe depression. As you can imagine, this threw me completely off track, and it took me quite a while to get fully back on my feet again. To be honest, I had almost forgotten about this project, and I only remembered it recently while browsing through my Firefox bookmarks. Anyway, I hope we can continue improving this project a bit. Even though there are already many great UDFs for Dark Mode, it’s still interesting to see how far we can push the W32 Dark Mode implementation. Kind Regards, NoNameCode
  20. @argumentum Advanced IP Scanner was just a test, as it was something on my laptop in Program Files (x86). The real app of interest is some BMS app which is not widely available and which I do not have installed on my laptop. The app is a 32 bit app running on x64 windows.
  21. Local $sProgram = FileGetShortName("C:\Program Files (x86)\Advanced IP Scanner\advanced_ip_scanner.exe") FileGetShortName() would solve the spaces "problem". But either way, RunAs() did not behave as it used to for me ( thank you M$ ) I'd have to code something and test it out before telling you to do this or that. If you run a task in task scheduler "with highest privileges" it should work. You could rip that part from Control Viewer (mod.). and see if that works for you. Place it in the folder you're having problems with. By default, I don't install anything in the programs folder because is a pain with the permissions and all. .. am looking at Advanced IP Scanner and they have a free download but not a free version for me to test. ( I use my own Ping / discover local IPs ) Now, why would you need to run this as admin ?, is just a port scanner.
  22. @argumentum The site for UAC Pass is broken, I have managed to find a copy on the Net, but I don't have any documentation. Before I started trying to write an autoitscript, I tried using the Task Scheduler and I could not get that to work either. Can I ask what settings that you specify for the Scheduled Task?
  23. @argumentum Why """ because I thought I wanted the path, which has spaces, to being enclosed within one set of " I tried just using " instead and the path is now found, but the runas statement still doesn't launch the program. PID = 0. Reason unknown. I'll try UAC Pass. I actually tried using Task Scheduler (without Autoit) and without success before trying the script above. Thanks
  24. ..tested in 25H2 and I did not get it do run as admin. In any case, when I need to run as admin, I add it to task scheduler and save the user/pass there. "UAC Pass - bypass UAC prompts only for specific programs" may just do that you need.
  25. Why """C:\Program Files (x86)\Advanced IP Scanner\advanced_ip_scanner.exe""" ? Why not "C:\Program Files (x86)\Advanced IP Scanner\advanced_ip_scanner.exe" ?
  1. Load more activity
×
×
  • Create New...