Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/26/2022 in all areas

  1. I've recently taken over the development of an extension for Visual Studio Code, which I've found to have a great mix of features as a code editor. I've recently been able to get the extension to a point that it could launch scripts from the editor, open the help docs on a highlighted keyword, and launch the Info app. I'm still working on wrapping my head around the inner workings of VSCode to be able to implement advanced features like Intellisense but would appreciate any feedback (bugs, feature requests, new different snippets) in this thread or on the GitHub page where I'm maintaining the extension. You check out the extension on the VSCode Marketplace here and view the code on GitHub here. Edit: Go to http://code.visualstudio.com/docs/setup/windows for information on installing Visual Studio Code. See http://code.visualstudio.com/docs/editor/extension-gallery for information on installing extensions to VS Code.
    1 point
  2. trancexx

    WinHTTP functions

    The other day mikeytown2 posted one post in HTTP UDF's thread that got me thinking if there is better (different) method to send requests through the HTTP protocol to HTTP servers. There is Winhttp.dll that ships with windows and that is its main purpose. I couldn't find any examples of using this dll in AutoIt, so I came up with this. Microsoft about Windows HTTP Services: Microsoft Windows HTTP Services (WinHTTP) provides developers with an HTTP client application programming interface (API) to send requests through the HTTP protocol to other HTTP servers... .. blah, blah, and so on... This is an example of getting page header: #include "WinHttp.au3" Opt("MustDeclareVars", 1) ; Open needed handles Local $hOpen = _WinHttpOpen() Local $hConnect = _WinHttpConnect($hOpen, "msdn.microsoft.com") ; Specify the reguest: Local $hRequest = _WinHttpOpenRequest($hConnect, Default, "en-us/library/aa384101(VS.85).aspx") ; Send request _WinHttpSendRequest($hRequest) ; Wait for the response _WinHttpReceiveResponse($hRequest) Local $sHeader = _WinHttpQueryHeaders($hRequest) ; ...get full header ; Clean _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) ; Display retrieved header MsgBox(0, "Header", $sHeader)Everything you need to be able to use this UDF can be found at WinHttp site. Remember, basic understanding of the HTTP protocol is important to use this interface. ProgAndy, trancexx WinHttp.au3 is completely free and no one has right to charge you for it. That's very important. If you feel WinHttp.au3 was helpful to you and you wish to support my further work you can donate to my personal account via PayPal address: trancexx at yahoo dot com I will appreciate that very much. Thank you in advance! :kiss:
    1 point
  3. Jos

    Help with conquer issue

    @ad777, Please ONLY report posts instead of replying to them when they are against our forum rules!
    1 point
  4. Regular expressions (RE) are in substance a series of arguments passed to a program (the RE engine), expressing what to search with explicit conditions. Hence it requires the same rigor to define formally (with mathematical rigor) what you consider to be a match. This phrasing from your first post doesn't seem to match what you tell us now. It looks like you need to match a series of exactly 9 digits preceeded and followed by whitespace(s), but only you can tell. Is that a correct definition for your use case?
    1 point
  5. A possible way, using word boundary \b Local $sData1 = "This is an example text which may include the correct thing 123456789. This is not 42345678.9 correct. This is not correct either as it contains 10 digits:1234567890" $res = StringRegExp($sData1,"\b\d{9}\b", 1) Msgbox(0,"", $res[0])
    1 point
  6. StringRegExp() help is your closest friend. Then RegExp is a very useful test bench.
    1 point
  7. USSSR, I would use the $STR_REGEXPARRAYFULLMATCH flag to return an array of all matches: #include <StringConstants.au3> #include <Array.au3> Local $sData1 = "This is an example text which may include the correct thing 123456789. This is not 42345678.9 correct. This is not correct either as it contains 10 digits:1234567890" $aRet = StringRegExp($sData1,"\d{9}(?!\.)", $STR_REGEXPARRAYGLOBALMATCH) _ArrayDisplay($aRet, "", Default, 8) The pattern asks for all exact 9 digit strings, not followed by a decimal point to exclude the second case. M23
    1 point
  8. pixelsearch

    Sort question in C++

    Hi everybody A few days ago, I was lucky to discover in this link a thread from @funkey (dated from 2013) where we can find a part in AutoIt and a part in C. funkey's script is interesting, not only for its content, but it helps to learn C and C++ when you're a newbie like me, as it's nicely written. As it was challenging, then I tried to write some simple code to quickly sort a 1D array of strings (using a dll) and the results look promising First of all, here is my code in AutoIt : #include <Array.au3> $hDLL = DllOpen(@ScriptDir & "\rrr.dll") If $hDLL = -1 Then Exit Msgbox(0, "DllOpen", "error occured") ;==================== ;~ Local $aArray[14] = ["john", "bobby", "hello", "test", "catherine", "nomi", "shinta", _ ;~ "martin", "abe", "may", "zeno", "zack", "angel", "gaby"] ; 56 + 14 delim => 80 ;~ ; OR for more elements : Local $iItems = 100000, $aArray[$iItems] FillArray($aArray, $iItems) _ArrayDisplay($aArray, "UNsorted") ;==================== $hTimer = TimerInit() Local $iRows = Ubound($aArray), $sDelim = Chr(1), $sData = "" For $i = 0 To $iRows - 1 $sData &= $aArray[$i] & $sDelim Next ConsoleWrite("Preparing concatenated string = " & Int(TimerDiff($htimer)) & " ms" & @crlf) ;==================== $hTimer = TimerInit() $iBufferSize = StringLen($sData) $tStruct = DllStructCreate("char[" & $iBufferSize & "]") If @error Then Exit Msgbox(0, "DllStructCreate", "error " & @error) DllStructSetData($tStruct, 1, $sData) If @error Then Exit Msgbox(0, "DllStructSetData", "error " & @error) ConsoleWrite("Writing structure = " & Int(TimerDiff($htimer)) & " ms" & @crlf) MsgBox(0, "Pointer of struct", DllStructGetPtr($tStruct) & " Buffer size = " & $iBufferSize) ;==================== $hTimer = TimerInit() $aRet = DllCall($hDLL, "int:cdecl", "StringSort", "ptr", DllStructGetPtr($tStruct), "str", $sDelim, "int", $iRows) If @error Then Exit Msgbox(0, "DllCall StringSort", "error " & @error) ConsoleWrite("DllCall = " & Int(TimerDiff($htimer)) & " ms" & @crlf) _ArrayDisplay($aRet, "$aRet") ;==================== $hTimer = TimerInit() $sSorted = DllStructGetData($tStruct, 1) If @error Then Exit Msgbox(0, "DllStructGetData", "error " & @error) ConsoleWrite("Reading structure = " & Int(TimerDiff($htimer)) & " ms" & @crlf) ;==================== $hTimer = TimerInit() Local $aArray2 = StringSplit($sSorted, Chr(1), 2) ; $STR_NOCOUNT = 2 ConsoleWrite("Generating sorted 1D array = " & Int(TimerDiff($htimer)) & " ms" & @crlf) _ArrayDisplay($aArray2, "Sorted") _StringSplitFree($tStruct) DllClose($hDLL) ;====================================== Func FillArray( ByRef $aItems, $iItems ) ; LarsJ (fill array with random strings) Local $aLetters[26] = [ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', _ 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' ], $s For $i = 0 To $iItems - 1 $s = $aLetters[Random(0,25,1)] For $j = 1 To Random(10,30,1) $s &= $aLetters[Random(0,25,1)] Next $aItems[$i] = $s Next EndFunc ;==>_FillArray ;====================================== Func _StringSplitFree(ByRef $tStruct) ; Funkey DllCall("msvcrt.dll", "none:cdecl", "free", "ptr", DllStructGetPtr($tStruct)) If @error Then Exit Msgbox(0, "DllCall Free", "error " & @error & " occured") $tStruct = 0 EndFunc ;==>_StringSplitFree Now the C++ code : #include <algorithm> // sort #include <string.h> // strtok, strcpy #include <string> // string using namespace std; extern "C" __declspec(dllexport) int StringSort(char* structure, char* sdelim, int irows) { string arr[irows]; int i = 0, ipos = 0; char* p; p = strtok(structure, sdelim); // split string into tokens (returns a pointer). // End of the token (delimiter) is automatically replaced by a null-character // https://www.cplusplus.com/reference/cstring/strtok/ while ((p != NULL) && (i < irows)) { arr[i] = p; p = strtok(NULL, sdelim); i++; } sort(arr, arr + irows); for(i = 0; i < irows; ++i) { strcpy(&structure[ipos], (arr[i] + ((i < irows - 1) ? sdelim : "")).c_str()); // strcpy adds a x00 at the end ipos += arr[i].size() + 1; // overwrite each preceding x00 from strcpy } return 0; } The result on 100.000 random strings looks great on my antique computer. This is what AutoIt console shows for 100.000 strings (about 2s for the whole process) : Preparing concatenated string = 651 ms Writing structure = 44 ms DllCall = 770 ms Reading structure = 37 ms Generating sorted 1D array = 542 ms Here are the different phases I went through, based on a simpler array of 14 strings (also found in the AutoIt code) : * create a string composed of all the (unsorted) array elements, separated by a delimiter. I choosed chr(1) as delimiter, maybe we'll discuss this point later in case you guys have a better idea. There's also a delimiter chr(1) at the end of the concatenated string. * Still in AutoIt, create a structure of char's and populate it with a single instruction (no loop) . Here is what the corresponding memory dump shows at this exact moment : * DllCall : this phase will : a) Split the big unsorted string found in the structure, ending with tokens (each token is an element of a new C array) . It's the C strtok instruction that splits and create tokens. b) Then Sort the Array of strings using C Sort c) Finally overwrite the structure using C strcpy instruction, overwriting carefully each chr(0) that strtok added (it replaced all my separators chr(1) with chr(0) !) . So we'll replace all chr(0) with the originals chr(1), except for the very last one. Watch out carefully for the last byte of the buffer, to avoid ending with a "buffer overflow"... only for one last byte ! Here is what the corresponding memory dump shows at this exact moment : the strings are sorted and there's no buffer overflow if you look at the 81th byte which is outside the buffer (its content is still 0B as in the preceding pic) : * Back to AutoIt : now we read the structure with 1 instruction (no loop) and StringSplit is used to immediately create a new sorted array, that's it. I compiled the C/C++ code with the the free MinGW compiler found in CodeBlocks 17.12 IDE . In case you're interested, it should be easy for you to do same. Thanks for reading Edit 28 january 2022 : Allocate memory on heap to avoid a possible stack overflow (error 0xC00000FD) if too many elements in the array, by doing what follows in C++ code. Replace this : string arr[irows]; With that : // dynamic memory allocation for the array : string *arr = new string[irows]; // works with 1.000.000 elements ... // before returning, delete the dynamically allocated memory delete [] arr; It seems that vectors could have been used instead, but I'm not familiar with them until now. One day maybe... Next step should be to work on 2D arrays. I'll create a new post if the results are promising, Edit 10 february 2022 : Though the preceding script works fine, it will soon be replaced with C++ code based on a Vector of structs (in a future post of this thread)
    1 point
  9. I check deeply https://www.w3.org/TR/webdriver/#print-page And I found solution. Here is full full set of possible options as a JSON string: { "page":{ "width": 29.70 ,"height": 42.00 } ,"margin":{ "top": 2 ,"bottom": 2 ,"left": 2 ,"right": 2 } ,"scale": 0.5 ,"orientation":"landscape" ,"shrinkToFit": true ,"background": true ,"pageRanges": [1, "1-1"] } btw. Just now I'm working on examples for wd_demo.au3 and in next step an FAQ in Wiki.
    1 point
  10. Something for you to play with: ; #FUNCTION# ==================================================================================================================== ; Name...........: _OLT_EML_Get ; Description ...: Returns the content of an EML file as a serialized stream within a single ADO Stream object. ; Syntax.........: _OLT_EML_Get($sEMLPath[, $sProperty = Default]) ; Parameters ....: $sEMLPath - Path to an EML mail file e.g. "C:\Local\Test.EML" ; $sPropery - [optional] Property to return. See Remarks (default = keyword Default) ; Return values .: Success - Sets global variable $__g_oIMessage to the ADO stream object and [optional] returns the specified property ; Failure - Returns 0 and sets @error: ; |1 - Could not create the IMessage object. @extended is set to the COM error code ; |2 - Could not create the ADO stream object. @extended is set to the COM error code ; |3 - Error accessing property $sProperty. Maybe the specified property does not exist? ; Author ........: maniootek, mLipok (in alph. order) ; Modified ......: water ; Remarks .......: The function always sets the global variable $__g_oIMessage to the ADO stream object. ; So you can access all properties after the function has been called. ; This is true even when you call the function using $sProperty to return the value of a single property. ; A list of available properties can be found here: ; iMessage: https://docs.microsoft.com/en-us/previous-versions/office/developer/exchange-server-2007/aa579703(v=exchg.80) ;+ ; Further information: ; ADO: https://docs.microsoft.com/en-us/sql/ado/reference/ado-api/stream-object-ado?view=sql-server-ver15 ; Related .......: ; Link ..........: ; Example .......: ; =============================================================================================================================== Func _OLT_EML_Get($sEMLPath, $sProperty = Default) Local Const $sCLASSID_IMessage = "{CD000001-8B95-11D1-82DB-00C04FB1625D}" ; CLSID of the IMessage interface Local $oADOStream If Not IsDeclared("__g_oIMessage") Then Global Static $__g_oIMessage = ObjCreate($sCLASSID_IMessage) If @error Then Return SetError(1, @error, 0) EndIf $oADOStream = $__g_oIMessage.GetStream() ; Return the message in serialized (wire-transport) format in a ADO stream object If @error Then Return SetError(2, @error, 0) $oADOStream.LoadFromFile($sEMLPath) If @error Then Return SetError(3, @error, 0) $oADOStream.Flush() If $sProperty <> Default Then $sResult = Execute("$__g_oIMessage." & $sProperty) If @error Then Return SetError(3, @error, 0) Return $sResult EndIf EndFunc ;==>_OLT_EML_Get Example: #include <OutlookTools.au3> _OL_ErrorNotify(2) Global $sTextBody = _OLT_EML_Get("C:\Local\Test.EML", "TextBody") ConsoleWrite("@Error: " & @error & ", @Extended: " & @extended & @CRLF) ; Function _OLT_EML_Get returns property TextBody (1) or you directly retrieve the TextBody from the ADO stream (2) ConsoleWrite(StringLeft($sTextBody, 80) & @CRLF) ; Example (1) ConsoleWrite(StringLeft($__g_oIMessage.TextBody, 80) & @CRLF) ; Example (2)
    1 point
  11. A similar discussion occurred recently, but regarding ProcessList --
    1 point
  12. Alright, I gonna provide the code : If $Mother0 = "Gigabyte" Then GUICtrlSetImage($Pic2, $img1) ElseIf $Mother0 = "Biostar" Then GUICtrlSetImage($Pic2, $img2) ElseIf $Mother0 = "Intel" Then GUICtrlSetImage($Pic2, $img3) ElseIf $Mother0 = "Lenovo" Then GUICtrlSetImage($Pic2, $img4) ElseIf $Mother0 = "MSI" Then GUICtrlSetImage($Pic2, $img5) ElseIf $Mother0 = "AsRock" Then GUICtrlSetImage($Pic2, $img6) ElseIf $Mother0 = "asus" Then GUICtrlSetImage($Pic2, $img7) EndIf If $CPU1 = "AMD" Then GUICtrlSetImage($Pic1, $img9) ElseIf $CPU1 = "Intel" Then GUICtrlSetImage($Pic1, $img8) EndIf
    1 point
  13. Hey thanks for your reply! just tried your script & you are totally right aswell, I sort of found a manual work around with this two articles: this works for Win+q (not with Win+w): https://winaero.com/disable-certain-winkey-shortcuts-in-windows-10/ this works disabling with windows whiteboard (Win+w) but still can not assign it https://www.windowscentral.com/how-disable-windows-ink-workspace-windows-10 - temp solution was assigning minimize to win+y and with WindowsPowerToys with admin right assign key remap Win+y to Win+w. this managed to work it is a bit wonky but seems to work! If someone has any other idea on how to mute/disable win+w windows ink workspace and assign hotkey in a clean way super happy to do so
    1 point
×
×
  • Create New...