Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/10/2021 in all areas

  1. Still adding it in by your developers is a lot of googling around in bits and pieces on how for example automationid can be set for WPF <ListView IsEnabled="{Binding TestSelectorEnabled}" x:Name="ListView1" ItemsSource="{Binding TestsDataTable}" SelectedValue="{Binding SelectedTest}" SelectedValuePath="TestName" Height="180" View="{Binding GridView}" TabIndex="0" MinWidth="1" Focusable="False"> <ListView.ItemContainerStyle> <Style TargetType="ListViewItem"> <Setter Property="AutomationProperties.AutomationId" Value="{Binding Path=DataContext.TestsViewModel.ListItemCounter, StringFormat='dataitem{0:F0}', UpdateSourceTrigger=PropertyChanged, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListView}}"/> </Style> </ListView.ItemContainerStyle> </ListView> https://cmakara.github.io/posts/how-to-set-automationid-for-treeviewitems-in-wpf Even for HTML 5 I have never found an easy reference for UIA and what developers should add to their HTML to get automationid in UIA nicely filled (id seems best but then automationid jumps sometimes from textbox element to a div element and still have then to search the next innerchild with a treewalker. https://www.w3.org/TR/core-aam-1.2/#mapping_state-property_table is the best part I found for HTML. Would be nice if it could be handled more with UIA so then no mix of webdriver and UIA stuff in framework.
    2 points
  2. By default, no UIA code in C# or VB.NET applicationsNote that an example GUI created as described in first post will generally not contain UIA code to automate the controls. Only standard Windows controls that can already be automated with classic code will also be able to automate with UIA code. Other controls including all the interesting .NET controls, e.g. the DataGridView control, which is not derived from the standard controls, can only be automated with MSAA code. By default, a program created with C# or VB.NET code will not contain UIA code except for the standard Windows controls. Otherwise only MSAA code. At top of this post is an example with the DataGridView control, which clearly demonstrates this. tst00.vb and tst00.au3 can be found in GridControls.7z at bottom of said post. Running tst00.au3 creates a GUI like this: UIASpy shows the element tree structure for all controls throughout the GUI as follows: 0000 Window: WindowsForms10.Window.8.app.0.3e799b_r35_ad1 0001 Pane: WindowsForms10.Window.8.app.0.3e799b_r35_ad1 0002 Button: Add Row 0003 Button: Delete Row 0004 Table: DataGridView 0005 Custom: Top Row 0006 Header: Title 0007 Header: Artist 0008 Header: Album 0009 Header: Release Date 0010 Header: Track 0011 Custom: Row 0 0012 Custom: Title Row 0 0013 Custom: Artist Row 0 0014 Custom: Album Row 0 0015 Custom: Release Date Row 0 0016 Custom: Track Row 0 0017 Custom: Row 1 0018 Custom: Title Row 1 0019 Custom: Artist Row 1 0020 Custom: Album Row 1 0021 Custom: Release Date Row 1 0022 Custom: Track Row 1 0023 Custom: Row 2 0024 Custom: Title Row 2 0025 Custom: Artist Row 2 0026 Custom: Album Row 2 0027 Custom: Release Date Row 2 0028 Custom: Track Row 2 0029 Custom: Row 3 0030 Custom: Title Row 3 0031 Custom: Artist Row 3 0032 Custom: Album Row 3 0033 Custom: Release Date Row 3 0034 Custom: Track Row 3 0035 Custom: Row 4 0036 Custom: Title Row 4 0037 Custom: Artist Row 4 0038 Custom: Album Row 4 0039 Custom: Release Date Row 4 0040 Custom: Track Row 4 0041 Custom: Row 5 0042 Custom: Title Row 5 0043 Custom: Artist Row 5 0044 Custom: Album Row 5 0045 Custom: Release Date Row 5 0046 Custom: Track Row 5 0047 Custom: Row 6 0048 Custom: Title Row 6 0049 Custom: Artist Row 6 0050 Custom: Album Row 6 0051 Custom: Release Date Row 6 0052 Custom: Track Row 6 0053 Custom: Row 7 0054 Custom: Title Row 7 0055 Custom: Artist Row 7 0056 Custom: Album Row 7 0057 Custom: Release Date Row 7 0058 Custom: Track Row 7 0059 TitleBar 0060 MenuBar: System 0061 MenuItem: System 0062 Button: Minimize 0063 Button: Maximize 0064 Button: Close Recognized controls can be automated with UIA code. Custom controls can only be automated with MSAA code. The $UIA_ProviderDescriptionPropertyId, which is a text string, provides some information about how a window or control can be automated: [pid:4496,hwnd:0x602D2 Main:Nested [pid:2976,hwnd:0x602D2 Main(parent link):Microsoft: MSAA Proxy (unmanaged:uiautomationcore.dll)]; Nonclient:Microsoft: Non-Client Proxy (unmanaged:uiautomationcore.dll); Hwnd(parent link):Microsoft: HWND Proxy (unmanaged:uiautomationcore.dll)] If the string contains Proxy substrings such as Microsoft: MSAA Proxy or Microsoft: HWND Proxy, it can be automated with MSAA code or classic code. There are many different of these Proxy substrings. To add more UIA code to the program take a look at the UI Automation Provider Programmer's Guide. It's not necessarily completely trivial. I don't know if it's possible through Visual Studio to more easily add at least default UIA code to actual .NET controls implemented in C# or VB.NET. Maybe junkew or Earthshine know something about this. At first glance, I think it's easier to test with existing programs that already contain more complete UIA code e.g. File Explorer and Calculator. Whether testing with File Explorer and Calculator or with .NET programs is completely indifferent to the UIA code. The UIA code to click a button, a menu item, set a selection in a table, or expand/collapse a treeview control element as well as other automation actions is exactly the same for all programs, as long as the controls support the required UIA code. In UIA code, automation actions as mentioned above are implemented through pattern interfaces. There are already a number of examples of the use of these automation actions and similar pattern interfaces in this post. Then it might be the easiest place to start. If you want, you can test some of the examples in other programs.
    2 points
  3. benners

    ini file problem

    Using the file you posted which should be in the same dir as the script I can get the inputs to load and any saved values written to the file. #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <File.au3> $Form1 = GUICreate("Form1", 255, 96, 1384, 290) $Button1 = GUICtrlCreateButton("Guardar", 56, 40, 137, 25) $r_largo = GUICtrlCreateInput("", 24, 8, 100, 21) $r_ancho = GUICtrlCreateInput("", 128, 8, 100, 21) ReadFromINI() GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 WriteToIni() EndSwitch WEnd Func WriteToIni() Local $as_Ini = 0 Local $s_IniFile = @ScriptDir & '\Config.ini.txt' _FileReadToArray($s_IniFile, $as_Ini) For $i = 1 To $as_Ini[0] If StringInStr($as_Ini[$i], 'screen_x') Then $as_Ini[$i] = StringRegExpReplace($as_Ini[$i], '[\d-]+$', GUICtrlRead($r_largo)) If StringInStr($as_Ini[$i], 'screen_y') Then $as_Ini[$i] = StringRegExpReplace($as_Ini[$i], '[\d-]+$', GUICtrlRead($r_ancho)) Next _FileWriteFromArray($s_IniFile, $as_Ini, 1) EndFunc ;==>Ini Func ReadFromINI() Local $as_Ini = 0 Local $s_IniFile = @ScriptDir & '\Config.ini.txt' _FileReadToArray($s_IniFile, $as_Ini) For $i = 1 To $as_Ini[0] If StringInStr($as_Ini[$i], 'screen_x') Then GUICtrlSetData($r_largo, StringRegExp($as_Ini[$i], '[\d-]+$', $STR_REGEXPARRAYMATCH)[0]) If StringInStr($as_Ini[$i], 'screen_y') Then GUICtrlSetData($r_ancho, StringRegExp($as_Ini[$i], '[\d-]+$', $STR_REGEXPARRAYMATCH)[0]) Next EndFunc
    1 point
  4. Launch the program and then use a Do... Until loop to loop until the login window exists. Inside the loop, use WinGetHandle to check if the pop-up exists and if so click the OK button. After the If statement checking for the pop-up add a sleep for 10 seconds. Quick example: Run('Program.exe') Do Local $hWnd = WinGetHandle('Pop-up Window Title') If IsHWnd($hWnd) = 1 Then If WinActive($hWnd) = 0 Then WinActivate($hWnd) ControlClick($hWnd, '', '[CLASS:Button; INSTANCE:1]') EndIf Sleep(10000) Until WinExists('Login Window Title') = 1
    1 point
  5. Because you're deleting array elements you're getting an errors when trying to access missing subscripts . You have to process the loop backwards #include <Array.au3> Global $astring = ["aaa_string","bbb_string","ccc_string","ddd_string","eee_string","fff_string"] For $i = UBound($astring)-1 To 0 Step -1 If StringInStr($astring[$i],"ccc",1)<>0 Then _ArrayDelete($astring,$i) _ArrayDisplay($astring, "Ex:2 Inner check") EndIf Next _ArrayDisplay($astring, "Ex:2 Outer check")
    1 point
  6. What's New in Version 0.2021.12.10 Fixed: signing would not sign other than SHA1. It can now sign SHA256 and greater.
    1 point
  7. @mLipokActually, it doesn't, at least not in the way I meant. You are detecting the failure in _WD_CreateSession. I was suggesting that it could be done sooner in _WD_Startup, which uses Run() to launch the web driver, but it doesn't perform any further checks to make sure that the app hasn't exited with an error code.
    1 point
  8. @Larsjm you are correct in that C# WPF apps do not automatically provide for client utilization of UIAutomation. The app developer can add that in. UI Automation Overview - .NET Framework | Microsoft Docs UI Automation of a Custom Control - WPF .NET Framework | Microsoft Docs Server-Side UI Automation Provider Implementation - .NET Framework | Microsoft Docs
    1 point
  9. I'd say that it's the script writer's responsibility to perform these checks. However, the UDF could do a better job of detecting that the webdriver console exited with errors. No worries. Just don't let it happen again! 😜
    1 point
  10. I seem to understand it. $sSelector is a child element and $sStartElement is the parent element. Similar to that of the jquery : $('StartElement').find('Selector')...
    1 point
  11. Good point about the iniread. You could use a static local variable to hold the value. The ini will be read once when the variable is initialised, after that it is ignored and the value will just be returned. You can then remove the first call to the function in the script and start it from the DirCreate line. Func GetCachePath() Local Static $s_CachePath = IniRead(@WorkingDir & '\USBTool.ini', "Settings", "CachePath", @WorkingDir & '\cache') & '\' Return $s_CachePath EndFunc ;==>GetCachePath For me, using _FileReadToArray is easier. No need to ubound to get the total. An example below using the GetCachePath above Func DiskList() RunWait('cmd /c diskpart /s ' & '"' & GetCachePath() & 'list.ini' & '"' & '>' & '"' & GetCachePath() & 'dpoutput.txt' & '"', @WorkingDir, @SW_HIDE) Local $as_diskpart = 0 Local $s_Filtered = '' ; read the file to an array _FileReadToArray(GetCachePath() & 'dpoutput.txt', $as_diskpart) ; loop through the array For $i = 1 To $as_diskpart[0] If StringRegExp($as_diskpart[$i], '(?i)Disk [\d]+') Then $s_Filtered &= $as_diskpart[$i] & '|' Next ; return the filtered string Return StringRegExpReplace($s_Filtered, '[\s|]*$', '') EndFunc ;==>DiskList You could also split the CheckWIM function into two, one to test for the file and the other to get the size. Keeps the functions simple and have a single job. Also gets rid of another global ($wimSize) ; check for the boot wim file Func BootWim_Check() If Not FileExists($MountedDrive & ':\sources\boot.wim') Then MsgBox($MB_ICONERROR, "Notice: ", "BOOT.WIM NOT DETECTED!!!" & @CRLF & "This tool is designed for SE" & @CRLF & "and XPE projects only.") UnmountIso() Exit EndIf EndFunc ; get the boot wim size and add 200 megabytes for headroom on boot partition Func BootWim_GetSize() Return Round((FileGetSize($MountedDrive & ':\sources\boot.wim') + 209715200) / 1048576) EndFunc In the burn pressed function, when you split the disk string to an array and use $DiskN[6], this will only work if the number of drives is less than 10. I know, who has that many. but for completeness you could try below. This should get disk numbers with double digits Func BurnPressed() If GUICtrlRead($DiskList) = '' Then MsgBox( _ $MB_ICONERROR, _ "Notice: ", _ "No disk has been selected") Else Local $s_DiskNumber = StringRegExp(GUICtrlRead($DiskList), '(?<=Disk\s)[0-9]+', $STR_REGEXPARRAYMATCH)[0] If @error Then MsgBox( _ $MB_ICONERROR, _ "Notice: ", _ "An error occured retrieving the disk number") Else If MsgBox( _ BitOR($MB_TOPMOST, $MB_ICONWARNING, $MB_YESNO, $MB_DEFBUTTON2), _ 'This will FORMAT Disk ' & $s_DiskNumber, _ 'ALL DATA WILL BE ERASED FROM DISK ' & $s_DiskNumber & @CRLF & 'Are you sure you want to proceed?') = $IDYES Then GUISetState(@SW_HIDE) ProgressOn("Applying ISO...", "Creating Bootable Media... ", "0%") PrepFormat($s_DiskNumber) ProgressSet(5 & "%", "Formatting Disk " & $s_DiskNumber) Format() ProgressSet(25 & "%", "Analyzing ISO Structure ") CleanDirList() CleanFileList() ProgressSet(26 & "%", "Copying Boot Partition ") CopyBootFiles() ;Progress in function; start at 55% CopyDataFilesF() ;Progress in function; start at 65% CopyDataFilesD() ProgressSet(100, "Finished", "ISO Applied!!") Sleep(2750) ProgressOff() Cleanup() UnmountIso() MsgBox($MB_ICONINFORMATION, "", " Enjoy! ") Exit EndIf EndIf EndIf EndFunc ;==>BurnPressed For the files issue. You could use FileListToArray or FileListToArrayRec to list the files and use AutoIt to copy them. This would give you the names and path to display and save on txt file creation. Yashied has create a file copy udf here that works great. On the subject of less file creation, if the contents of list.ini never change, you could create the file yourself and include it in the compiled exe. Use FIleInstall to copy it to the cache folder. You can then remove the code that creates it and lose another global variable.
    1 point
  12. yes in the middle of wd_core.au3 UDF If $sStartNodeID = Default Then $sStartNodeID = "" And this mean: Local $sElement_Form = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, '//form') ;; start looking for "form" element from the root element of the document Local $sElement_Input = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, '//input', $sElement_Form) ;; start looking for "input" element from $sElement_Form
    1 point
  13. @LetraindusoirCheck out the coding for _WD_ElementSelectAction. P.S. Are you using the latest version? I'm guessing not based on the code you posted.
    1 point
  14. You could create your own progress gui and have a total progress for the whole process and a current progress for each function. You can then also design it to have labels that identify which part of the process is currently running. A few suggestions after a quick glance :- You could lose the $Burn and $Refresh globals as they are for buttons which have an onevent and are only used once in the posted code. The $CachePath global can be dropped and the GetCachePath function altered to return the path. This can then be called directly. Func GetCachePath() Return IniRead(@WorkingDir & '\USBTool.ini', "Settings", "CachePath", @WorkingDir & '\cache') & '\' EndFunc ;==>GetCachePath In the CopyBootFiles function, the four local variables can go and replaced with the Fileexists call, i.e. If FileExists($MountedDrive & ":\BOOTMGR.") Then RunWait('cmd /c xcopy ' & $MountedDrive & ':\BOOTMGR. ' & $bootDrive & ':\ /h /r /v /y', @WorkingDir, @SW_HIDE) In the CopyDataFiles functions, you could try FileReadToArray to create the array instead of creating one then redimming to fit the line count and looping to read the line.
    1 point
  15. You could call the functions in a loop and use the variable to calculate the percentage? #NoTrayIcon #RequireAdmin #include <AutoItConstants.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <Constants.au3> #include <File.au3> #include <Array.au3> #include <String.au3> Global $DiskList, $Selection, $Burn, $Refresh, $MountedDrive = "" Global $IsoFile, $CachePath, $finalfiles, $finaldirs, $wimSize, $bootDrive, $dataDrive GetCachePath() ProperUse() MountIso() GetISODriveLetter() CheckWIM() Cleanup() DirCreate($CachePath) $listFile = FileOpen($CachePath & 'list.ini', 2) FileWrite($listFile, 'lis dis') FileClose($listFile) Opt("GUIOnEventMode", 1) MainMenu() Cleanup() Exit Func MainMenu() GUICreate('USBTool (PE) v2.0', 300, 298) GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents") GUISetIcon(@WorkingDir & '\USBTool.ico', 1) GUISetBkColor(0x797979) GUICtrlCreateLabel('1: Select a disk use...', 20, 10, 280) $DiskList = GUICtrlCreateList('', 20, 30, 260, 150) GUICtrlSetData(-1, DiskList()) $Refresh = GUICtrlCreateButton('Refresh List', 110, 185, 80, 25) GUICtrlSetOnEvent(-1, "_RefreshPressed") GUICtrlSetState(-1, $GUI_FOCUS) GUICtrlCreateLabel('________________________________________', 30, 210, 280, 30) $Burn = GUICtrlCreateButton('Burn', 90, 232, 120, 40) GUICtrlSetOnEvent(-1, "BurnPressed") GUICtrlCreateLabel('( * ) Disk is Currently GPT', 160, 278, 130, 30) GUISetState() ; Just idle around While 1 Sleep(10) WEnd EndFunc ;==>MainMenu Func RefreshPressed() GUICtrlSetData($DiskList, "") GUICtrlSetData($DiskList, DiskList()) EndFunc ;==>RefreshPressed Func BurnPressed() Local $Disk = StringRegExpReplace(GUICtrlRead($DiskList), '(?i)^.*(Disk [\d]+).*$', '$1') Local $DiskN = StringSplit($Disk, "") Local $AreYouSure If $Disk = "" Then MsgBox($MB_ICONERROR, "Notice: ", "No disk has been selected") Else $AreYouSure = MsgBox(262452, 'This will FORMAT Disk ' & $DiskN[6], 'ALL DATA WILL BE ERASED FROM DISK ' & $DiskN[6] & @CRLF & 'Are you sure you want to proceed?') Select Case $AreYouSure = 6 ;Yes GUISetState(@SW_HIDE) ; $aFunctions - 0 = Function Name, 1 = Task Description, 2 = Param 1 Local $aFunctions[7][3] = [ [ 'PrepFormat', 'Preparing Format..', $DiskN[6] ], _ [ 'Format', 'Formatting..', -1 ], _ [ 'CleanDirList', 'Cleaning Dir List..', -1 ], _ [ 'CleanFileList', ' Cleaning File List..', -1 ], _ [ 'CopyBootFiles', 'Copying Boot Files..', -1 ], _ [ 'CopyDataFilesF', 'Copying Boot Files F..', -1 ], _ [ 'CopyDataFilesD', 'Copying Boot Files D..', -1 ] ] ProgressOn("Applying ISO...", "Creating Bootable Media... ", "0%") For $i = 0 To (UBound($aFunctions) - 1) Step 1 If $aFunctions[$i][2] <> -1 Then Call($aFunctions[$i][0], $aFunctions[$i][2]) Else Call($aFunctions[$i][0]) EndIf Local $iPercentage = Int(((100 / UBound($aFunctions)) * ($i + 1))) ProgressSet($iPercentage, $aFunctions[$i][1], $iPercentage & '%') Sleep(1000) ; You might want to remove this sleep - I added it for visibility Next ProgressOff() Cleanup() UnmountIso() MsgBox($MB_ICONINFORMATION, "", " Enjoy! ") Exit Case $AreYouSure = 7 ;No EndSelect EndIf EndFunc ;==>BurnPressed Func SpecialEvents() Select Case @GUI_CtrlId = $GUI_EVENT_CLOSE ; Code below for actions on Close Cleanup() UnmountIso() Exit Case @GUI_CtrlId = $GUI_EVENT_MINIMIZE ; Code below for actions on Minimize Case @GUI_CtrlId = $GUI_EVENT_RESTORE ; Code below for actions on Restore EndSelect EndFunc ;==>SpecialEvents Func ProperUse() If Not ($CmdLine[0]) = 0 Then ;Something was dropped on the EXE file or CLI was used with a flag(s) $IsoFile = ($CmdLine[1]) ;Sets $IsoFile var to the full path of whatever was dropped onto the EXE file or the 1st CLI flag that was used Else MsgBox($MB_ICONERROR, "Notice: ", "This program cannot be run directly!" & @CRLF & "Please drag an ISO onto" & @CRLF & "the program to begin...") Exit EndIf EndFunc ;==>ProperUse Func CheckWIM() Local $wimExists = FileExists($MountedDrive & ":\sources\boot.wim") If Not $wimExists Then MsgBox($MB_ICONERROR, "Notice: ", "BOOT.WIM NOT DETECTED!!!" & @CRLF & "This tool is designed for SE" & @CRLF & "and XPE projects only.") UnmountIso() Exit Else $wimSize = FileGetSize($MountedDrive & ":\sources\boot.wim") $wimSize = StringSplit(($wimSize + 200000000) / 1000000, ".") ; +200mb headroom on boot partition $wimSize = $wimSize[1] ;Get whole number after converting size from bytes to megabytes EndIf EndFunc ;==>CheckWIM Func MountIso() RunWait('cmd /c powershell.exe ' & '"Mount-DiskImage "' & '"' & $IsoFile & '"' & '"' & '"' & ' >nul', @WorkingDir, @SW_HIDE) EndFunc ;==>MountIso Func UnmountIso() RunWait('cmd /c powershell.exe ' & '"Dismount-DiskImage "' & '"' & $IsoFile & '"' & '"' & '"' & ' >nul', @WorkingDir, @SW_HIDE) EndFunc ;==>UnmountIso Func Cleanup() If FileExists($CachePath) Then DirRemove($CachePath, $DIR_REMOVE) EndIf EndFunc ;==>Cleanup Func GetISODriveLetter() Local $findiso = StringSplit("CDEFGHIJKLMNOPQRSTUVWXYZ", "", 1) For $i = 1 To $findiso[0] Step +1 $isoExists = FileExists($findiso[$i] & ":\CdUsb.Y") If $isoExists Then If PathIsWritable($findiso[$i] & ":\") = False Then $MountedDrive = ($findiso[$i]) EndIf EndIf Next If $MountedDrive = "" Then MsgBox($MB_ICONERROR, "Notice: ", "CdUsb.Y NOT DETECTED!!!" & @CRLF & "This tool is designed for SE" & @CRLF & "and XPE projects only.") Exit EndIf EndFunc ;==>GetISODriveLetter Func PathIsWritable($sFile) Local $aRet = DllCall('kernel32.dll', 'handle', 'CreateFileW', _ 'wstr', $sFile, _ 'dword', 2, _ 'dword', 7, _ 'struct*', 0, _ 'dword', 3, _ 'dword', 0x02000000, _ 'handle', 0) If @error Or $aRet[0] = Ptr(-1) Or $aRet[0] = 0 Then Return False DllCall('kernel32.dll', 'bool', 'CloseHandle', 'handle', $aRet[0]) Return True EndFunc ;==>PathIsWritable Func DiskList() RunWait('cmd /c diskpart /s ' & '"' & $CachePath & 'list.ini' & '"' & '>' & '"' & $CachePath & 'dpoutput.txt' & '"', @WorkingDir, @SW_HIDE) Local $Filtered = '', $Array = _StringExplode(FileRead($CachePath & 'dpoutput.txt'), @LF) For $rawlist = 0 To UBound($Array) - 1 If StringRegExp($Array[$rawlist], '(?i)Disk [\d]+') Then $Filtered &= $Array[$rawlist] & '|' Next $Filtered = StringRegExpReplace($Filtered, '[\s|]*$', '') Return $Filtered EndFunc ;==>DiskList Func GetCachePath() $CachePath = IniRead(@WorkingDir & '\USBTool.ini', "Settings", "CachePath", @WorkingDir & '\cache') $CachePath = ($CachePath & '\') EndFunc ;==>GetCachePath Func PrepFormat($Drive) GetDriveLetters() createDiskPartScriptFile($CachePath & 'clean.dat', 'Sel Dis ' & $Drive & @CRLF & 'clean' & @CRLF & 'Exit') createDiskPartScriptFile($CachePath & 'attrib.dat', 'Sel Dis ' & $Drive & @CRLF & 'attribute disk clear readonly' & @CRLF & 'Exit') createDiskPartScriptFile($CachePath & 'scrubber.dat', 'Sel Dis ' & $Drive & @CRLF & 'cre par pri' & @CRLF & 'format quick fs=NTFS label=scrubber' & @CRLF & 'Exit') createDiskPartScriptFile($CachePath & 'convert.dat', 'Sel Dis ' & $Drive & @CRLF & 'convert mbr' & @CRLF & 'Exit') createDiskPartScriptFile($CachePath & 'initdata.dat', 'Sel Dis ' & $Drive & @CRLF & 'cre par pri' & @CRLF & 'shrink minimum=' & $wimSize & @CRLF & 'format quick fs=ntfs label="WinPE Data"' & @CRLF & 'assign letter=' & $dataDrive & @CRLF & 'Exit') createDiskPartScriptFile($CachePath & 'initboot.dat', 'Sel Dis ' & $Drive & @CRLF & 'cre par pri' & @CRLF & 'format quick fs=fat32 label="BOOTFILES"' & @CRLF & 'assign letter=' & $bootDrive & @CRLF & 'Active' & @CRLF & 'Exit') EndFunc ;==>PrepFormat Func CopyBootFiles() Local $bmgrExists = FileExists($MountedDrive & ":\BOOTMGR.") Local $bmgrefiExists = FileExists($MountedDrive & ":\bootmgr.efi") Local $bmgrexeExists = FileExists($MountedDrive & ":\bootmgr.exe") Local $menulstExists = FileExists($MountedDrive & ":\menu.lst") RunWait('cmd /c xcopy ' & $MountedDrive & ':\BOOT ' & $bootDrive & ':\BOOT /i /s /e /h /r /v /y', @WorkingDir, @SW_HIDE) ProgressSet(27 & "%", "Copying Boot Partition ") RunWait('cmd /c xcopy ' & $MountedDrive & ':\EFI ' & $bootDrive & ':\EFI /i /s /e /h /r /v /y', @WorkingDir, @SW_HIDE) ProgressSet(40 & "%", "Copying Boot.wim, this may take a while... ") RunWait('cmd /c xcopy ' & $MountedDrive & ':\sources ' & $bootDrive & ':\sources /i /s /e /h /r /v /y', @WorkingDir, @SW_HIDE) ProgressSet(50 & "%", "Copying Boot Files ") If $bmgrExists Then RunWait('cmd /c xcopy ' & $MountedDrive & ':\BOOTMGR. ' & $bootDrive & ':\ /h /r /v /y', @WorkingDir, @SW_HIDE) EndIf If $bmgrefiExists Then RunWait('cmd /c xcopy ' & $MountedDrive & ':\bootmgr.efi ' & $bootDrive & ':\ /h /r /v /y', @WorkingDir, @SW_HIDE) EndIf If $bmgrexeExists Then RunWait('cmd /c xcopy ' & $MountedDrive & ':\bootmgr.exe ' & $bootDrive & ':\ /h /r /v /y', @WorkingDir, @SW_HIDE) EndIf If $menulstExists Then ;Need to add grub support etc later if this gets expanded beyond PE SE or XPE ISO's RunWait('cmd /c xcopy ' & $MountedDrive & ':\menu.lst ' & $bootDrive & ':\ /h /r /v /y', @WorkingDir, @SW_HIDE) EndIf EndFunc ;==>CopyBootFiles Func CopyDataFilesF() Local $GoFiles = ($CachePath & $finalfiles), $StartProgAt FileOpen($GoFiles, 0) Local $aArray[1000] ReDim $aArray[_FileCountLines($GoFiles) + 1] For $i = 1 To _FileCountLines($GoFiles) $newline = FileReadLine($GoFiles, $i) $aArray[$i] = $newline Next _ArraySort($aArray) $StartProgAt = 55 For $i = 1 To UBound($aArray) - 1 ProgressSet($StartProgAt & "%", "Copying " & $aArray[$i] & " ") RunWait('cmd /c xcopy ' & $MountedDrive & ':\' & $aArray[$i] & ' ' & $dataDrive & ':\' & ' /h /r /v /y', @WorkingDir, @SW_HIDE) $StartProgAt = ($StartProgAt + 1) Next EndFunc ;==>CopyDataFilesF Func CopyDataFilesD() Local $GoFiles = ($CachePath & $finaldirs), $StartProgAt FileOpen($GoFiles, 0) Local $aArray[1000] ReDim $aArray[_FileCountLines($GoFiles) + 1] For $i = 1 To _FileCountLines($GoFiles) $newline = FileReadLine($GoFiles, $i) $aArray[$i] = $newline Next _ArraySort($aArray) $StartProgAt = 65 For $i = 1 To UBound($aArray) - 1 If $aArray[$i] = "Programs" Then ProgressSet($StartProgAt & "%", "Copying Programs, this may take a while... ") RunWait('cmd /c xcopy ' & $MountedDrive & ':\' & $aArray[$i] & ' ' & $dataDrive & ':\' & $aArray[$i] & ' /i /s /e /h /r /v /y', @WorkingDir, @SW_HIDE) $StartProgAt = ($StartProgAt + 15) Else ProgressSet($StartProgAt & "%", "Copying " & $aArray[$i] &" Folder ") RunWait('cmd /c xcopy ' & $MountedDrive & ':\' & $aArray[$i] & ' ' & $dataDrive & ':\' & $aArray[$i] & ' /i /s /e /h /r /v /y', @WorkingDir, @SW_HIDE) $StartProgAt = ($StartProgAt + 1) EndIf Next EndFunc ;==>CopyDataFilesD Func createDiskPartScriptFile($fileName, $message) $CacheFile = '' $CacheFile = FileOpen($fileName, 2) FileWrite($CacheFile, $message) FileClose($CacheFile) EndFunc ;==>createDiskPartScriptFile Func GetDriveLetters() Local $allDriveLetters = "CDEFGHIJKLMNOPQRSTUVWXYZ", $AvailDriveLetters Local $aArray = DriveGetDrive($DT_ALL) If @error Then ; An error occurred when retrieving the drives. MsgBox($MB_SYSTEMMODAL, "", "An Error Occurred! Unable to retrieve " & @CRLF & "available drive letters! Exiting Program...") Cleanup() UnmountIso() Exit Else For $i = 1 To $aArray[0] $driveLetter = StringLeft(StringUpper($aArray[$i]), 1) $allDriveLetters = StringReplace($allDriveLetters, $driveLetter, "") Next EndIf $AvailDriveLetters = StringSplit($allDriveLetters, "") $bootDrive = $AvailDriveLetters[1] ;Get first available letter $dataDrive = $AvailDriveLetters[2] ;Get second available letter EndFunc ;==>GetDriveLetters Func CleanDirList() Local $rawlist = 'isod.dat' $finaldirs = 'isodirs.dat' RunWait('cmd /c DIR /B /A:D ' & $MountedDrive & ':\>' & '"' & $CachePath & $rawlist & '"', @WorkingDir, @SW_HIDE) RunWait('cmd /c FINDSTR /v /i /c:' & '"' & 'efi' & '"' & ' /c:' & '"' & 'boot' & '"' & ' /c:' & '"' & 'sources' & '"' & ' "' & $CachePath & $rawlist & '"' & '>>' & '"' & $CachePath & $finaldirs & '"', @WorkingDir, @SW_HIDE) EndFunc ;==>CleanDirList Func CleanFileList() Local $rawlist = 'isof.dat' $finalfiles = 'isofiles.dat' RunWait('cmd /c DIR /B /A-D ' & $MountedDrive & ':\>' & '"' & $CachePath & $rawlist & '"', @WorkingDir, @SW_HIDE) RunWait('cmd /c FINDSTR /v /i /c:' & '"' & 'bootmgr' & '"' & ' /c:' & '"' & 'menu' & '"' & ' "' & $CachePath & $rawlist & '"' & '>>' & '"' & $CachePath & $finalfiles & '"', @WorkingDir, @SW_HIDE) EndFunc ;==>CleanFileList Func Format() Local $aArray[7][3] = [ _ ["Cleaning Drive", 'cmd /c diskpart /s ' & '"' & $CachePath & 'clean.dat' & '"'], _ ["Cleaning Drive", 'cmd /c diskpart /s ' & '"' & $CachePath & 'scrub.dat' & '"'], _ ["Cleaning Drive", 'cmd /c diskpart /s ' & '"' & $CachePath & 'clean.dat' & '"'], _ ["Resetting Disk Attributes", 'cmd /c diskpart /s ' & '"' & $CachePath & 'attrib.dat' & '"'], _ ["Converting Layout to MBR", 'cmd /c diskpart /s ' & '"' & $CachePath & 'convert.dat' & '"'], _ ["Creating Data Partition", 'cmd /c diskpart /s ' & '"' & $CachePath & 'initdata.dat' & '"'], _ ["Creating Boot Partition", 'cmd /c diskpart /s ' & '"' & $CachePath & 'initboot.dat' & '"'] _ ] For $i = 0 To UBound($aArray) - 1 ProgressSet($i * 2 & "%", $aArray[$i][0]) ;MsgBox($MB_ICONINFORMATION, "Troubleshooting.. ", $aArray[$i][1]) ;Troubleshoot Array Data RunWait($aArray[$i][1], @WorkingDir, @SW_HIDE) Sleep(750) Next EndFunc ;==>Format
    1 point
  16. Hi Misuranai, The GUI created in the _GuiCtrlMakeTrans function needs the $WS_EX_TRANSPARENT extended style adding. #include <StaticConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $TestBG = GUICreate("TestBG",609,435,-1,-1,-1,-1) $Group1 = GUICtrlCreateGroup("My Text",30,29,200,150,-1,-1) _GuiCtrlMakeTrans($Group1, 50) GUICtrlSetState($Group1, $GUI_DISABLE) GUICtrlCreateButton("My Text",60,60,100,30,-1,-1) GUICtrlCreateCheckbox("My Text",70,110,74,20,-1,-1) GUISetState(@SW_SHOW,$TestBG) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _GuiCtrlMakeTrans($iCtrlID,$iTrans=255) Local $pHwnd, $nHwnd, $aPos, $a $hWnd = GUICtrlGetHandle($iCtrlID);Get the control handle If $hWnd = 0 then Return SetError(1,1,0) $pHwnd = DllCall("User32.dll", "hwnd", "GetParent", "hwnd", $hWnd);Get the parent Gui Handle If $pHwnd[0] = 0 then Return SetError(1,2,0) $aPos = ControlGetPos($pHwnd[0],"",$hWnd);Get the current pos of the control If @error then Return SetError(1,3,0) $nHwnd = GUICreate("", $aPos[2], $aPos[3], $aPos[0], $aPos[1], 0x80000000, 0x00080000 + 0x00000040 + $WS_EX_TRANSPARENT, $pHwnd[0]);greate a gui in the position of the control If $nHwnd = 0 then Return SetError(1,4,0) $a = DllCall("User32.dll", "hwnd", "SetParent", "hwnd", $hWnd, "hwnd", $nHwnd);change the parent of the control to the new gui If $a[0] = 0 then Return SetError(1,5,0) If NOT ControlMove($nHwnd,'',$hWnd,0,0) then Return SetError(1,6,-1);Move the control to 0,0 of the newly created child gui GUISetState(@SW_Show,$nHwnd);show the new child gui WinSetTrans($nHwnd,"",$iTrans);set the transparency If @error then Return SetError(1,7,0) GUISwitch($pHwnd[0]);switch back to the parent Gui Return $nHwnd;Return the handle for the new Child gui EndFunc
    1 point
  17. JohnOne, now it works, so it's a 64bit problem then thanks for the help JohnOne [EDIT:] put this on top in the au3 script and you don't have to compile it every time: #AutoIt3Wrapper_UseX64=n TheAutomator.
    1 point
  18. I asked about general problem with "--log-path" and your's related question helped me to understand the clue of the problem. So here is my example: #include <MsgBoxConstants.au3> #include "wd_capabilities.au3" #include "wd_helper.au3" _Example_UsingCapabilitesWithChrome() If @error Then ConsoleWrite("! ---> @error=" & @error & " @extended=" & @extended & _ " : Error launching browser" & @CRLF) Func _Example_UsingCapabilitesWithChrome() _WD_CapabilitiesStartup() _WD_CapabilitiesAdd("alwaysMatch") _WD_CapabilitiesAdd("acceptInsecureCerts", True) _WD_CapabilitiesAdd("firstMatch", "chrome") _WD_CapabilitiesAdd("w3c", True) _WD_CapabilitiesDump(@ScriptLineNumber & " Testing") Local $sCapabilities = _WD_CapabilitiesGet() _WD_Option("Driver", @ScriptDir & "\chromedriver.exe") _WD_Option("Port", 9515) _WD_Option("DefaultTimeout", 1000) Local $sLog_Dir = 'C:\Testing_LogDir_' Local $sLog_Name = '\WebDriver_Testing.log' While 1 $sLog_Dir &= 'a' If StringLen($sLog_Dir & $sLog_Name) > 200 Then ExitLoop WEnd ;~ DirCreate($sLog_Dir) ConsoleWrite("! LogPath = " & $sLog_Dir & $sLog_Name & @CRLF) ConsoleWrite("! LogPath Length = " & StringLen($sLog_Dir & $sLog_Name) & @CRLF) _WD_Option("DriverParams", "--log-path=" & Chr(34) & $sLog_Dir & $sLog_Name & Chr(34)) _WD_Startup() If @error Then Return SetError(@error, @extended, "") Local $WD_SESSION = _WD_CreateSession($sCapabilities) If @error Then Return SetError(@error, @extended, $WD_SESSION) ; this MsgBox is placed here only to have possibility to manually check if all is fine with Chrome instance If Not @Compiled Then MsgBox($MB_OK + $MB_TOPMOST + $MB_ICONINFORMATION, "Information #" & @ScriptLineNumber, "Waiting before _WD_Shutdown()") _WD_DeleteSession($WD_SESSION) _WD_Shutdown() EndFunc ;==>_Example_UsingCapabilitesWithChrome Conclusion: There is no problem with WebDriver API. The solutions is to uncomment: ;~ DirCreate($sLog_Dir) The problem is on user or UDF side. One of them should check if Directory exist and is accesible. btw. Sorry but yeasterday I was really tired (was working in my office 14 hour) and thus my post was not well written.
    0 points
×
×
  • Create New...