Leaderboard
Popular Content
Showing content with the highest reputation on 01/26/2023 in all areas
-
WebDriver click on text to load content
SkysLastChance and one other reacted to Danp2 for a topic
Here's my "simplified" version -- #include "wd_helper.au3" #include "wd_capabilities.au3" #include "array.au3" _WD_Option('Driver', 'chromedriver.exe') _WD_Option('Port', 9515) _WD_Option('DriverParams', '--verbose --log-path="' & @ScriptDir & '\chrome.log"') _WD_CapabilitiesStartup() _WD_CapabilitiesAdd('alwaysMatch', 'chrome') _WD_CapabilitiesAdd('w3c', True) _WD_CapabilitiesAdd('excludeSwitches', 'enable-automation') _WD_CapabilitiesDump(@ScriptLineNumber) Local $sCapabilities = _WD_CapabilitiesGet() _WD_Startup() $sSession = _WD_CreateSession($sCapabilities) _WD_Window($sSession,"MAXIMIZE") Local $aSymbol = 'LPF' _WD_Navigate($sSession,"https://www.set.or.th/en/market/product/stock/quote/"& $aSymbol &"/news") _WD_LoadWait($sSession) ; Accept cookies Local $sElement = _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//div[@class='align-self-md-center mb-3 mb-md-0']/button") If @error = $_WD_Error_Success Then _WD_ElementAction($sSession, $sElement, "Click") EndIf Local $sElement = _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//div[contains(@class, 'news-finance-state mb')]/div[2]/div[6]/div/span") If @error = $_WD_Error_Success Then If _WD_ElementAction($sSession, $sElement, "text") = 'more' Then ; scroll to bottom _WD_ExecuteScript($sSession, "window.scrollTo({ top: document.body.scrollHeight, behavior: 'smooth' })") Sleep(1000) $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//div[contains(@class, 'news-finance-state mb')]/div[2]/div[6]/div") _WD_ElementAction($sSession, $sElement, "Click") EndIf EndIf _WD_DeleteSession($sSession) _WD_Shutdown() Some items of note -- The cookie banner is accepted to avoid any issues due to items being covered by it Forcibly scroll to the bottom of the webpage. This avoids issue with trying to click on "more" when it hasn't fully scrolled into view2 points -
Use the same creating order from values and both script will have the same result.1 point
-
Retrieve the X32/X64 mode of a running process
SOLVE-SMART reacted to mLipok for a topic
@jpm we was using the following code in wd_helper.au3 _WinAPI_GetBinaryType($sInstallDir & $sDriverEXE) Local $bDriverIs64Bit = (@extended = $SCS_64BIT_BINARY) Is this what you was looking for ? edit: Take a look also for this function: _WinAPI_GetProcessFileName() _WinAPI_GetProcessWorkingDirectory()1 point -
Can a Compiled script car still use #Include Files
Camille_Feuvrais reacted to SOLVE-SMART for a topic
Hi @Camille_Feuvrais, as far as I understand you correct, you want to parameterize your program execution, am I right? I mean, you store values of variables in a separate *.au3 file. When you compile your script, this *.au3 file is already included in the executable and will not be read again. That's your problem, I think. There are multiple ways/solutions to handle your requirement. One easy way could be, depending on the amount of your variables, to use a simple *.ini file. In this file you store your values of your variables and read it within the runtime of your program. So you can change the *.ini file content every time, like you described by a network share, also in script mode or as compiled program 👍 . Best regards Sven1 point -
Can a Compiled script car still use #Include Files
Camille_Feuvrais reacted to Jos for a topic
Use an INI file and read the info from it when you need to be able to update config variables. #include is for static code. Jos1 point -
Two GUIs but only one responds
SOLVE-SMART reacted to TryingToCode for a topic
Thanks, the answer was that I needed to delete the following lines from my NewGUI function. They are only needed in the first GUI. While 1 Sleep(100) WEnd1 point -
Program crashing when I change which window is in focus.
ioa747 reacted to pixelsearch for a topic
@Nine bravo you did it, it works great and covers all cases. I'm gonna study carefully your code to find out how you did that. Thanks again for your help1 point -
Nice job again @pixelsearch I came up with this. What do you think ? #include <Array.au3> #include <GDIPlus.au3> #include <WinAPISysWin.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) HotKeySet("{ESC}", "_Quit") ; <=================== Global $hGraphic, $hPen _Main() Func _Main() Local $hGUI = GUICreate("GDI+", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST)) GUISetBkColor(0x0000FF) _WinAPI_SetLayeredWindowAttributes($hGUI, 0x0000FF) Local $tPoint = DllStructCreate($tagPOINT) _GDIPlus_Startup() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) $hPen = _GDIPlus_PenCreate(0xFFFF0000, 5) ; alpha channel = 0xFF (opaque), red = 0xFF0000, width = 5 (pixels) GUISetState() Local $hWnd, $hRoot, $hWnd2, $hWnd_Old = -1, $aWPos While True $tPoint = _WinAPI_GetMousePos() $hWnd = _WinAPI_WindowFromPoint($tPoint) $hWnd2 = GetRealChild($hWnd) If $hWnd2 And $hWnd <> $hWnd2 Then $hWnd = $hWnd2 If $hWnd <> $hWnd_Old Then _GDIPlus_GraphicsClear($hGraphic, 0xFF0000FF) $aWPos = WinGetPos($hWnd) _GDIPlus_GraphicsDrawRect($hGraphic, $aWPos[0], $aWPos[1], $aWPos[2], $aWPos[3], $hPen) $hWnd_Old = $hWnd EndIf Sleep(100) WEnd EndFunc ;==>_Main Func _Quit() ; Clean up resources _GDIPlus_PenDispose($hPen) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() Exit EndFunc ;==>_Quit Func _WinAPI_RealChildWindowFromPoint($hWnd, $tPoint) Local $aRet = DllCall('user32.dll', 'hwnd', 'RealChildWindowFromPoint', 'hwnd', $hWnd, 'struct', $tPoint) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc ;==>_WinAPI_RealChildWindowFromPoint Func GetRealChild($hWnd) Local $tPoint, $hRoot = _WinAPI_GetAncestor($hWnd, $GA_ROOT) If $hWnd = $hRoot Then $tPoint = _WinAPI_GetMousePos(True, $hWnd) Return _WinAPI_ChildWindowFromPointEx($hWnd, $tPoint) EndIf Local $hParent = _WinAPI_GetAncestor($hWnd, $GA_PARENT) Local $aChild = _WinAPI_EnumChildWindows($hParent) If @error Then Return 0 Local $hFound For $i = 1 To $aChild[0][0] $hParent = _WinAPI_GetParent($aChild[$i][0]) $tPoint = _WinAPI_GetMousePos(True, $hParent) $hFound = _WinAPI_RealChildWindowFromPoint($hParent, $tPoint) If $hFound = $aChild[$i][0] Then Return $hFound Next Return 0 EndFunc ;==>GetRealChild1 point
-
WebDriver click on text to load content
maninternet reacted to Danp2 for a topic
Thanks Sven. We can always hope that this will rub off on some other users. 😉1 point -
SciTE Customization GUI -- [03/04/2017]
jimmy123j reacted to jaberwacky for a topic
SciTE Customization GUI is intended to be your one-stop solution for your SciTE customization needs. With SciTE Customization GUI you can create new themes from scratch without having to touch a single configuration file. Simply select 'Default Theme' from the file menu. This will start you out with a default theme. Then make your changes to the theme. Finally, select 'Save As' from the file menu and give it a name. Or you can select from an already existing theme. You can see live changes to SciTE as you change things around (some settings are not live). You can change various SciTE4AutoIt3 settings such as Tidy, Tools, debug trace messages, etc. I mostly want to try out new ideas which I hope will get used in the official SciTE4AutoIt3. I also wanted to see how large of a program I could script in AutoIt before it become a mass of unmaintable spaghetti. I feel that I am successful in that regard. It is reasonably easy to debug, extend and understand. I feel that this was achieved by employing the Model-View-Controller pattern. I also used AutoItObject which allows me to achieve a level of information hiding which would not have been possible otherwise. I stand on the shoulders of giants so credit where credit is due. Thanks to Jos for the original SciTEConfig. Thanks to Jon for AutoIt. Melba23 for the SciTE Abbreviation Manager and the SciTE UserCalltip Manager. Credits and changelog have be moved to the script. Note: this is not an official script. Jon, Jos or the rest of the AutoIt team do not provide support. That's all up to me. SciTE Customization GUI.zip -- downloads: ~5253 SciTE Customization GUI -- Source.zip -- Includes all of the required dependencies.1 point -
Yesterday I made some tool that was need to drop multiple files onto it. GUI_DragFile handle only single file, Edit though accept multiple files, was not suitable for me. Fortunately, with GUIRegisterMsg this become pretty simple. #include <GUIConstants.au3> Global $WM_DROPFILES = 0x233 Global $gaDropFiles[1], $str = "" ### Koda GUI section start ### $hGUI = GUICreate("Test", 400, 200, 219, 178, -1, BitOR($WS_EX_ACCEPTFILES, $WS_EX_TOPMOST)) $hList = GUICtrlCreateList("", 5, 5, 390, 190) GUICtrlSetState (-1, $GUI_DROPACCEPTED) GUISetState(@SW_SHOW) ### Koda GUI section end ### GUIRegisterMsg ($WM_DROPFILES, "WM_DROPFILES_FUNC") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_DROPPED $str = "" For $i = 0 To UBound($gaDropFiles) - 1 $str &= "|" & $gaDropFiles[$i] Next GUICtrlSetData($hList, $str) EndSwitch WEnd Func WM_DROPFILES_FUNC($hWnd, $msgID, $wParam, $lParam) Local $nSize, $pFileName Local $nAmt = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", 0xFFFFFFFF, "ptr", 0, "int", 255) For $i = 0 To $nAmt[0] - 1 $nSize = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", $i, "ptr", 0, "int", 0) $nSize = $nSize[0] + 1 $pFileName = DllStructCreate("char[" & $nSize & "]") DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", $i, "ptr", DllStructGetPtr($pFileName), "int", $nSize) ReDim $gaDropFiles[$i+1] $gaDropFiles[$i] = DllStructGetData($pFileName, 1) $pFileName = 0 Next EndFuncMultiDropTest.au31 point
-
lucamad, Welcome to the AutoIt forum. If you add the items to the ListView with the UDF, you need to carry on using the UDF on the items created: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> GUICreate("Lokyweb Uploader", -1, -1, -1, -1, BitOr($WS_SIZEBOX, $WS_SYSMENU, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX), $WS_EX_ACCEPTFILES);x il drag & drop $listview = GUICtrlCreateListView("List", 2, 40, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT, $LVS_SINGLESEL)) _GUICtrlListView_AddItem($listview, "test1", 1) _GUICtrlListView_AddItem($listview, "test2", 2) $button = GUICtrlCreateButton("Selected item", 10, 325) GUISetState() While (1) $msg = GUIGetMsg() if $msg = $button Then $iIndex = _GUICtrlListView_GetSelectedIndices($listview) msgbox (0, "Selected item", $iIndex) EndIf If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd This will return the 0-based index of the selected item. Be very careful mixing the buit-in commands and those from the UDF (regardless of which control type) as it can often end in tears. M231 point