Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/19/2023 in all areas

  1. Happy I could make myself useful :) Lists like these are extremely helpful to me, the more examples of production AutoIt code I see, the quicker I can learn :)
    2 points
  2. Update: With the help of @noellarkin I could extend the collection list (post #1) by 12 more users that are forum members and also share their AutoIt related GitHub projects/repositories with the world 😅 . Thanks again Noellarkin 👍 and don't be confused, I didn't add all of your suggestions/findings. Because of various reasons (not maintained anymore, only private repos, too old and so one). Best regards Sven
    2 points
  3. NOOOOOO. Now everyone can see my publicly available badly coded AutoIt
    2 points
  4. This UDF provides 2 functions to read data directly from xlsx files or to output data as xlsx file. Only the cell contents are considered - no cell formatting and the like. It is therefore explicitly not a full replacement for the Excel UDF, since its scope goes well beyond that. But to quickly read in data or to work with xlsx files without having Excel installed, the UDF can be quite useful. There may also be specially formatted xlsx files which I have not yet encountered during testing and which may cause problems. In this case it is best to make a message about it here and upload the file. Note: xlsx files must be unpacked for reading. To make this as fast as possible it is recommended to put a >>7za.exe<< file into the script directory, otherwise a slow alternative will be used. Otherwise an example says more than 1000 words: >>sourcecode and download on github<< Changelog:
    1 point
  5. This UDF contains functions to make the handling of arrays more effective and elegant. Besides functions which are inspired by Python's range-create and its array-slicing, most of the functions are based on the principle of being able to specify user-defined functions for subtasks. E.g. with the classic _ArraySort() it is not possible to sort "naturally" or to sort 2D arrays by multiple columns or instead by string length or or or... With these functions here you can usually realize this in only one function call. Also the possibility to display arrays nicely formatted as string (quasi the counterpart to _ArrayDisplay) was missing until now. The function list of the UDF: Therefore, here are a few code examples for selected functions: _ArrayCreate(): _ArraySlice(): _Array2String(): _ArraySortFlexible(): _ArrayBinarySearchFlex(): _ArrayGetNthBiggestElement(): >>sourcecode and download on github<<
    1 point
  6. ioa747, I suggest that the "User Call Tip Manager" is the tool that ozymandius257 is looking for - this gives you the list of parameters after typing in the function name. You access it from the same tab in SciteConfig. M23
    1 point
  7. You can submit the compiled file to Microsoft Security Intelligence (https://www.microsoft.com/en-us/wdsi/filesubmission/) for malware analysis. They will remove the file from detection by way of releasing a Windows Defender update. According to my experience, they usually do it in less than 12 hours.
    1 point
  8. Especially you @rcmaehl, don't have to worry about it! So many people already know your code and what you did in the past with AutoIt => this is pure unbelievable Robert 👍 . You have my highest respect 😊 . Best regards Sven
    1 point
  9. ioa747

    JSON UDF in pure AutoIt

    Congratulations !! file size JSMN Pure AutoIt ;~ ------------------------------------------------------------------------ ;~ sample4.json 451 bytes 2.64 ms 0.77 ms ;~ test.json 1,46 KB 3.93 ms 2.48 ms ;~ USD.json 2,12 KB 10.68 ms 6.42 ms ;~ 110-pcp-ytd-12-1895-2016.json 5,43 KB 54.20 ms 13.42 ms ;~ earth_meteorites.json 240 KB 1339.18 ms 546.57 ms ;~ Test2.json 2,04 MB 4180.48 ms 2172.16 ms
    1 point
  10. changing to: Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idBtnExit _GUICtrlRichEdit_SetSel($hRichEdit, 0, -1, True) ;this line avoid's the problem _GUICtrlRichEdit_StreamToFile($hRichEdit, @ScriptDir & "\signature.rtf") _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes GUIDelete() Exit EndSwitch
    1 point
  11. Sure... Please go somewhere else moaning instead of necro posting in old threads. .. and think before you reply or post again in our forums as the next post like this gets your ass banned.
    1 point
  12. Hi @ihatejavascript97, out of my perspective nobody should answer you until you come up with a little bit more respect for the language and the people behind. So please calm down. Besides that, as you already mentioned, there is at least one way (by GDI+), to handle this. Best regards Sven Update: I am also referring to this post of you and your "lovely" statement "autoit su--s" 😒 .
    1 point
  13. Did you try the example posted here?
    1 point
  14. I use the following code to grab the output of a PS script: $sCMD = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -file " & @ScriptDir & "\NM.ps1" $pid = Run($sCMD, @SystemDir, @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD + $STDERR_CHILD) StdinWrite($pid, @CRLF) ; Close STDIN StdinWrite($pid) ; Get output from STDOUT $sSTDOUT = "" While 1 $sOutput = StdoutRead($pid) If @error Then ExitLoop If $sOutput <> "" Then $sSTDOUT = $sSTDOUT & @CRLF & $sOutput ; Drops empty lines WEnd ; Get output from STDERR $sSTDERR = "" While 1 $sOutput = StderrRead($pid) If @error Then ExitLoop If $sOutput <> "" Then $sSTDERR = $sSTDERR & @CRLF & $sOutput ; Drops empty lines WEnd
    1 point
  15. You owe me a beer for this #include <Constants.au3> #include <Process.au3> #include <WinAPISysWin.au3> #include <WinAPIProc.au3> #include <Array.au3> Opt("MustDeclareVars", 1) Local $aPrograms[0][4] Local $aWinList = WinList() Local $iPID, $sName For $i = 1 To $aWinList[0][0] If $aWinList[$i][0] <> "" And BitAND(WinGetState($aWinList[$i][1]), 2) Then $iPID = WinGetProcess($aWinList[$i][1]) $sName = _ProcessGetName($iPID) If $sName = "ApplicationFrameHost.exe" Then $iPID = FindTrueApp($aWinList[$i][0], $iPID, $sName) If Not $iPID Then ContinueLoop EndIf _ArrayAdd($aPrograms, $aWinList[$i][0] & "|" & $aWinList[$i][1] & "|" & $iPID & "|" & $sName) EndIf Next _ArrayDisplay($aPrograms) Func FindTrueApp($sTitle, $iPID, ByRef $sProcess) Local Static $aList = _WinAPI_EnumWindows(True) Local $iTruePID For $i = 1 To $aList[0][0] If WinGetTitle($aList[$i][0]) = $sTitle Then $iTruePID = WinGetProcess($aList[$i][0]) If $iPID <> $iTruePID Then $sProcess = _WinAPI_GetProcessName($iTruePID) Return $iTruePID EndIf EndIf Next Return 0 EndFunc ;==>FindTrueApp Working nicely for me...
    1 point
  16. Hey all just wanted to share some code if you're struggling to send keys to your web session. Here is how I was able to send an "ENTER" keystroke to my web session: _WD_Action($sSession, 'actions', '{"actions": [{"type": "key", "id": "keyboard", "actions": [{"type": "keyDown", "value": "\uE007"}, {"type": "keyUp", "value": "\uE007"}]}]}') Spent many hours trying to figure the sequence out. Hopefully this can help someone. @giahh - Saw you trying to do this back in 2018 Referenced: https://github.com/jlipps/simple-wd-spec#perform-actions
    1 point
  17. I am pretty sure that a wide range of user-defined functions already exists for exactly this use case. Like many others, i have written a function that lists files/folders recursively with the possibility to filter by RegEx. But it has a few extras: On the one hand you can directly pass multiple search locations. On the other hand you can do much more complex filtering, because you can pass your own matching function: ; #FUNCTION# ====================================================================================== ; Name ..........: _listFilesFlexible() ; Description ...: Finds files and/or folders in a directory tree with multiple filtering options ; Syntax ........: _listFilesFlexible($sSD, [Const $sPat = '', [Const $iF = 3, [Const $1BASED = 0]]]) ; Parameters ....: $sSD - search location[s] (you can separate multiple with "|") ; Const $sPat - [optional] regular expression for filename matching or a function pointer for more complex matching ; remark: RegEx is normally case-sensitive - add (?i) at pattern start to switch to case-insensitive ; "" (Default): No filename matching - all elements will be retrieved ; Const $iF - [optional] 1=only files, 2=only folders, 3=files and folders (default:3) ; Const $1BASED - [optional] 0= zero-based - no count in $Array[0] (Default), 1= 1-based - count in $Array[0] ; Return values .: Success - Return Array with Matches ; Failure - Return "" and set @error ; Author ........: AspirinJunkie ; ================================================================================================= Func _listFilesFlexible($sSD, Const $sPat = '', Const $iF = 3, Const $1BASED = 0) Local $cEl = $1BASED, $cAS = 1 ; counter for number of elements vs. current array size Local $aRet[1] = [0] Local $aSD = StringSplit($sSD, '|', 1) ; stack for search folders Local $FFFF, $FFNF, $sDir, $sP Local $hDLL = DllOpen('kernel32.dll') Local $p_F = DllCall($hDLL, "ptr", "GetProcAddress", "handle", DllCall($hDLL, "handle", "GetModuleHandleW", "wstr", "kernel32.dll")[0], "str", "GetFileAttributesW")[0] ; get the function address of GetModuleHandleW If Not ($iF = 3 Or $iF = 1 Or $iF = 2) Then Return SetError(3, 0, "") If $sPat = "" Then Do ; pull next dir from stack $sDir = $aSD[$aSD[0]] & "\" $aSD[0] -= 1 $FFFF = FileFindFirstFile($sDir & '*') If $FFFF <> -1 Then Do $FFNF = FileFindNextFile($FFFF) If @error Then ExitLoop $sP = $sDir & $FFNF If @extended Then ; folder If BitAND($iF, 2) Then ; matched dir If $cEl >= $cAS Then $cAS += $cAS ReDim $aRet[$cAS] EndIf $aRet[$cEl] = $sP $cEl += 1 EndIf ; ignore reparse points If BitAND(DllCallAddress('dword', $p_F, 'wstr', $sP)[0], 0x400) Then ContinueLoop ; push subfolder to folder stack $aSD[0] += 1 If $aSD[0] = UBound($aSD) Then ReDim $aSD[UBound($aSD) * 2] $aSD[$aSD[0]] = $sP ElseIf BitAND($iF, 1) Then ; matched file If $cEl >= $cAS Then $cAS += $cAS ReDim $aRet[$cAS] EndIf $aRet[$cEl] = $sP $cEl += 1 EndIf Until 0 FileClose($FFFF) EndIf Until $aSD[0] = 0 ElseIf IsFunc($sPat) Then ; $sPat = function Do ; pull next dir from stack $sDir = $aSD[$aSD[0]] & "\" $aSD[0] -= 1 $FFFF = FileFindFirstFile($sDir & '*') If $FFFF <> -1 Then Do $FFNF = FileFindNextFile($FFFF) If @error Then ExitLoop $sP = $sDir & $FFNF If @extended Then ; folder If BitAND($iF, 2) And $sPat($sP) Then ; match by function If $cEl >= $cAS Then $cAS += $cAS ReDim $aRet[$cAS] EndIf $aRet[$cEl] = $sP $cEl += 1 EndIf ; ignore reparse points If BitAND(DllCallAddress('dword', $p_F, 'wstr', $sP)[0], 0x400) Then ContinueLoop ; push subfolder to folder stack $aSD[0] += 1 If $aSD[0] = UBound($aSD) Then ReDim $aSD[UBound($aSD) * 2] $aSD[$aSD[0]] = $sP ; file ElseIf BitAND($iF, 1) And $sPat($sP) Then ; match by function If $cEl >= $cAS Then $cAS += $cAS ReDim $aRet[$cAS] EndIf $aRet[$cEl] = $sP $cEl += 1 EndIf Until 0 FileClose($FFFF) EndIf Until $aSD[0] = 0 Else ; $sPat = regex Do ; pull next dir from stack $sDir = $aSD[$aSD[0]] & "\" $aSD[0] -= 1 $FFFF = FileFindFirstFile($sDir & '*') If $FFFF <> -1 Then Do $FFNF = FileFindNextFile($FFFF) If @error Then ExitLoop $sP = $sDir & $FFNF If @extended Then ; folder If BitAND($iF, 2) And StringRegExp($FFNF, $sPat) Then ; match by regex If $cEl >= $cAS Then $cAS += $cAS ReDim $aRet[$cAS] EndIf $aRet[$cEl] = $sP $cEl += 1 EndIf ; ignore reparse points If BitAND(DllCallAddress('dword', $p_F, 'wstr', $sP)[0], 0x400) Then ContinueLoop ; push subfolder to folder stack $aSD[0] += 1 If $aSD[0] = UBound($aSD) Then ReDim $aSD[UBound($aSD) * 2] $aSD[$aSD[0]] = $sP ElseIf BitAND($iF, 1) And StringRegExp($FFNF, $sPat) Then ; match by regex If $cEl >= $cAS Then $cAS += $cAS ReDim $aRet[$cAS] EndIf $aRet[$cEl] = $sP $cEl += 1 EndIf Until 0 FileClose($FFFF) EndIf Until $aSD[0] = 0 EndIf DllClose($hDLL) If $1BASED = 1 Then $aRet[0] = $cEl - 1 ReDim $aRet[$cEl] Return $aRet EndFunc ;==>_listFilesFlexible Example for simple RegEx usage: #include <Array.au3> ; all dll-files in system dir $aFiles = _listFilesFlexible(@SystemDir, "(?i)\.dll$", 1) _ArrayDisplay($aFiles) More complex example (multiple search folders with search by file size): #include <Array.au3> ; all dll files in system dir AND user profile dir which are greater than 5 mb $aFiles = _listFilesFlexible(@SystemDir & "|" & @UserProfileDir, _myCheck, 1) _ArrayDisplay($aFiles) Func _myCheck(Const $sPath) If StringRight($sPath, 4) <> ".dll" Then Return 0 If FileGetSize($sPath) > 5242880 Then Return 1 Return 0 EndFunc
    1 point
  18. This script: ;https://autoit.de/index.php?thread/86082-treeview-root-verbergen/&postID=691139#post691139 #include <File.au3> #include <WindowsConstants.au3> Global $sPath = @ScriptDir Global $hGui = GUICreate('TreeView-Example', 400, 600) Global $idTreeView = GUICtrlCreateTreeView(10, 10, 380, 580, Default, $WS_EX_CLIENTEDGE) GUISetState() _CreatePath($sPath, $idTreeView) Do Until GUIGetMsg() = -3 Func _CreatePath($sPath, $idParent) Local $aFolder, $aFiles, $idItem If StringRight($sPath, 1) <> '\' Then $sPath &= '\' $aFolder = _FileListToArray($sPath, '*', $FLTA_FOLDERS) If Not @error Then For $i = 1 To $aFolder[0] $idItem = GUICtrlCreateTreeViewItem($aFolder[$i], $idParent) _CreatePath($sPath & $aFolder[$i], $idItem) Next EndIf $aFiles = _FileListToArray($sPath, '*', $FLTA_FILES) If @error Then Return For $i = 1 To $aFiles[0] $idItem = GUICtrlCreateTreeViewItem($aFiles[$i], $idParent) Next EndFunc does same as yours with native GUICtrlCreateTreeViewItem and _FileListToArray.
    1 point
  19. On windows vista and above (which I think with the deprecation of windows XP it's now reasonable to assume unless you are still writing for a business), there is a TVN_ITEMCHANGED message. The constants and structure required for this are not currently in the standard AutoIt libraries. I'll commit them when I get svn sorted out again, so the code below will break (re-declaration of constants) in the next beta. #include <GUIConstantsEx.au3> #include <GuiTreeView.au3> #include <WindowsConstants.au3> Global $hTreeView Global Const $TVN_ITEMCHANGINGA = $TVN_FIRST - 16 Global Const $TVN_ITEMCHANGINGW = $TVN_FIRST - 17 Global Const $TVN_ITEMCHANGEDA = $TVN_FIRST - 18 Global Const $TVN_ITEMCHANGEDW = $TVN_FIRST - 19 Global Const $tagNMTVITEMCHANGE = $tagNMHDR & ";UINT uChanged; HANDLE hItem; UINT uStateNew; UINT uStateOld; LPARAM lParam;" Example() Func Example() Local $GUI, $hItem Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES) $GUI = GUICreate("(UDF Created) TreeView Create", 400, 300) $hTreeView = _GUICtrlTreeView_Create($GUI, 2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") _GUICtrlTreeView_BeginUpdate($hTreeView) For $x = 1 To 10 $hItem = _GUICtrlTreeView_Add($hTreeView, 0, StringFormat("[%02d] New Item", $x)) For $y = 1 To Random(2, 10, 1) _GUICtrlTreeView_AddChild($hTreeView, $hItem, StringFormat("[%02d] New Child", $y)) Next Next _GUICtrlTreeView_EndUpdate($hTreeView) ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndTreeview $hWndTreeview = $hTreeView If Not IsHWnd($hTreeView) Then $hWndTreeview = GUICtrlGetHandle($hTreeView) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndTreeview Switch $iCode Case $TVN_ITEMCHANGEDW, $TVN_ITEMCHANGEDA $tNMTVIC = DllStructCreate($tagNMTVITEMCHANGE, $ilParam) ConsoleWrite(StringFormat("Item %i Changed, checked=%i\n", DllStructGetData($tNMTVIC, "hItem"), _GUICtrlTreeView_GetChecked($hWndFrom, DllStructGetData($tNMTVIC, "hItem")))) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Mat
    1 point
  20. Because it is not exactly 0.5. It is only rounded on output, so you don't see this. Consolewrite basically makes an implicit string() around the number variable to be output. And this has the effect of rounding if the difference occurs after the 14th decimal place. Modify your output line as follows to avoid this implicit rounding: ConsoleWrite(StringFormat("Output will be: %d %d --> %.17f\n", $x, $y, $result))
    0 points
×
×
  • Create New...