Jump to content

YGYL0

Members
  • Posts

    11
  • Joined

  • Last visited

Everything posted by YGYL0

  1. sure,It won't work if you copy the original, After changing \\to//, it can run normally. $chromeLOC="C:\111\222\chrome.exe" ....... _WD_CapabilitiesAdd('w3c', True) _WD_CapabilitiesAdd('binary',$chromeLOC) Of course, the best way is change the code to this.
  2. $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "binary":"C:\\Path\\To\\Alternate\\Browser\\chrome.exe" }}}}' This format is wrong. \\ To be written as//
  3. #include "wd_helper.au3" #include "wd_capabilities.au3" $bHeadless = False $sCapabilities = SetupChrome($bHeadless) If @error Then MsgBox(0, @error, @extended) Local $iWebDriver_PID = _WD_Startup() $sSession = _WD_CreateSession($sCapabilities) _WD_Navigate($sSession, 'https://www.baidu.com') _WD_LoadWait($sSession) MsgBox(0,"","OK") Func SetupChrome($bHeadless) _WD_Option('Driver', 'chromedriver.exe') Local $iPort = _WD_GetFreePort(5555, 5600) ;~ If @error Then Return SetError(@error, @extended, 0) _WD_Option('Port', $iPort) _WD_Option('DriverParams', '--port=' & $iPort & ' --verbose --log-path="' & @ScriptDir & '\chrome.log"') ;~ Local $sCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "excludeSwitches": [ "enable-automation"]}}}}' _WD_CapabilitiesStartup() _WD_CapabilitiesAdd('alwaysMatch', 'chrome') _WD_CapabilitiesAdd('w3c', True) _WD_CapabilitiesAdd('excludeSwitches', 'enable-automation') If $bHeadless Then _WD_CapabilitiesAdd('args', '--headless') _WD_CapabilitiesDump(@ScriptLineNumber) ; dump current Capabilities setting to console - only for testing in this demo Local $sCapabilities = _WD_CapabilitiesGet() Return $sCapabilities EndFunc ;==>SetupChrome Google Chrome 131.0.6778.70 chromedriver 131.0.6778.69 au3WebDriver-1.4.0 Google Chrome for Testing 131.0.6778.69 ,install dir is d:\gct131\chrome.exe The format of "binary=". And Testing port?
  4. @mLipokIn the EDGE settings, Cookies and website permissions, site permissions/images, can be disabled for loading images on a certain site. What I mean is how to implement this setting in AU3 WebDriver - EDGE
  5. @SOLVE-SMARTI want to get the execution result of the HTML page JavaScript, but I don't want to spend time loading things that I don't need
  6. How to disable images &css in WebDriver - EDGE? ========Others==== from selenium import webdriver from selenium.webdriver.chrome.options import Options import time import random options = Options() num=str(float(random.randint(500,600))) options.add_argument("user-agent=Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/{}" " (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/{}".format(num,num)) prefs = {"profile.managed_default_content_settings.images": 2,'permissions.default.stylesheet':2} options.add_experimental_option("prefs", prefs) driver = webdriver.Chrome(executable_path='D:\\chromedriver\\chromedriver.exe',chrome_options=options) driver.get('https://www.ly.com/') time.sleep(5) html=driver.find_element_by_xpath("//body").get_attribute("innerHTML") print(html)
  7. in PS can use Threshold or Invert,like this
  8. _GUICtrlToolbar_ButtonCount and _GUICtrlToolbar_GetButtonText not work on WIN11 DESKTOP System Tray info: Class:Shell_TrayWnd Windows.UI.Composition.DesktopWindowContentBridge1 ======================= ;~ #RequireAdmin #include <GuiToolBar.au3> _SysTray_ClickItem("Everything", "right") Func _SysTray_ClickItem($iTitle, $iButton = "left", $iClick = 1, $sMove = False, $iSpeed = 1) Local $hToolbar, $iButCount, $hButton, $cID, $i For $iIndex = 1 To 3 If @OSVersion = "WIN_11" Then $hToolbar = ControlGetHandle("[Class:Shell_TrayWnd]", "", "[Class:Windows.UI.Composition.DesktopWindowContentBridge;Instance:" & $iIndex & "]") Else $hToolbar = ControlGetHandle("[Class:Shell_TrayWnd]", "", "[Class:ToolbarWindow32;Instance:" & $iIndex & "]") EndIf $iButCount = _GUICtrlToolbar_ButtonCount($hToolbar) MsgBox(0,$iButCount,$hToolbar) $iButCount=9 For $i = 0 To $iButCount - 1 ConsoleWrite($i&@CRLF) $cID = _GUICtrlToolbar_IndexToCommand($hToolbar, $i) ConsoleWrite(_GUICtrlToolbar_GetButtonText($hToolbar, $cID) & @CRLF) If StringInStr(_GUICtrlToolbar_GetButtonText($hToolbar, $cID), $iTitle) Then _GUICtrlToolbar_ClickButton($hToolbar, $cID, $iButton, $sMove, $iClick, $iSpeed) ExitLoop EndIf Next Next EndFunc ;==>_SysTray_ClickItem
  9. Generally speaking, the support for autoit AU3 file drag and drop is not perfect AU3 built-in GUI $WS_ EX_ ACCESSFILES, Control $GUI_ DROPACCEPTED, then @ GUI_ DropId distinguishes the control that occurs, but @ GUI_ DragFile does not support multiple files, only the first file is recognized! And dragging into the window means dragging and dropping the cursor, without distinguishing the display of controls. Common WM_DROPFILES_FUNC, DllCall shell32.dll DragQueryFile, GUI window also $WS_ EX_ ACCESSFILES, supports multiple files, but requires GUI event mode 1, and cannot distinguish which control occurred, making it difficult to handle when there are multiple different drag and drop destinations. Similarly, dragging the cursor into the window does not distinguish the display of controls. Here is an example of AU3 source code that can determine which control triggers the drag, and can support multiple files being dragged in at once, which can be processed one by one without setting GUIOnEventMode to 1 Running under WIN11 has passed. The image shows the system wallpaper of WIN11 or WIN7. If you don't have it, please replace it yourself Select multiple files in the system file browser, then drag them into the program window. When pointing to the blank space, cursor as disabled. When pointing to the Input input box and image, you can release the mouse to complete the drag and drop. The effect is that the input box displays all the file names that were dragged and dropped, and displays the recently dragged control hWnd,for easy differentiation ================== #include <GUIConstants.au3> #include <WinAPI.au3> #include <Array.au3> Global $aFileList, $lastDragID $hGUI = GUICreate("Independent control multi file drag", 565, 247, -1, -1, -1, $WS_EX_WINDOWEDGE) $Input1 = GUICtrlCreateInput("", 32, 16, 505, 121) ; Now only here the drop sign appears $defpic1 = "C:\Windows\Web\Wallpaper\Spotlight\img50.jpg" ;win11壁纸1 $defpic2 = "C:\Windows\Web\Wallpaper\Windows\img19.jpg" ;win11壁纸2 $defpic = "" For $i = 1 To 5 If Random(0, 1, 1) Then $defpic = $defpic1 Else $defpic = $defpic2 EndIf Assign("Pic" & $i & "Handle", GUICtrlCreatePic($defpic, 20 + (($i - 1) * 100), 180, 90, 50, -1, $WS_EX_ACCEPTFILES)) GUICtrlSetState(Eval("Pic" & $i & "Handle"), $GUI_DROPACCEPTED) Next GUICtrlSetState(-1, $GUI_DROPACCEPTED) Global $idDummy = GUICtrlCreateDummy() GUISetState() $wProcHandle = DllCallbackRegister("_WindowProc", "ptr", "hwnd;uint;wparam;lparam") For $i = 1 To 5 Assign("gchp" & $i, GUICtrlGetHandle(Eval("Pic" & $i & "Handle"))) Assign("wProcOld" & $i, _WinAPI_SetWindowLong(Eval("gchp" & $i), $GWL_WNDPROC, DllCallbackGetPtr($wProcHandle))) Next While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $idDummy For $i = 1 To $aFileList[0] ConsoleWrite($aFileList[$i] & @CRLF) ;拖放处理文件段 Next GUICtrlSetData($Input1, $lastDragID & "##" & _ArrayToString($aFileList, "|", 1)) For $i = 1 To 5;提示哪个控件响应 If Eval("gchp" & $i) = $lastDragID Then MsgBox(0, "idP-" & $i, _ArrayToString($aFileList, @CRLF, 1)) Next EndSwitch WEnd GUIDelete($hGUI) DllCallbackFree($wProcHandle) Func _WindowProc($hWnd, $Msg, $wParam, $lParam) For $j = 1 To 5 ;拖放识别控件段 If $hWnd = GUICtrlGetHandle(Eval("Pic" & $j & "Handle")) Then isDrag($hWnd, $Msg, $wParam, $lParam, Eval("wProcOld" & $j)) Next EndFunc ;==>_WindowProc Func isDrag($hWnd2, $Msg2, $wParam2, $lParam2, $wProcOldx) If $Msg2 = $WM_DROPFILES Then $lastDragID = $hWnd2 ConsoleWrite($lastDragID & @CRLF) $aFileList = _WinAPI_DragQueryFileEx($wParam2) If Not @error Then GUICtrlSendToDummy($idDummy) _WinAPI_DragFinish($wParam2) Return 0 Else Return _WinAPI_CallWindowProc($wProcOldx, $hWnd2, $Msg2, $wParam2, $lParam2) ;放行相应控件的其它消息 EndIf EndFunc ;==>isDrag ================= 单控件多文件拖放22.au3
  10. Machine translation I am on the Win11 system and when i using autoit SQLite udf, report errors: _SQLite_Startup error [SQLite Error SQLite.dll Can't be Loaded!], my version is 3.3.16.0 For example, running the f1 help document _SQLite_GetTable2D Example will report an error I took a brief look at the process, and there are basically several reasons for this: 1.The most critical issue is the issue with the official UDF SQLite.au3 In SQLite.au3 _SQLite_Startup() The third parameter of the Startup() function, iForceLocal, forces the use of the local DLL. When iForceLocal is 0, it will be downloaded from the official AU3 and the official DLL will be used IForceLocal defaults to 0 and can be downloaded from the official website without specifying it, but this feature seems to be disabled, __SQLite_Inline_Version in __SQLite_GetDownloadedPath is actually no longer available. 2. Of course, we have a way to manually download it, https://www.autoitscript.com/autoit3/pkgmgr/sqlite/ Manually download sqlite3.dll, sqlite3.exe, sqlite3_x64.dll, update.dat in C:\Users\admin...\AppData\Local\AutoIt v3\SQLite solve the problem? The answer is no~~ Firstly, pkgmgr/sqlite did not update the corresponding version files in a timely manner The program will search for file names online, such as sqlite3_302800000.dll, display does not match~ So to disable the online download function, set the third parameter to 1, and then place the file in your program directory, which is more stable 3. Then you may find that there is still an error, and the root cause is whether the system is 64 bit and whether autoit is running in x64 mode by default Generally speaking, when installing autoit, the installation program is recommended for x32 installation, so even if you use a 64-bit DLL and autoit runs according to 32-bit, an error will still be reported #AutoIt3Wrapper_ UseX64=n This is not a random addition, sometimes we have to=y instead When autoit runs at 64 bit_ SQLite_ Startup will add_ X64 suffix, if the file name is not_ X64 doesn't work either Of course, we can also go to the latest version in 2023 on the official website of SQLite, corresponding to SQLite version 3.41.2 https://www.sqlite.org/download.html So here we need to pay special attention to x64 and x32, as well as their suffix issues. Of course, putting them together is also a good idea.
×
×
  • Create New...