-
Posts
3,955 -
Joined
-
Days Won
38
Community Answers
-
Andreik's post in Re-declaring AutoIt Constants locally was marked as the answer
I usually do this when I use few constants but if I use more functions and constants I include the whole UDF. If this is a bad idea? It really depends. If there is a function that is called every second it's not the best way. I hope to see soon in AutoIt implemented local static constants, so we can have something like this:
Func Test() Local Static Const $MB_OK = 0 ... EndFunc
-
Andreik's post in [Resolved] Help with script that truncates date, and fixing short date? was marked as the answer
The script it does exactly what it's suppose to do:
Local $sWkDay = StringRight($parametersDate, 3) This mean take 3 characters from the right of Mon.Nov.06.2023.
And this line does exactly nothing and will return an empty string.
Local $ShortDayMyFormat = StringMid("Sn,Mn,Tu,Wd,Th,Fr,Sa", StringInStr("SunMonTueWedThuFriSat", $sWkDay), 2) So when you replace $sWkDay with nothing, basically you strip the last 3 characters from the original string:
$parametersDate = StringReplace($parametersDate, $sWkDay, $ShortDayMyFormat) You probably want to get 3 characters from the left not from the right, so use:
Local $sWkDay = StringLeft($parametersDate, 3)
-
Andreik's post in Count down in For...Next loop? was marked as the answer
For $x = 90 To 65 Step -1 ... Next
-
Andreik's post in Inputbox not working? was marked as the answer
You get the answer if you read the documentation.
Use a custom GUI with an input or edit control and I think you are fine.
-
Andreik's post in Running Microsoft Photos application with Autoit3 was marked as the answer
ShellExecute('ms-photos:viewer?fileName={Your image path here}') or if your default app for certain file extension is already MS Photos you can simply use
ShellExecute('{Your image path here}') PS: brackets above mark a placeholder, you don't need them
-
Andreik's post in Two listview, delete the duplicated element. was marked as the answer
Not tested as a fully script but something like this:
#include <Array.au3> #include <GuiListView.au3> ; Create GUI here $aList1 = ListColumnToArray($cList1, 1) ; $cList1 - handle or ctrl id of the first list $aList2 = ListColumnToArray($cList2, 1) ; $cList2 - handle or ctrl id of the second list For $Index = 1 To $aList1[0] _ArraySearch($aList2, StringReplace($aList1[$Index], '.kml', '.srt')) If Not @error Then _GUICtrlListView_DeleteItem($cList1, $Index - 1) Next Func ListColumnToArray($List, $Column) Local $sData If $Column > _GUICtrlListView_GetColumnCount($List) Then Return SetError(1, 0, Null) Local $NumOfItems = _GUICtrlListView_GetItemCount($List) For $Index = 0 To $NumOfItems - 1 $sData &= _GUICtrlListView_GetItemText($List, $Index, $Column) & '|' Next Return StringSplit(StringTrimRight($sData, 1), '|') EndFunc
-
Andreik's post in Hold down Hotkey without repeating assigned function was marked as the answer
Well, if you want to suppress the key just use a keyboard hook:
#include <WindowsConstants.au3> #include <WinAPISys.au3> #include <WinAPIConstants.au3> Global $bExit = False $hKeyboardProc = DllCallbackRegister('KeyboardProc', 'long', 'int;wparam;lparam') $hHook = _WinAPI_SetWindowsHookEx($WH_KEYBOARD_LL, DllCallbackGetPtr($hKeyboardProc), _WinAPI_GetModuleHandle(0)) Do Sleep(10) Until $bExit _WinAPI_UnhookWindowsHookEx($hHook) DllCallbackFree($hKeyboardProc) Func KeyboardProc($nCode, $wParam, $lParam) If $nCode < 0 Then Return _WinAPI_CallNextHookEx($hHook, $nCode, $wParam, $lParam) Local $tKEYHOOKS = DllStructCreate('dword vkCode;dword scanCode;dword flags;dword time;ulong_ptr dwExtraInfo', $lParam) Switch $wParam Case $WM_KEYDOWN If $tKEYHOOKS.vkCode = 0x1B Then $bExit = True If $tKEYHOOKS.vkCode = 0xBB Then ConsoleWrite('= is pressed down' & @CRLF) Return 1 EndIf Case $WM_KEYUP If $tKEYHOOKS.vkCode = 0xBB Then ConsoleWrite('= is released' & @CRLF) Return 1 EndIf EndSwitch Return _WinAPI_CallNextHookEx($hHook, $nCode, $wParam, $lParam) EndFunc
-
Andreik's post in convert array to list was marked as the answer
Example for first two columns, you can do it for all columns:
#include <Excel.au3> $hGUI = GUICreate('Test', 600, 400) $cList = GUICtrlCreateListView('Cámara|7/12/2024', 10, 10, 580, 380) GUISetState(@SW_SHOW, $hGUI) LoadExcel($cList, @ScriptDir & '\test.xlsx') Do Until GUIGetMsg() = -3 Func LoadExcel($cList, $sPath) Local $oExcel =_Excel_Open(False) Local $oWorkbook = _Excel_BookOpen($oExcel, $sPath) Local $vData = _Excel_RangeRead($oWorkbook) If Not IsArray($vData) Then Return SetError(1, 0, 0) For $Index = 1 To UBound($vData) - 1 GUICtrlCreateListViewItem($vData[$Index][0] & '|' & $vData[$Index][1], $cList) Next _Excel_BookClose($oWorkbook) _Excel_Close($oExcel) EndFunc
-
Andreik's post in _GUICtrlRichEdit_SetText (No Undo) was marked as the answer
I'm not sure what are you talking about. Selection has nothing to do with undo, as you can see below:
#include <GUIConstantsEx.au3> #include <GuiRichEdit.au3> #include <WindowsConstants.au3> Local $hGui = GUICreate("RichEdit Get/Set Text (v" & @AutoItVersion & ")", 340, 350) Local $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 320, 220, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) GUISetState(@SW_SHOW) Sleep(5000) _GUICtrlRichEdit_SetText2($hRichEdit, "This is Set text.", True) Sleep(5000) _GUICtrlRichEdit_Undo($hRichEdit) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE _GUICtrlRichEdit_Destroy($hRichEdit) Func _GUICtrlRichEdit_SetText2($hWnd, $sText, $bCanUndo = False) If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False) Local $tSetText = DllStructCreate($tagSETTEXTEX) DllStructSetData($tSetText, 1, ($bCanUndo ? $ST_KEEPUNDO : $ST_DEFAULT)) DllStructSetData($tSetText, 2, $CP_ACP) Local $iRet If StringLeft($sText, 5) <> "{\rtf" And StringLeft($sText, 5) <> "{urtf" Then DllStructSetData($tSetText, 2, $CP_UNICODE) $iRet = _SendMessage($hWnd, $EM_SETTEXTEX, $tSetText, $sText, 0, "struct*", "wstr") Else $iRet = _SendMessage($hWnd, $EM_SETTEXTEX, $tSetText, $sText, 0, "struct*", "STR") EndIf If Not $iRet Then Return SetError(700, 0, False) Return True EndFunc
-
Andreik's post in TAB in Inputbox was marked as the answer
Here is a hacky way:
#include <WinAPISysWin.au3> #include <GuiEdit.au3> HotKeySet('{TAB}', 'Tab') $hGUI = GUICreate('Test') $cInput1 = GUICtrlCreateInput('test', 100, 100, 150, 25) $hInput1 = GUICtrlGetHandle($cInput1) $cInput2 = GUICtrlCreateInput('', 100, 200, 150, 25) $cInput3 = GUICtrlCreateInput('', 100, 300, 150, 25) GUISetState() Do Until GUIGetMsg() = -3 Func Tab() HotKeySet('{TAB}') If _WinAPI_GetFocus() = $hInput1 Then _GUICtrlEdit_ReplaceSel($hInput1, @TAB) Else Send('{TAB}') EndIf HotKeySet('{TAB}', 'Tab') EndFunc
-
Andreik's post in code to create file folders according to their extension and move them to the corresponding folders was marked as the answer
It should be easy to check and exclude some extensions:
#include <File.au3> CreateExtDirs(@ScriptDir) Func CreateExtDirs($sPath, $fRec = False) Local $aFile = _FileListToArrayRec(@ScriptDir, Default, $FLTAR_FILES, ($fRec ? $FLTAR_RECUR : $FLTAR_NORECUR), $FLTAR_NOSORT, $FLTAR_FULLPATH) If @error Then Return SetError(1, 0, 0) Local $sDrive, $sDir, $sFileName, $sExt, $sExtDir, $vIdx = '' For $Index = 1 To $aFile[0] $vIdx = '' _PathSplit($aFile[$Index], $sDrive, $sDir, $sFileName, $sExt) If StringLower($sExt) = '.au3' Or StringLower($sExt) = '.exe' Then ContinueLoop $sExtDir = @ScriptDir & '\' & StringReplace($sExt, '.', '') If Not FileExists($sExtDir) Then DirCreate($sExtDir) While FileExists($sExtDir & '\' & $sFileName & $vIdx & $sExt) $vIdx += 1 WEnd FileMove($aFile[$Index], $sExtDir & '\' & $sFileName & $vIdx & $sExt) Next EndFunc Note that you can also pass wanted extensions to _FileListToArrayRec().
-
Andreik's post in Replace characters from right side of the string was marked as the answer
Something like this?
Local $String[8] $String[0] = 'GROUP_hmz.tmp___\hmz7______________0035' $String[1] = 'GROUP_hmz.tmp___\hmz7TT_______0035__10' $String[2] = 'AAAALLLL\ainm1___all_____falef__________0075' $String[3] = 'AAAALLLL\ainm31___all_____falef_______0075_22' $String[4] = 'ALL_1_\tem.Qm_________0102' $String[5] = 'ALL_1_\temQ1_________0111' $String[6] = 'NONE_2_All.t__\amm.rfw_______________0551_21' $String[7] = 'NONE_2_All.t__\fem.bb__back_________0554' For $Increment = 0 To UBound($String) - 1 ConsoleWrite(StringRegExpReplace($String[$Increment], '(\_+\d+(?:\_+\d+)*)$', '-------' & StringFormat('%04s', $Increment + 1)) & @CRLF) Next
-
Andreik's post in Create a bitmap object with a chequered background using GDI+ was marked as the answer
Maybe posting a specific question without unnecessary code increase the chances that you will receive a fast answer from other users. Anyway, here is a demo that should help you. Make the necessary changes to fit your project.
#include <GDIPlus.au3> _GDIPlus_Startup() Global $hDisplay = _GDIPlus_BitmapCreateFromScan0(178, 146) Global $hGraphics1 = _GDIPlus_ImageGetGraphicsContext($hDisplay) Global $hColor = _GDIPlus_BitmapCreateFromScan0(178, 146) Global $hGraphics2 = _GDIPlus_ImageGetGraphicsContext($hColor) Global $hTransparent = _GDIPlus_BitmapCreateFromFile(@ScriptDir & '\transparent.bmp') Global $hGUI, $cPic, $cSlider, $hSlider, $cDummy $hGUI = GUICreate('Example', 198, 250) $cPic = GUICtrlCreatePic('', 10, 10, 178, 146) $cSlider = GUICtrlCreateSlider(10, 165, 178, 40) $hSlider = GUICtrlGetHandle($cSlider) $cColor = GUICtrlCreateInput('D62828', 10, 215, 178, 25, 0x01) $cDummy = GUICtrlCreateDummy() GUICtrlSetLimit($cSlider, 255, 0) GUICtrlSetFont($cColor, 12) GUICtrlSetData($cSlider, 127) GUISetState(@SW_SHOW, $hGUI) GUIRegisterMsg(0x0114, 'WM_HSCROLL') UpdateColor() While True Switch GUIGetMsg() Case $cDummy If GUICtrlRead($cDummy) = $cSlider Then UpdateColor() Case -3 ExitLoop EndSwitch WEnd _GDIPlus_GraphicsDispose($hGraphics1) _GDIPlus_GraphicsDispose($hGraphics2) _GDIPlus_BitmapDispose($hTransparent) _GDIPlus_BitmapDispose($hColor) _GDIPlus_BitmapDispose($hDisplay) _GDIPlus_Shutdown() Func UpdateColor() Local $sColor = GUICtrlRead($cColor) Local $iAlpha = GUICtrlRead($cSlider) _GDIPlus_GraphicsDrawImageRect($hGraphics1, $hTransparent, 0, 0, 178, 146) _GDIPlus_GraphicsClear($hGraphics2, '0x' & Hex($iAlpha, 2) & $sColor) _GDIPlus_GraphicsDrawImageRect($hGraphics1, $hColor, 0, 0, 178, 146) ImageToCtrl($hDisplay, $cPic) GUICtrlSetTip($cSlider, $iAlpha) EndFunc Func ImageToCtrl($hBitmap, $cCtrl) Local $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _WinAPI_DeleteObject(GUICtrlSendMsg($cCtrl, 0x0172, 0, $hHBITMAP)) _WinAPI_DeleteObject($hHBITMAP) EndFunc Func WM_HSCROLL($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Switch $lParam Case $hSlider GUICtrlSendToDummy($cDummy, $cSlider) EndSwitch EndFunc
-
Andreik's post in form with image background with several .png image buttons was marked as the answer
Not really a button but something that might work well in your case.
#include <GUIConstantsEx.au3> #include <GDIPlus.au3> Global $Info, $ButtonHover = False _GDIPlus_Startup() Local $hMain = GUICreate("Image", 400, 200) Local $cBackground = GUICtrlCreatePic(@ScriptDir & '\background.jpg', 0, 0, 400, 200) ; Background image GUICtrlSetState($cBackground, $GUI_DISABLE) Local $cButton = GUICtrlCreatePic('', 50, 50, 50, 50) ImageToCtrl(@ScriptDir & '\button.png', $cButton) GUISetState(@SW_SHOW, $hMain) While True Switch GUIGetMsg() Case $cButton MsgBox(0, '', 'You clicked me?') Case $GUI_EVENT_CLOSE _GDIPlus_Shutdown() Exit EndSwitch $Info = GUIGetCursorInfo($hMain) If Not IsArray($Info) Then ContinueLoop If $Info[4] = $cButton Then If Not $ButtonHover Then $ButtonHover = True ;~ You can upscale control here ImageToCtrl(@ScriptDir & '\hover.png', $cButton) ; Hovered button image EndIf Else If $ButtonHover Then $ButtonHover = False ;~ You can downscale control here ImageToCtrl(@ScriptDir & '\button.png', $cButton) ; Normal button image EndIf EndIf WEnd Func ImageToCtrl($sImage, $cCtrl) Local $hImage = _GDIPlus_ImageLoadFromFile($sImage) Local $iWidth = _GDIPlus_ImageGetWidth($hImage) Local $iHeight = _GDIPlus_ImageGetHeight($hImage) Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight) Local $hGraphics = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsDrawImageRect($hGraphics, $hImage, 0, 0, $iWidth, $iHeight) Local $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _WinAPI_DeleteObject(GUICtrlSendMsg($cCtrl, 0x0172, 0, $hHBITMAP)) _WinAPI_DeleteObject($hHBITMAP) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_ImageDispose($hImage) EndFunc If you want multiple "buttons" you can create a multidimensional array to store the control ID and current hover state for each control.
-
Andreik's post in _GUICtrlEdit_SetText and how it handles @CRLF and @CR differently was marked as the answer
Don't be tricked by what you see, everything works as expected, you get exactly what you set (convert the string returned by _GUICtrlEdit_GetText() to binary if you want to be sure). If you want a different end of line character and you have at least Win 10 then look at EM_GETENDOFLINE and EM_SETENDOFLINE.
-
Andreik's post in IF variable contains @ symbol THEN was marked as the answer
Read in help file about StringInStr().
-
Andreik's post in GDIplus Transparent GUI and Opaque Shape was marked as the answer
Here is an adaptation based this code
#include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Global Const $SC_DRAGMOVE = 0xF012 HotKeySet("{ESC}", _Exit) _GDIPlus_Startup() $myWidth = 800 $myHeight = 800 $hGUI = GUICreate('', $myWidth, $myHeight, -1, -1, $WS_POPUP, $WS_EX_LAYERED) GUISetState() $hBitmap = _GDIPlus_BitmapCreateFromScan0(300, 300) $hGraphic = _GDIPlus_ImageGetGraphicsContext($hBitmap) $hBrush = _GDIPlus_BrushCreateSolid(0xFF0000FF) _GDIPlus_GraphicsFillPie($hGraphic, 150, 80, 100, 100, 45, 90, $hBrush) _GDIPlus_GraphicsDispose($hGraphic) $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _WinAPI_BitmapDisplayTransparentInGUI($hHBitmap, $hGUI, 255) GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _Exit() EndSwitch WEnd Func _WinAPI_BitmapDisplayTransparentInGUI(ByRef $hHBitmap, ByRef $hGUI, $iOpacity = 0xFF, $bReleaseGDI = True) If Not BitAND(GUIGetStyle($hGUI)[1], $WS_EX_LAYERED) = $WS_EX_LAYERED Then Return SetError(1, 0, 0) Local $tDim = DllStructCreate($tagBITMAP) If Not _WinAPI_GetObject($hHBitmap, DllStructGetSize($tDim), DllStructGetPtr($tDim)) Then Return SetError(2, 0, 0) Local $tSize = DllStructCreate($tagSIZE), $tSource = DllStructCreate($tagPOINT), $tBlend = DllStructCreate($tagBLENDFUNCTION) Local Const $hScrDC = _WinAPI_GetDC(0), $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC), $hOld = _WinAPI_SelectObject($hMemDC, $hHBitmap) $tSize.X = $tDim.bmWidth $tSize.Y = $tDim.bmHeight $tBlend.Alpha = $iOpacity $tBlend.Format = 1 _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, DllStructGetPtr($tSize), $hMemDC, DllStructGetPtr($tSource), 0, DllStructGetPtr($tBlend), $ULW_ALPHA) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteDC($hMemDC) If $bReleaseGDI Then _WinAPI_DeleteObject($hHBitmap) Return True EndFunc Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam) _SendMessage($hGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0) EndFunc ;==>_WM_LBUTTONDOWN Func _Exit() _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_Shutdown() Exit EndFunc
-
Andreik's post in Function not working with array was marked as the answer
In first example you are calling Clicking with a single parameter and below your function has at least 2 mandatory parameters ($x, $y) out of 4 parameters. Isn't this self explanatory?
If you want to use the first example then your function should look like this:
Local $aClicks[3][4] = [[100, 100, "Test", 1000] _ , [200, 200, " Test2", 1500] _ , [200, 200, " Test3", 2000]] Clicking($aClicks) Func Clicking($aClicks) ; Your code here EndFunc Or if you want to preserve your original function with 4 parameters you can do something like this:
Local $aClicks[3][4] = [[100, 100, "Test", 1000] _ , [200, 200, " Test2", 1500] _ , [200, 200, " Test3", 2000]] ClickingArray($aClicks) Func ClickingArray($aClicks) For $Index = 0 To UBound($aClicks) - 1 Clicking($aClicks[$Index][0], $aClicks[$Index][1], $aClicks[$Index][2], $aClicks[$Index][3]) Next EndFunc Func Clicking($x, $y, $s = "", $z = 1000) ; Your original function EndFunc
-
Andreik's post in Sorting a string numerically and alphabetically was marked as the answer
Something like this?
#include <Array.au3> Local $aData = StringSplit('2|3|4|4 Part|7|8|9|12|13|15|21|28|31|35|OB1|NORTH|SOUTH|BORDER|3 Part|4 Past', '|', 2) NaturalCompare($aData) _ArrayDisplay($aData) Func NaturalCompare(ByRef $aData) Local $vTemp, $i, $j Local $hDll = DllOpen('Shlwapi.dll') For $i = 1 To UBound($aData) - 1 $j = $i While $j > 0 And DllCall($hDll, "int", "StrCmpLogicalW", "wstr", $aData[$j-1], "wstr", $aData[$j])[0] <> -1 $vTemp = $aData[$j] $aData[$j] = $aData[$j-1] $aData[$j-1] = $vTemp $j -= 1 WEnd Next DllClose($hDll) EndFunc
-
Andreik's post in How to obtain the text of application with the code of the Autoit v3 Windows Information - (Moved) was marked as the answer
Because BluffTitler it's the window class. Try this:
$hWin = WinWait('[CLASS:BluffTitler]') ConsoleWrite('Window handle: ' & $hWin & @CRLF) $sText = ControlGetText($hWin, '', 'ComboBox1') ConsoleWrite('ComboBox Text: ' & $sText & @CRLF) or directly using the window's class instead of the handle:
$sText = ControlGetText('[CLASS:BluffTitler]', '', 'ComboBox1') ConsoleWrite('ComboBox Text: ' & $sText & @CRLF)
-
Andreik's post in ID3 tags act weird was marked as the answer
It looks like you have a null char at the end of the string. You can do something like this to delete all trailing null chars:
$sTrackArtist = BinaryToString(StringRegExpReplace(StringToBinary($sTrackArtist), '(00)+$', '')) MsgBox(0, "id3", $sTrackArtist & " - " & $sTrackTitle)
-
Andreik's post in Fastest Way to Delete Empty Records in 1d Array was marked as the answer
Since _ArrayToString() already traverse the entire array you can do it by yourself and meanwhile keep just non empty data:
#include <Array.au3> $array = Get_Array() _ArrayDisplay($array) $array = StripEmptyRecords($array, 0) _ArrayDisplay($array) Func Get_Array() Local $array[7] $array[0] = "12345" $array[1] = "01621" $array[2] = "xyz" $array[3] = "abc@defg.com" $array[4] = " john smith" $array[5] = " sally turner " $array[5] = " " $array[6] = "zxy" Return $array EndFunc ;==>Get_Array Func StripEmptyRecords(ByRef $aData, $iStart) If Not IsArray($aData) Then Return SetError(1, 0, False) Local $iElements = UBound($aData) If $iStart >= $iElements Then Return SetError(2, 0, False) Local $sResult For $Index = $iStart To $iElements - 1 $sResult &= (StringStripWS($aData[$Index], 8) ? $aData[$Index] & '|' : '') Next Return StringSplit(StringTrimRight($sResult, 1), '|', 2) EndFunc
-
Andreik's post in Memory leak with GUICtrlSendMsg and Picture control was marked as the answer
You need to delete the object returned by GUICtrlSendMsg().
_WinAPI_DeleteObject(GUICtrlSendMsg($img, 0x0172, 0, $bitmap_3))
The message you send to the control is STM_SETIMAGE and doesn't star/stop anything but set a new image. The third parameter is IMAGE_BITMAP and specifies the type of image to associate with the control. Also the return value is a handle to the image previously associated with the control (or NULL) so it must be deleted properly.
-
Andreik's post in read XML file was marked as the answer
Local $oXML = ObjCreate('Microsoft.XMLDOM') If IsObj($oXML) Then $oXML.load("PrixCarburants_test.xml") $oXML.setProperty('SelectionLanguage', 'XPath') $oNodes = $oXML.selectNodes('/pdv_liste/pdv') For $oNode In $oNodes ConsoleWrite('Latitude: ' & $oNode.getAttribute('latitude') & @CRLF) ConsoleWrite('Longitude: ' & $oNode.getAttribute('longitude') & @CRLF) ConsoleWrite('CP: ' & $oNode.getAttribute('cp') & @CRLF) ConsoleWrite('Address: ' & $oNode.selectSingleNode('adresse').text & @CRLF) ConsoleWrite('Ville: ' & $oNode.selectSingleNode('ville').text & @CRLF) ConsoleWrite('Horaires: ' & @CRLF) $oJours = $oNode.selectNodes('horaires/jour') For $oJour In $oJours $oHoraire = $oJour.selectSingleNode('horaire') $sJour = $oJour.getAttribute('nom') $sOverture = $oHoraire.getAttribute('ouverture') $sFermeture = $oHoraire.getAttribute('fermeture') ConsoleWrite($sJour & ' (Ouverture: ' & $sOverture & ', Fermeture: ' & $sFermeture & @CRLF) Next $oServices = $oNode.selectNodes('services/service') For $oService In $oServices ConsoleWrite('Service: ' & $oService.text & @CRLF) Next $oPrixCol = $oNode.selectNodes('prix') For $oPrix In $oPrixCol $sPrixNom = $oPrix.getAttribute('nom') $sPrixId = $oPrix.getAttribute('id') $sPrixMaj = $oPrix.getAttribute('maj') $sPrixVal = $oPrix.getAttribute('valeur') ConsoleWrite('Prix: ' & $sPrixNom & ' (ID: ' & $sPrixId & ', Maj: ' & $sPrixMaj & ', Valeur: ' & $sPrixVal & @CRLF) Next ConsoleWrite(@CRLF) Next Else ConsoleWrite('Invalid XML object.' & @CRLF) EndIf Or a regex version:
$sData = FileRead('PrixCarburants_test.xml') $aPDV = StringRegExp($sData, '(?is)(<pdv (?:.*?)<\/pdv>)', 3) If IsArray($aPDV) Then For $Index = 0 To UBound($aPDV) - 1 $vLatitude = StringRegExp($aPDV[$Index], '(?i)<pdv(?:.*?)latitude="(\d+)"(?:.*?)>', 3) If Not @error Then ConsoleWrite('Latitude: ' & $vLatitude[0] & @CRLF) $vLongitude = StringRegExp($aPDV[$Index], '(?i)<pdv(?:.*?)longitude="(\d+)"(?:.*?)>', 3) If Not @error Then ConsoleWrite('Longitude: ' & $vLongitude[0] & @CRLF) $vCP = StringRegExp($aPDV[$Index], '(?i)<pdv(?:.*?)cp="(\d+)"(?:.*?)>', 3) If Not @error Then ConsoleWrite('CP: ' & $vCP[0] & @CRLF) $vAdresse = StringRegExp($aPDV[$Index], '(?i)<adresse>(.*?)<\/adresse>', 3) If Not @error Then ConsoleWrite('Adresse: ' & $vAdresse[0] & @CRLF) $vVille = StringRegExp($aPDV[$Index], '(?i)<ville>(.*?)<\/ville>', 3) If Not @error Then ConsoleWrite('Ville: ' & $vVille[0] & @CRLF) ; Horaires $aHoraires = StringRegExp($aPDV[$Index], '(?is)(<jour.*?<\/jour>)', 3) If IsArray($aHoraires) Then ConsoleWrite('Horaires: ' & @CRLF) For $iJour = 0 To UBound($aHoraires) - 1 $vJourNom = StringRegExp($aHoraires[$iJour], '(?i)nom="(.*?)"', 3) If Not @error Then ConsoleWrite(' ' & $vJourNom[0] & @CRLF) $vOuverture = StringRegExp($aHoraires[$iJour], '(?i)ouverture="(.*?)"', 3) If Not @error Then ConsoleWrite(@TAB & 'Ouverture: ' & $vOuverture[0] & @CRLF) $vFermeture = StringRegExp($aHoraires[$iJour], '(?i)fermeture="(.*?)"', 3) If Not @error Then ConsoleWrite(@TAB & 'Fermeture: ' & $vFermeture[0] & @CRLF) Next EndIf ; Services $aServices = StringRegExp($aPDV[$Index], '(?is)<service>(.*?)<\/service>', 3) If IsArray($aServices) Then For $iService = 0 To UBound($aServices) - 1 ConsoleWrite('Service: ' & $aServices[$iService] & @CRLF) Next EndIf ; Prix $aPrix = StringRegExp($aPDV[$Index], '(?is)<prix(.*?)\/>', 3) If IsArray($aPrix) Then For $iPrix = 0 To UBound($aPrix) - 1 $vPrixNom = StringRegExp($aPrix[$iPrix], '(?i)nom="(.*?)"', 3) If Not @error Then ConsoleWrite('Prix: ' & $vPrixNom[0] & @CRLF) $vPrixID = StringRegExp($aPrix[$iPrix], '(?i)id="(.*?)"', 3) If Not @error Then ConsoleWrite(' ID: ' & $vPrixID[0] & @CRLF) $vPrixMaj = StringRegExp($aPrix[$iPrix], '(?i)maj="(.*?)"', 3) If Not @error Then ConsoleWrite(' Maj: ' & $vPrixMaj[0] & @CRLF) $vPrixValeur = StringRegExp($aPrix[$iPrix], '(?i)valeur="(.*?)"', 3) If Not @error Then ConsoleWrite(' Valeur: ' & $vPrixValeur[0] & @CRLF) Next EndIf ConsoleWrite(@CRLF) Next EndIf
-
Andreik's post in Automate ComboBox using UI Automation was marked as the answer
#include <GuiComboBox.au3> WinWait('Connect to Server') $hCtrl = ControlGetHandle('Connect to Server', '', '[REGEXPCLASS:WindowsForms10\.COMBOBOX\.app(.*?)_ad1; INSTANCE:1]') $aItem = _GUICtrlComboBox_GetListArray($hCtrl) If IsArray($aItem) Then For $Index = 1 To $aItem[0] ConsoleWrite($aItem[$Index] & @CRLF) Next EndIf ; Select new string in combo _GUICtrlComboBox_SelectString($hCtrl, 'Analysis Services') Tested with SSMS 20.0.70.0