Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/28/2023 in all areas

  1. I will get back to you on this with piece of my own working code. For time being just updating new findings. Use of $CURLOPT_PRIVATE this can be of some use. I was unaware of curl command line parameters which eventually led me to other findings that could potentially help me grow my knowledge. Thanks @TheXman
    1 point
  2. You're welcome. Implicit in your questions is a lack of prerequisite research & understanding of curl and how it works. Since this is an AutoIt forum and not a curl forum, I won't spend much time trying to help you learn & understand curl itself. However, if you have specific questions, I'll most likely try to answer them. Also, this topic is for this curl UDF. Therefore, I won't go into too much detail about using the curl command line. However, I would suggest that you get familiar with using the command line version of curl before trying to use the libcurl UDF's. Having a firm understanding to the command line parameters and how they work will go a long way in terms of helping you understand how to use the libcurl UDF's. If you want to ask more questions about the command line version, I would suggest creating a general help & support topic with your questions. Answers to your enumerated questions above: Maybe, right after you show a snippet of the code in which you at least try to implement it yourself. As a hint, I have provided a sample curl command line below that sends 3 requests, in parallel, and outputs their individual responses to separate files. See answer #1. Does curl provide a way to set the maximum number of parallel requests to process at any given time? Yes, the command line parameter is "--parallel-max". How do I do it my script? In my script, I have a CONST that tells the script the maximum number of requests that I wish to send in a single curl command. As I mentioned in my previous post, I have a file that contains all of the requests. I read in those requests and batch them together according to the CONST that specifies the max requests and execute the commands. In my particular case, if any given request fails, the whole process needs to stop. The parameter I use for that is "--fail-early". If you want to learn more about curl parameters/options, there are several good resources on the web including the official curl site. I have included a few of those reference links below. Sample curl command line that my script generates and executes: The following sample curl command makes 3 requests, in parallel, and outputs each response to a separate file. If you open a command prompt and successfully execute it, you should see the 3 response files. curl.exe -s -Z --parallel-max 3 --fail-early -L -o "~resp-file1.html" "https://example.com" --next -L -o "~resp-file2.html" "https://example.com" --next -L -o "~resp-file3.html" "https://example.com" Hopefully all of those requests were not against the same server. If so, sending 175 concurrent requests from a single IP address is a very good way to get your IP address temporarily or permanently banned on that web server and/or a very harsh warning from your ISP. I have no idea whether that'll work because that tiny little snippet does not provide enough context about the overall implementation. If $html is an array of curl handles, then maybe. But as I said, that snippet is woefully inadequate to say. A few curl reference links: Documentation Overview (official site) The manual on the official site Examples based on specific tasks (official site) Another good general curl information site Info about parallel requests on this site
    1 point
  3. Thank you so much, i appreciate you. @DoVinhTrung Download the Lastest version on Danp2 signature
    1 point
  4. Hi @UEZ your _WinAPI_SHCreateStreamOnFileEx function is awesome! I just put that function in my draft script and changed the parameters of the $dtag_ICoreWebView2 variable a bit and the CapturePreview method started working! Thanks so much for that 🙂 However it seems that the generated screenshot has some problems. It seems that the generated screenshot doesn't capture the whole page but only a part; also maybe you need somehow to close the stream after taking the screenshot? it appears that the file is only "flushed to disk" when the script is closed. However this seems to be the right way even if still to be improved.... I've updated the two draft scripts (which are now starting to work) in my previous post See You UEZ and thanks again PS If anyone has any improvements or new features to add to this material, they are welcome
    1 point
  5. get handle with RegExp RegExpQuickTester 2.5p will help put all the ClassNameNN keys here old and new here you can put your filter (Search pattern) an, in live time, test the pattern, and see which cases it catches, and readjust it here it shows which cases it catches here I have put '3 - Retum array of global matches' here you can use it as a storage space (for copying and pasting) Until now we use CLASSNN which is CLASS & INSTANCE ControlClick($hWnd, "", "WindowsForms10.Window.8.app.0.1a52015_r22_ad11") WindowsForms10.Window.8.app.0.1a52015_r22_ad11 = WindowsForms10.Window.8.app.0.1a52015_r22_ad1 & 1 now we will go to logic ; ControlClick($hWnd, "", "[REGEXPCLASS:<>; INSTANCE:<>]") ; where REGEXPCLASS:<> we put *2 the 'Search pattern' ; where INSTANCE:<> we put the instance e.g. 1 ControlClick($hWnd, "", "[REGEXPCLASS:WindowsForms10\.Window\.8\.app\.0\..*._r.*._ad1 ; INSTANCE:1]") ; Wait 3 seconds for the ShareX - Editor menu window to appear. Local $hWnd = WinWait("ShareX - Editor menu", "", 3) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $hWnd = ' & $hWnd & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console ; Retrieve the handle of the MenuBar control in ShareX - Editor menu" Local $hCtrMenuBar = ControlGetHandle($hWnd, "", "[REGEXPCLASS:WindowsForms10\.Window\.8\.app\.0\..*._r.*._ad1; INSTANCE:1]") ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $hCtrMenuBar = ' & $hCtrMenuBar & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console ControlClick($hWnd, "", $hCtrMenuBar ) here I must emphasize that we behave differently in Handle controls than Handle windows ShellExecute(@WindowsDir & '\hh.exe', 'ms-its:' _ & StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", 2, -1) - 1) & "\AutoIt.chm" _ & '::/html/intro/controls.htm') ShellExecute(@WindowsDir & '\hh.exe', 'ms-its:' _ & StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", 2, -1) - 1) & "\AutoIt.chm" _ & '::/html/intro/windowsadvanced.htm') with windows handle: ; Until now we use CLASS or TITLE ; WinWait("[CLASS:<>; TITLE:<>]") WinWait("[CLASS:WindowsForms10.Window.808.app.0.1a52015_r22_ad1]") ; now we will go to logic ; WinWait("[REGEXPCLASS:<>; REGEXPTITLE:<>]") ; WinWait("[REGEXPCLASS:<>; TITLE:<>]") ; WindowsForms10\.Window\..*808*.\.app\.0\..*._r.*._ad1 WinWait("[REGEXPCLASS:WindowsForms10\.Window\..*808*.\.app\.0\..*._r.*._ad1]")
    1 point
  6. Ah I think this may have been it. The pipes shouldn't be there, of course, that threw me off, but I tried with this simpler example: $spintext = "{Hello{ooo| There}|Hi}, how's it going?" And got: Helloooo, how's it going? Hi, how's it going? Hi, how's it going? Hello There, how's it going? So yeah, script works, the input string in the example isn't valid spintax :) For future reference, a working script an example for nested spintax in Autoit: ;Spintax Test #include <Array.au3> ; Text in Spintax format ;~ Global $a = 1 $spintext = "{Hello{ooo| There}|Hi}, how's it going?" ConsoleWrite(Spintax($spintext) & @CRLF) ConsoleWrite(Spintax($spintext) & @CRLF) ConsoleWrite(Spintax($spintext) & @CRLF) ConsoleWrite(Spintax($spintext) & @CRLF) Func Spintax($sInput) ;~ ConsoleWrite("- Iteration "&$a&" Start -" & @CRLF) $SpinArray = StringRegExp($sInput, '{([^{]*?|[^{]*?)}',3); Global matches ;~ _ArrayDisplay($SpinArray,"") $sfinrep = StringReplace($sInput,"}|{","|") ; look For final replacing If Not IsArray($SpinArray) Then ;~ ConsoleWrite("!No Array!" & @CRLF) If $sfinrep = $sInput then ; Nothing replaced, so free of }|{ --> end string ;~ ConsoleWrite("+EndResult: " & @CRLF) Return $sInput EndIf ;else replace workstring with the string without }|{ for further processing $sInput = $sfinrep $SpinArray = StringRegExp($sInput, '{([^{]*?|[^{]*?)}',3); Global matches ;~ ConsoleWrite("final replaced string:" & @CRLF) ;~ ConsoleWrite($sInput & @CRLF) EndIf $TrimmedText = StringRegExpReplace($sInput, '{([^{]*?|[^{]*?)}',chr(0x1A)); or any other special char to mark where to insert $RNDText = $TrimmedText For $i = 0 To UBound($SpinArray)-1 $WordArray = StringSplit($SpinArray[$i], "|",3) $rnum = Random(0, UBound($WordArray)-1, 1); get random Array index $RNDText = StringReplace($RNDText, chr(0x1A), $WordArray[$rnum],1); replace only the next occurrence Next ;~ ConsoleWrite($RNDText & @CRLF) ;~ ConsoleWrite("- Iteration "&$a&" End -" & @CRLF) ;~ $a += 1 Return Spintax($RNDText) EndFunc Thanks @qsek and @water :)
    1 point
  7. The way I do it is to have curl store each response in a file whose file name uniquely identifies the request and then process the files accordingly. Longer explanation below:
    1 point
  8. pixelsearch

    Infinite scroll

    @mutleey I just scripted what follows to use an imagelist control and it worked. I placed 6 images (jpg) in the script directory, resized them 100x100 (didn't care about the ratio because I just wanted to get a quick result, would it work or not ?) #include <GDIPlus.au3> #include <GuiImageList.au3> #include <GuiListView.au3> GUICreate("ImageList Create", 400, 300) $idListview = GUICtrlCreateListView("", 2, 2, 394, 296, -1, $LVS_EX_SUBITEMIMAGES) For $i = 0 To 1 ; 2 columns _GUICtrlListView_AddColumn($idListview, "Col " & $i, 105) Next $hImageList = _GUIImageList_Create(100, 100) ; all images are 100x100 _GDIPlus_Startup() For $i = 0 To 5 ; 6 images $hBitmap = _GDIPlus_BitmapCreateFromFile(@ScriptDir & "\image " & $i & ".jpg") $hGDIBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _GUIImageList_Add($hImageList, $hGDIBitmap) _WinAPI_DeleteObject($hGDIBitmap) _GDIPlus_BitmapDispose($hBitmap) Next _GDIPlus_Shutdown() _GUICtrlListView_SetImageList($idListview, $hImageList, 1) ; 1 = Image list with small icons (0 or 2 won't display anything) For $i = 0 To 2 ; 3 rows (2 images per row) _GUICtrlListView_AddItem($idListview, "", $i*2) ; 0/2/4 = image 0/2/4 in Col 0 _GUICtrlListView_AddSubItem($idListview, $i, "", 1, $i*2 +1) ; $i = row, 1 = Col 1 (1st subitem), $i*2 +1 = image 1/3/5 Next GUISetState(@SW_SHOW) Do Until GUIGetMsg() = -3 ; $GUI_EVENT_CLOSE = -3 _GUIImageList_Destroy($hImageList) GUIDelete() The list is naturally scrollable, maybe it could be a good start for what you want to achieve. Good luck and a great day to all of you
    1 point
  9. Solved! I managed to get all the html it generates returned by changing the "SetRequestHeaders" and therefore also the type of response that the server provides me. Obviously now I have to redo all the response parsing work (it no longer responds in json) but I can see everything and it's what I needed. I report below the code that I changed in case it is also useful to someone else Original: $oHTTP.Open("GET", $url&"/dynamic_load/0", False) $oHTTP.SetRequestHeader("Accept", "application/json") $oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded") $oHTTP.Send() $oReceived = $oHTTP.ResponseText $oStatusCode = $oHTTP.Status Consolewrite($oReceived & @crlf) Modified: $oHTTP.Open("GET", $url&"/dynamic_load/0", False) $oHTTP.SetRequestHeader("Accept", "text/html, application/xhtml+xml, image/jxr, */*") $oHTTP.SetRequestHeader("Accept-Encoding", "zip, deflate, text/html, application/xhtml+xml, image/jxr, */*") $oHTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko") $oHTTP.SetRequestHeader("Referer", $url) $oHTTP.Send() $oReceived = $oHTTP.ResponseText $oStatusCode = $oHTTP.Status Consolewrite($oReceived & @crlf) Thanks Marco
    1 point
  10. HezzelQuartz, If you look inside the Help file you will find the following functions: _FileReadToArray _ArrayAdd _ArraySort _FileWriteFromArray complete with examples of how to use them. I was rather hoping you might do that yourself once given the sequence of actions.... M23
    1 point
  11. Why don't you save the timestamp in the JPG itself?
    1 point
  12. pat4005

    Wake on LAN UDF

    A tiny UDF that can shoot magic packets at your computers to wake them the heck up. All credits to Olish. The only parameter it needs to be specified – is your machine's MAC-address (ip address (the second parameter), at which you will be sending magic packet is generating automatically from @IPAddress1 macro) Example: _WoL_WakeDevice('001CC0CAED7A') ; the second parameter (if necessery) must be a broadcast address of your local network segment (i.e. 192.168.0.255 for a network 192.168.0.0) _WakeOnLan.au3
    1 point
  13. A better solution - re-embed on receipt of WM_PAINT message #AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <WindowsConstants.au3> #include <GuiConstantsEx.au3> #include <Timers.au3> #include <GuiStatusBar.au3> #include <ProgressConstants.au3> Opt("MustDeclareVars", 1) Global $iMemo, $hStatusBar, $progress, $percent = 0, $direction = 1 _Example_CallBack() Func _Example_CallBack() Local $hGUI, $iTimerProgress, $btn_change, $iWait = 10, $btn_state Local $aParts[3] = [75, 330, -1] $hGUI = GUICreate("Timers Using CallBack Function(s)", 400, 320) $iMemo = GUICtrlCreateEdit("", 2, 32, 396, 226, BitOR($WS_HSCROLL, $WS_VSCROLL)) GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New") $btn_state = GUICtrlCreateButton("Start Progress Bar", 70, 270, 100, 25) $btn_change = GUICtrlCreateButton("Change", 215, 270, 90, 25) GUICtrlSetState($btn_change, $GUI_DISABLE) $hStatusBar = _GUICtrlStatusBar_Create($hGUI, $aParts) _GUICtrlStatusBar_SetText($hStatusBar, "Timers") _GUICtrlStatusBar_SetText($hStatusBar, @TAB & @TAB & StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC), 2) $progress = GUICtrlCreateProgress(0, 0, -1, -1, $PBS_SMOOTH) GUICtrlSetColor($progress, 0xff0000) _GUICtrlStatusBar_EmbedControl($hStatusBar, 1, GUICtrlGetHandle($progress)) GUISetState() GUIRegisterMsg($WM_PAINT, "_WM_PAINT") _Timer_SetTimer($hGUI, 1000, "_UpdateStatusBarClock") ; create timer While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $btn_state If GUICtrlRead($btn_state) = "Start Progress Bar" Then $iTimerProgress = _Timer_SetTimer($hGUI, $iWait, "_UpdateProgressBar") ; create timer If @error Or $iTimerProgress = 0 Then ContinueLoop GUICtrlSetData($btn_state, "Stop Progress Bar") GUICtrlSetState($btn_change, $GUI_ENABLE) Else GUICtrlSetState($btn_change, $GUI_DISABLE) _Timer_KillTimer($hGUI, $iTimerProgress) GUICtrlSetData($btn_state, "Start Progress Bar") EndIf Case $btn_change If $iWait = 10 Then $iWait = 250 Else $iWait = 10 EndIf MemoWrite("Timer for _UpdateProgressBar set at: " & $iWait & " milliseconds") $iTimerProgress = _Timer_SetTimer($hGUI, $iWait, "", $iTimerProgress) ; reuse timer with different interval EndSwitch WEnd ConsoleWrite("Killed All Timers? " & _Timer_KillAllTimers($hGUI) & @CRLF) GUIDelete() EndFunc ;==>_Example_CallBack ; call back function Func _UpdateStatusBarClock($hWnd, $Msg, $iIDTimer, $dwTime) #forceref $hWnd, $Msg, $iIDTimer, $dwTime _GUICtrlStatusBar_SetText($hStatusBar, @TAB & @TAB & StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC), 2) EndFunc ;==>_UpdateStatusBarClock ; call back function Func _UpdateProgressBar($hWnd, $Msg, $iIDTimer, $dwTime) #forceref $hWnd, $Msg, $iIDTimer, $dwTime $percent += 5 * $direction GUICtrlSetData($progress, $percent) If $percent = 100 Or $percent = 0 Then $direction *= -1 If $percent = 100 Then GUICtrlSetColor($progress, 0xff0000) ElseIf $percent = 0 Then GUICtrlSetColor($progress, 0x0000ff) EndIf EndFunc ;==>_UpdateProgressBar ; Write a line to the memo control Func MemoWrite($sMessage) GUICtrlSetData($iMemo, $sMessage & @CRLF, 1) EndFunc ;==>MemoWrite Func _WM_PAINT($hWnd, $Msg) _GUICtrlStatusBar_EmbedControl($hStatusBar, 1, GUICtrlGetHandle($progress)) Return 'GUI_RUNDEFMSG' EndFunc ;==>WM_PAINT
    1 point
  14. MrCreatoR Quick and rough example: #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListBox.au3> #include <WinAPI.au3> #include <GDIPlus.au3> Global Const $ODT_LISTBOX = 2 Global Const $ODA_DRAWENTIRE = 0x1 Global Const $ODA_SELECT = 0x2 Global Const $ODS_SELECTED = 0x1 $hGUI = GUICreate("Test GUI", 300, 200) $hListBox = _GUICtrlListBox_Create($hGUI, "", 10, 10, 280, 180, BitOR($LBS_HASSTRINGS, $LBS_OWNERDRAWFIXED)) For $i = 1 To 10 _GUICtrlListBox_AddString($hListBox, "String " & $i) Next _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile("c:\Program Files\AutoIt3\Examples\GUI\Advanced\Images\Blue.bmp") $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hListBox) GUIRegisterMsg($WM_DRAWITEM, "WM_DRAWITEM") GUISetState() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() Func WM_DRAWITEM($hWnd, $Msg, $wParam, $lParam) Local $tagDRAWITEMSTRUCT, $cID, $itmID, $itmAction, $itmState, $hItm, $hDC, $iBrushColor, $hBrush, $hBrushOld $tagDRAWITEMSTRUCT = DllStructCreate("uint cType;uint cID;uint itmID;uint itmAction;uint itmState;" & _ "hwnd hItm;hwnd hDC;int itmRect[4];dword itmData", $lParam) If DllStructGetData($tagDRAWITEMSTRUCT, "cType") <> $ODT_LISTBOX Then Return $GUI_RUNDEFMSG $cID = DllStructGetData($tagDRAWITEMSTRUCT, "cID") $itmID = DllStructGetData($tagDRAWITEMSTRUCT, "itmID") $itmAction = DllStructGetData($tagDRAWITEMSTRUCT, "itmAction") $itmState = DllStructGetData($tagDRAWITEMSTRUCT, "itmState") $hItm = DllStructGetData($tagDRAWITEMSTRUCT, "hItm") $hDC = DllStructGetData($tagDRAWITEMSTRUCT, "hDC") Switch $itmAction Case $ODA_DRAWENTIRE, $ODA_SELECT If $itmState = $ODS_SELECTED Then $iBrushColor = 0x6495ED Else $iBrushColor = 0x66CDAA EndIf $hBrush = _WinAPI_CreateSolidBrush($iBrushColor) $hBrushOld = _WinAPI_SelectObject($hDC, $hBrush) DLLCall("user32.dll","int","FillRect", _ "hwnd", $hDC, _ "ptr", DllStructGetPtr($tagDRAWITEMSTRUCT, "itmRect"), _ "hwnd", $hBrush) _WinAPI_SelectObject($hDC, $hBrushOld) _WinAPI_DeleteObject($hBrush) DLLCall("gdi32.dll","int","SetBkMode", "hwnd", $hDC, "int", 1) Local $tBuffer = DllStructCreate("char[256]") DllCall("user32.dll", "int", "SendMessage", _ "hwnd", $hItm, _ "int", $LB_GETTEXT, _ "int", $itmID, _ "ptr", DllStructGetPtr($tBuffer)) $itmText = DllStructGetData($tBuffer, 1) Local $tRECT = DllStructCreate("int Left;int Top;int Right;int Bottom") DllStructSetData($tRECT, "Left", DllStructGetData($tagDRAWITEMSTRUCT, "itmRect", 1) + 12) DllStructSetData($tRECT, "Top", DllStructGetData($tagDRAWITEMSTRUCT, "itmRect", 2)) DllStructSetData($tRECT, "Right", DllStructGetData($tagDRAWITEMSTRUCT, "itmRect", 3)) DllStructSetData($tRECT, "Bottom", DllStructGetData($tagDRAWITEMSTRUCT, "itmRect", 4)) DllCall("user32.dll", "int", "DrawText", "hwnd", $hDC, "str", $itmText, "int", StringLen($itmText), _ "ptr", DllStructGetPtr($tRECT), "int", $DT_LEFT) Local $iX = DllStructGetData($tagDRAWITEMSTRUCT, "itmRect", 1) Local $iY = DllStructGetData($tagDRAWITEMSTRUCT, "itmRect", 2) + 2 _GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage, $iX, $iY, 10, 10) EndSwitch Return $GUI_RUNDEFMSG EndFunc
    1 point
×
×
  • Create New...