Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/08/2022 in all areas

  1. Verssuss, And just for fun, a dummy updown: #include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) $cInput = GUICtrlCreateInput(1, 10, 10, 50, 20) $cDummyInput = GUICtrlCreateInput(10, 75, 10, 1, 20) $cUpDown = GUICtrlCreateUpdown($cDummyInput) GUICtrlSetLimit($cUpDown, 19, 0) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cDummyInput _SetData() EndSwitch WEnd Func _SetData() Local $iDummy = Number(GUICtrlRead($cDummyInput)) If $iDummy >= 10 Then GUICtrlSetData($cInput, $iDummy - 9) Else GUICtrlSetData($cInput, "." & $iDummy) EndIf M23
    1 point
  2. Ok... after some digging I found the reason of the difference in displaying 1 or 2 backslashes when the API contains \\: I had for some mystic reason this one in my SciTEUser.properties: calltip.*.use.escapes=1 ... so that is the reason and this means that I have to change the script to only save a single \ for the include text to the dynamic api files. Will change the script and upload a new zip file. Changed and uploaded.
    1 point
  3. Danp2

    Websockets and AutoIt

    I was just looking into that. Here's the request -- Frame 435: 260 bytes on wire (2080 bits), 260 bytes captured (2080 bits) on interface \Device\NPF_Loopback, id 0 Null/Loopback Internet Protocol Version 4, Src: 127.0.0.1, Dst: 127.0.0.1 Transmission Control Protocol, Src Port: 56835, Dst Port: 9222, Seq: 1, Ack: 1, Len: 216 Source Port: 56835 Destination Port: 9222 [Stream index: 5] [Conversation completeness: Complete, WITH_DATA (31)] [TCP Segment Len: 216] Sequence Number: 1 (relative sequence number) Sequence Number (raw): 2973920447 [Next Sequence Number: 217 (relative sequence number)] Acknowledgment Number: 1 (relative ack number) Acknowledgment number (raw): 555817769 0101 .... = Header Length: 20 bytes (5) Flags: 0x018 (PSH, ACK) Window: 8442 [Calculated window size: 2161152] [Window size scaling factor: 256] Checksum: 0xfffa [unverified] [Checksum Status: Unverified] Urgent Pointer: 0 [Timestamps] [SEQ/ACK analysis] TCP payload (216 bytes) Hypertext Transfer Protocol GET /session/afbb4b0c-aed8-45db-b16e-baba587e7369 HTTP/1.1\r\n Host: 127.0.0.1:9222\r\n Upgrade: websocket\r\n Connection: Upgrade\r\n Sec-WebSocket-Key: Fz/9gz4uVaJHZU8885/ryQ==\r\n Origin: 127.0.0.1\r\n Sec-WebSocket-Version: 13\r\n \r\n [Full request URI: http://127.0.0.1:9222/session/afbb4b0c-aed8-45db-b16e-baba587e7369] [HTTP request 1/1] [Response in frame: 457] I believe http is correct here because this is the request where the upgrade from http --> websocket is taking place. Here's an open issue that I believe touches on this issue.
    1 point
  4. Danp2

    Websockets and AutoIt

    Here are the full details of the failing request to FF -- Frame 457: 195 bytes on wire (1560 bits), 195 bytes captured (1560 bits) on interface \Device\NPF_Loopback, id 0 Section number: 1 Interface id: 0 (\Device\NPF_Loopback) Encapsulation type: NULL/Loopback (15) Arrival Time: Nov 7, 2022 19:09:33.752941000 Central Standard Time [Time shift for this packet: 0.000000000 seconds] Epoch Time: 1667869773.752941000 seconds [Time delta from previous captured frame: 0.000023000 seconds] [Time delta from previous displayed frame: 0.001845000 seconds] [Time since reference or first frame: 18.164051000 seconds] Frame Number: 457 Frame Length: 195 bytes (1560 bits) Capture Length: 195 bytes (1560 bits) [Frame is marked: True] [Frame is ignored: False] [Protocols in frame: null:ip:tcp:http:data-text-lines] [Coloring Rule Name: HTTP] [Coloring Rule String: http || tcp.port == 80 || http2] Null/Loopback Internet Protocol Version 4, Src: 127.0.0.1, Dst: 127.0.0.1 0100 .... = Version: 4 .... 0101 = Header Length: 20 bytes (5) Differentiated Services Field: 0x00 (DSCP: CS0, ECN: Not-ECT) Total Length: 191 Identification: 0x2918 (10520) 010. .... = Flags: 0x2, Don't fragment ...0 0000 0000 0000 = Fragment Offset: 0 Time to Live: 128 Protocol: TCP (6) Header Checksum: 0x0000 [validation disabled] [Header checksum status: Unverified] Source Address: 127.0.0.1 Destination Address: 127.0.0.1 Transmission Control Protocol, Src Port: 9222, Dst Port: 56835, Seq: 1, Ack: 217, Len: 151 Source Port: 9222 Destination Port: 56835 [Stream index: 5] [Conversation completeness: Complete, WITH_DATA (31)] [TCP Segment Len: 151] Sequence Number: 1 (relative sequence number) Sequence Number (raw): 555817769 [Next Sequence Number: 152 (relative sequence number)] Acknowledgment Number: 217 (relative ack number) Acknowledgment number (raw): 2973920663 0101 .... = Header Length: 20 bytes (5) Flags: 0x018 (PSH, ACK) Window: 8441 [Calculated window size: 2160896] [Window size scaling factor: 256] Checksum: 0x0b33 [unverified] [Checksum Status: Unverified] Urgent Pointer: 0 [Timestamps] [SEQ/ACK analysis] TCP payload (151 bytes) Hypertext Transfer Protocol HTTP/1.1 400 Bad Request\r\n [Expert Info (Chat/Sequence): HTTP/1.1 400 Bad Request\r\n] Response Version: HTTP/1.1 Status Code: 400 [Status Code Description: Bad Request] Response Phrase: Bad Request Server: httpd.js\r\n Content-Type: text/plain\r\n Content-Length: 59\r\n \r\n [HTTP response 1/1] [Time since request: 0.001871000 seconds] [Request in frame: 435] [Request URI: http://127.0.0.1:9222/session/afbb4b0c-aed8-45db-b16e-baba587e7369] File Data: 59 bytes Line-based text data: text/plain (1 lines) The handshake request has incorrect Origin header 127.0.0.1
    1 point
  5. TheXman

    Websockets and AutoIt

    Hello @Danp2 In your research, have you come across sgcWebSocketApps? Although they primarily make components for .Net, Delphi, Lazarus, & C++ Builder, they also have CLI versions that are pretty feature-rich. I have had success using their WebSocket CLI tools in AutoIT scripts. As you can see here, they not only support RFC 6455 (the WebSocket Protocol) but they also support other sub protocols and related app API's like: WebRTC, MQTT, SignalR, Kraken, Soket.IO, and STOMP. Here, you can see that they have been tested using a pretty comprehensive set of test cases and you can also see how they stacked up against Chrome, Firefox, and IE Websocket support. However, the browsers are a bit dated because the tests were from 2019. After reading over their documentation, if you think their CLI WebSocket Client and/or their other apps may fit your needs, since I've used them with success in some of my scripts, I may be able to help flatten your learning curve by answering questions you may have or by possibly providing stripped down examples taken from my scripts. For the record, I have no relationship with or to ESEGECE, I just found their products useful and decided to share them as a possible solution for your future WebDriver WebSocket needs. 🙂 Quick Summary of sgcWebSocket CLI Client/Server features: Fully functional multithreaded WebSocket server according to RFC 6455. Supports Windows 32/64. Supports MacOSX 32/64. Supports LINUX. Embedded TCP server for external access to the CLI app. Supports Message Compression using PerMessage_Deflate extension RFC 7692. Supports Text and Binary Messages. WatchDog and HeartBeat built-in support (Keep-Alive & Auto-Reconnect support). Built-in sub-protocols: WebRTC, MQTT (3.1.1 and 5.0) and more. (Built-in refers to the components. They have standalone CLI tools.) Client Built-in API: SignalR Core, Kraken, STOMP, SocketIO and more. (Built-in refers to the components. They have standalone CLI tools.) Built-in Javascript libraries to support browser clients. (Built-in refers to the components. They have standalone CLI tools.) SSL/TLS Support for Server / Client Components.
    1 point
  6. @TimRude try to subclass the listview, it should intercept the right-click before it reaches it : #include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> #include <WinAPIShellEx.au3> OnAutoItExitRegister('OnAutoItExit') Global $g_hListView ; Register DLL callback that will be used as window subclass procedure Global $g_hDll = DllCallbackRegister('_SubclassProc', 'lresult', 'hwnd;uint;wparam;lparam;uint_ptr;dword_ptr') Global $g_pDll = DllCallbackGetPtr($g_hDll) Example() Func Example() Local $hGUI, $hImage $hGUI = GUICreate("ListView Create (v" & @AutoItVersion & ")", 400, 300) $g_hListView = _GUICtrlListView_Create($hGUI, "", 2, 2, 394, 268) _GUICtrlListView_SetExtendedListViewStyle($g_hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)) ; Install window subclass callback _WinAPI_SetWindowSubclass($g_hListView, $g_pDll, 1000, 0) GUISetState(@SW_SHOW) ; Load images $hImage = _GUIImageList_Create() _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($g_hListView, 0xFF0000, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($g_hListView, 0x00FF00, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($g_hListView, 0x0000FF, 16, 16)) _GUICtrlListView_SetImageList($g_hListView, $hImage, 1) ; Add columns _GUICtrlListView_InsertColumn($g_hListView, 0, "Column 1", 100) _GUICtrlListView_InsertColumn($g_hListView, 1, "Column 2", 100) _GUICtrlListView_InsertColumn($g_hListView, 2, "Column 3", 100) ; Add items _GUICtrlListView_AddItem($g_hListView, "Row 1: Col 1", 0) _GUICtrlListView_AddSubItem($g_hListView, 0, "Row 1: Col 2", 1) _GUICtrlListView_AddSubItem($g_hListView, 0, "Row 1: Col 3", 2) _GUICtrlListView_AddItem($g_hListView, "Row 2: Col 1", 1) _GUICtrlListView_AddSubItem($g_hListView, 1, "Row 2: Col 2", 1) _GUICtrlListView_AddItem($g_hListView, "Row 3: Col 1", 2) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example Func _SubclassProc($hWnd, $iMsg, $wParam, $lParam, $iID, $pData) #forceref $iID, $pData If $iMsg = $WM_RBUTTONDOWN Then Return 0 Return _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) EndFunc ;==>_SubclassProc Func OnAutoItExit() _WinAPI_RemoveWindowSubclass($g_hListView, $g_pDll, 1000) DllCallbackFree($g_hDll) EndFunc ;==>OnAutoItExit
    1 point
  7. My 2 cents My 0.5 cents ... 😊 Local $a[] = ['a4', 22, 44, 33, 5, 3, 4, 4, 'a4', 22, 44, 66, 234, 'a4', 234, 31, 34, 55, 'a4', 22, 44] Local $c[] = ['a4', 22, 44] Local $bMatch For $ia = 0 To UBound($a) - UBound($c) $bMatch = 0 For $ic = 0 To UBound($c) - 1 $bMatch += ($a[$ia + $ic] == $c[$ic]) Next If $bMatch = UBound($c) Then ConsoleWrite("sequence found at index " & $ia & @CRLF) Next
    1 point
  8. With no loop at all : #include <Array.au3> #include <Constants.au3> Local $a[] = [33, 5, 3, 4, 4, 'a4', 2, 22, 66, 234, 'a4', 234, 31, 34, 55, 'a4', 22, 44] Local $c[] = ['a4', 22, 44] Local $pos = _ArrayInArray($a, $c) If Not @error Then MsgBox($MB_SYSTEMMODAL, "", $pos & "th value (base-0)") Func _ArrayInArray(ByRef $a, ByRef $c) Local $aStr = _ArrayToString($a) Local $found = StringInStr($aStr, _ArrayToString($c)) If Not $found Then Return SetError(1, 0, -1) StringReplace(StringLeft($aStr, $found - 1), "|", "|", 0, $STR_CASESENSE) Return @extended EndFunc ;==>_ArrayInArray Edit : increase speed with removing case sensitivity
    1 point
  9. #include <MsgBoxConstants.au3> Local $a[]=[33,5,3,4,4,'a4',2,22,66,234,'a4',234,31,34,55,'a4',22,44] Local $c[]=['a4',22,44] Local $lastrow=UBound($a)-1 Local $lastcol=UBound($c)-1 Local $d=$c[0] & "/" For $cc=1 To $lastcol $d&= $c[$cc] & "/" ; this ensures 1/23 and 12/3 are not confused Next Local $e For $rc=0 To $lastrow-$lastcol ; no need to search beyond what would fit $e=$a[$rc] & "/" For $cc=1 To $lastcol $e&=$a[$rc+$cc] & "/" Next ; NB performing a STRING comparison on values (is this intended?) If $d==$e Then MsgBox($MB_SYSTEMMODAL, "", $rc &"th value (base-0)" ) Next A different way: #include <Array.au3> #include <MsgBoxConstants.au3> Local $a[]=[33,5,3,4,4,'a4',2,22,66,234,'a4',234,31,34,55,'a4',22,44] Local $c[]=['a4',22,44] Local $aStr=_ArrayToString($a) & "|" Local $cStr=_ArrayToString($c) & "|" Local $found=StringInStr($aStr,$cStr) if $found>0 Then Local $pos=0 For $b=1 To $found-1 $pos+=(StringMid($aStr,$b,1)="|") Next MsgBox($MB_SYSTEMMODAL, "", $pos &"th value (base-0)" ) EndIf Incorporating Nine's suggestion in the next post, this is shorter still (but does not contain a For-loop as requested by OP): #include <Array.au3> #include <MsgBoxConstants.au3> Local $a[]=[33,5,3,4,4,'a4',2,22,66,234,'a4',234,31,34,55,'a4',22,44] Local $c[]=['a4',22,44] Local $aStr=_ArrayToString($a) & "|" Local $found=StringInStr($aStr,_ArrayToString($c) & "|") If $found>0 Then StringReplace(StringLeft($aStr,$found-1),"|","|") MsgBox($MB_SYSTEMMODAL, "", (($found>0)?(@extended & "th value (base-0)"):("not found"))) EDIT: There was an edge-case that wasn't properly handled in all my examples (final substring part was unterminated so could trigger a false-positive), now fixed.
    1 point
  10. Something like the following code? #include <Array.au3> #include <MsgBoxConstants.au3> Local $a[]=[33,5,3,4,4,'a4',2,22,66,234,'a4',234,31,34,55,'a4',22,44] Local $c[]=['a4',22,44] For $ic=0 To Ubound($c) - 1 For $ia=0 To UBound($a) - 1 If $c[$ic]==$a[$ia] Then MsgBox($MB_SYSTEMMODAL, "", "value " & $c[$ic] & " found in $a at index " & $ia) EndIf Next Next
    1 point
  11. Greetings everyone, I'd like to start my own cURL UDF, with a focus on a nice and simple syntax. There are many other cURL samples in the forum, though I found them too difficult to understand and use. This UDF uses the libcurl library, as opposed to the cURL command-line tool, to provide better integration with AutoIT and better performance. REQUIREMENTS: Windows 32-bit (not tested under Windows 64-bit but may work if a 64-bit version of libcurl below is used) AutoIt3 3.2 or higher libcurl v7.21.7 or higher (libcurl.dll, libeay32.dll & libssl32.dll) - see http://curl.haxx.se or download link below LIST OF FUNCTIONS: EXAMPLES: Note - To make these examples work, you must make sure the three libcurl DLLs (libcurl.dll, libeay32.dll & libssl32.dll) are present in the same folder as the examples. Example #1 - Reading HTML from a webpage. #include <cURL.au3> ; Initialise cURL cURL_initialise() ; Return the HTML from "http://www.autoitscript.com/site" $response = cURL_easy("http://www.autoitscript.com/site/") ; Output the response to the console ConsoleWrite("HTTP Response Code = " & $response[0] & @CRLF) ConsoleWrite("HTTP Response Headers = " & $response[1] & @CRLF) ConsoleWrite("HTTP Response Data = " & $response[2] & @CRLF) ; Clean up cURL cURL_cleanup() Example #2 - Reading a binary file from a website. #include <cURL.au3> ; Initialise cURL cURL_initialise() ; Output the file from "http://web.aanet.com.au/seangriffin/content/computing/development/eBay%20Bargain%20Hunter%20setup.exe" to "tmp.exe" cURL_easy("http://web.aanet.com.au/seangriffin/content/computing/development/eBay%20Bargain%20Hunter%20setup.exe", "", 0, 1, "tmp.exe") ; Clean up cURL cURL_cleanup() Example #3 - Reading HTML from a webpage, and writing the cookie to a file. #include <cURL.au3> ; Initialise cURL cURL_initialise() ; Return the response from "http://www.about.com", and the cookie to the file "cookie.txt" $response = cURL_easy("http://www.about.com", "cookie.txt", 2) ; Output the response to the console ConsoleWrite("HTTP Response Code = " & $response[0] & @CRLF) ConsoleWrite("HTTP Response Headers = " & $response[1] & @CRLF) ConsoleWrite("HTTP Response Data = " & $response[2] & @CRLF) ; Clean up cURL cURL_cleanup() DOWNLOAD: Recent Version of libcurl.dll, libeay32.dll & libssl32.dll (required) http://fossies.org/windows/www/curl-7.24.0-ssl-sspi-zlib-static-bin-w32.zip Latest Version - v0.3 (03/04/16) cURL.au3
    1 point
  12. Here we go: #include <GDIPlus.au3> Global $sFile = FileOpenDialog("Select an image", "", "Images (*.jpg;*.bmp;*.png;*.gif)") If @error Then Exit MsgBox(16, "Error", "You must select an image!", 20) _GDIPlus_Startup() Global Const $hImg = _GDIPlus_ImageLoadFromFile($sFile) Global Const $hBmp = _GDIPlus_BitmapCreateRoundedCornerFromBitmap($hImg) _GDIPlus_ImageSaveToFile($hBmp, @ScriptDir & "\TestImg.png") _GDIPlus_ImageDispose($hImg) _GDIPlus_ImageDispose($hBmp) _GDIPlus_Shutdown() ShellExecute(@ScriptDir & "\TestImg.png") Func _GDIPlus_BitmapCreateRoundedCornerFromBitmap($hImage, $fRadiusCorner = -1, $bBorder = False, $iBorderColor = 0xE0FFFFFF, $iBorderSize = 1) ;coded by UEZ buid 2017-04-17 Local $aDim = _GDIPlus_ImageGetDimension($hImage) If @error Then Return SetError(1, 0, 0) Local Const $iW = $aDim[0], $iH = $aDim[1] Local Const $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH), $hGfx = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetSmoothingMode($hGfx, 4) _GDIPlus_GraphicsSetPixelOffsetMode($hGfx, 4) _GDIPlus_GraphicsSetCompositingQuality($hGfx, 2) Local Const $hTexture = _GDIPlus_TextureCreate($hImage) Local Const $hPath = _GDIPlus_PathCreate() If $fRadiusCorner = -1 Then $fRadiusCorner = (($iW + $iH) / 2) * 0.1 EndIf _GDIPlus_PathAddArc($hPath, $iW - ($fRadiusCorner * 2), 0, $fRadiusCorner * 2, $fRadiusCorner * 2, 270, 90) _GDIPlus_PathAddArc($hPath, $iW - ($fRadiusCorner * 2), $iH - ($fRadiusCorner * 2), $fRadiusCorner * 2, $fRadiusCorner * 2, 0, 90) _GDIPlus_PathAddArc($hPath, 0, $iH - ($fRadiusCorner * 2), $fRadiusCorner * 2, $fRadiusCorner * 2, 90, 90) _GDIPlus_PathAddArc($hPath, 0, 0, $fRadiusCorner * 2, $fRadiusCorner * 2, 180, 90) _GDIPlus_PathCloseFigure($hPath) _GDIPlus_GraphicsFillPath($hGfx, $hPath, $hTexture) If $bBorder Then Local Const $hPen = _GDIPlus_PenCreate($iBorderColor, $iBorderSize) _GDIPlus_PenSetLineJoin($hPen, 2) _GDIPlus_PenSetAlignment($hPen, 1) _GDIPlus_GraphicsDrawPath($hGfx, $hPath, $hPen) _GDIPlus_PenDispose($hPen) EndIf _GDIPlus_GraphicsDispose($hGfx) _GDIPlus_BrushDispose($hTexture) _GDIPlus_PathDispose($hPath) Return $hBitmap EndFunc ;==>_GDIPlus_BitmapCreateRoundedCornerFromBitmap
    1 point
  13. That example is still a little broken. Here: #NoTrayIcon #include <GDIPlus.au3> #include <WinAPI.au3> #include <ScreenCapture.au3> _GDIPlus_Startup() $hGUI = WinGetHandle("AutoIt Help") WinMove($hGUI, "", @DesktopWidth-100, @DesktopHeight) $iWidth = _WinAPI_GetWindowWidth($hGUI) $iHeight = _WinAPI_GetWindowHeight($hGUI) $hParent = GUICreate("WindowViewer", 500, 400) $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hParent) GUISetState() $hBMP = _WinCapture($hGUI, $iWidth, $iHeight) $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBMP) _GDIPlus_GraphicsDrawImageRectRect($hGraphics, $hImage, 0, 0, $iWidth, $iHeight, 50, 50, 400, 300) _GDIPlus_ImageDispose($hImage) _GDIPlus_GraphicsDispose($hGraphics) _WinAPI_DeleteObject($hBMP) Sleep(5000) Func _WinCapture($hWnd, $iWidth = -1, $iHeight = -1) Local $iH, $iW, $hDDC, $hCDC, $hBMP If $iWidth = -1 Then $iWidth = _WinAPI_GetWindowWidth($hWnd) If $iHeight = -1 Then $iHeight = _WinAPI_GetWindowHeight($hWnd) $hDDC = _WinAPI_GetDC($hWnd) $hCDC = _WinAPI_CreateCompatibleDC($hDDC) $hBMP = _WinAPI_CreateCompatibleBitmap($hDDC, $iWidth, $iHeight) _WinAPI_SelectObject($hCDC, $hBMP) DllCall("User32.dll", "int", "PrintWindow", "hwnd", $hWnd, "hwnd", $hCDC, "int", 0) _WinAPI_BitBlt($hCDC, 0, 0, $iW, $iH, $hDDC, 0, 0, 0x00330008) _WinAPI_ReleaseDC($hWnd, $hDDC) _WinAPI_DeleteDC($hCDC) _ScreenCapture_SaveImage(@DesktopDir&"\window.jpg", $hBMP, False) Return $hBMP EndFunc ;==>_WinCapture
    1 point
  14. The only way I know to do it is have the window visible, but moved off the screen.
    1 point
×
×
  • Create New...