Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/29/2015 in all areas

  1. You can use _WinAPI_GetParentProcessto get the parent PID. If you got the parent PID then call the function again until the return value is 0. You can easily create a recursive function to do this. Something like this here: #include <Array.au3> #include <WinAPIProc.au3> Global $iPID = @AutoItPID $aResults = _WinAPI_GetParentProcessRec($iPID) _ArrayDisplay($aResults, "Parent and higher PIDs of " & $iPID, "", 0, Default, "PID|Process Name") $aResults = _WinAPI_GetParentProcessIter($iPID) _ArrayDisplay($aResults, "Parent and higher PIDs of " & $iPID, "", 0, Default, "PID|Process Name") Func _WinAPI_GetParentProcessRec($iPID, $bRec = True) ;coded by UEZ build 2015-04-29 Local Static $aPIDs[20][2], $i = 1 Local $iParent_PID = _WinAPI_GetParentProcess($iPID) If $iParent_PID > 0 Then $aPIDs[$i][0] = $iParent_PID $aPIDs[$i][1] = _WinAPI_GetProcessName($iParent_PID) $i += 1 If $bRec Then _WinAPI_GetParentProcessRec($iParent_PID) EndIf If $i = 1 Then Return SetError(1, 0, 0) ReDim $aPIDs[$i - 1 * $bRec][2] $aPIDs[0][0] = $iPID $aPIDs[0][1] = _WinAPI_GetProcessName($iPID) Return $aPIDs EndFunc Func _WinAPI_GetParentProcessIter($iPID = 0, $bAll = True) ;coded by UEZ build 2015-04-30 Local Static $aPIDs[20][2], $i = 1 $aPIDs[0][0] = $iPID $aPIDs[0][1] = _WinAPI_GetProcessName($iPID) Local $iParent_PID = 1 While $iParent_PID > 0 $iParent_PID = _WinAPI_GetParentProcess($iPID) If @error Then ExitLoop $iPID = $iParent_PID $aPIDs[$i][0] = $iParent_PID $aPIDs[$i][1] = _WinAPI_GetProcessName($iParent_PID) $i += 1 If Not $bAll Then ExitLoop WEnd If $i = 1 Then Return SetError(1, 0, 0) ReDim $aPIDs[$i - 2 * $bAll][2] Return $aPIDs EndFunc $aResults[0][0] is the child pid. $aResults[1][0] is its parent, $aResults[2][0] is the grandparent and so on.
    2 points
  2. PM it to Melba23.
    2 points
  3. There are three ways you can posts scripts, these are: Inline code Attachments Download system Each has different advantages and disadvantages. In general you should use: Inline code - for short code snippets Attachments - for more complicated code larger than a page. Downloads system - for projects or complex libraries Inline Code Best for entering short snippets of code Easiest for other users to see May be accidentally modified by forum upgrades or when re-editing your post - it's happened before... Inline code is entered using the "Add Code" button in the toolbar and after posting appears with syntax highlighting like this: ; This is some AutoIt code MsgBox(4096, "Message", "Hello there!") Code over around 50 lines will appear in a scrollable box. At this point it becomes more difficult for other users to work with and you should consider an attachment instead. Attachments Best for long pieces of code, entire programs, or multiple files Unlikely to be accidentally lost or modified by forum upgrades or when re-editing your post Counts against your global attachment allocation Can be seen in the "username / My Attachments" part of your profile, along with the number of downloads Multiple attachments can be added to a post. As attachments are stored as complete files in the filesystem, they are more robust than inline code snippets. Downloads System Best for very long and complicated projects or libraries that are of significant use to the community Uses a different part of the forum that is optimised for file downloads and features screenshots, change logs, download counts, etc. Does not count against your global attachment allocation This can be accessed here: Downloads System.
    1 point
  4. So I think it's time to publish this little tutorial I have made on using DllCall() and DllStructs. It's not near completion but I think it's a good start at least This tutorial is mostly aimed for people who have never used DllCall() before or have very limited knowledge about it. In the future I will update it with more advanced topics so more advanced users can make use of it too. Well here goes. Dealing_with_Dll.pdf Previous downloads: 31 Suggestions, language corrections and errors in the tutorial is of course welcome.
    1 point
  5. http://techcrunch.com/2015/04/29/microsoft-shocks-the-world-with-visual-studio-code-a-free-code-editor-for-os-x-linux-and-windows/#.yabcl7:Pdlo This is really interesting, I love the direction Microsoft are moving in. When the switch is flipped you shouldn't be able to download from http://code.visualstudio.com
    1 point
  6. willichan

    Code39.zip

    Version 1.0.0

    903 downloads

    Creates a Code39 or Code39Extended (with or without check-character) barcode from supplied data
    1 point
  7. willichan

    Code128Auto.zip

    Version 1.0.1

    1,427 downloads

    Creates a Code128A/B/C optimized barcode from supplied data
    1 point
  8. water

    Copy Protect

    There is no 100% foolproof way to protect your script but search the Example Scripts forum for XProtec.
    1 point
  9. trancexx

    WinHTTP functions

    To get extensions info you should query for $WINHTTP_OPTION_SERVER_CERT_CONTEXT and then use Certificate functions to read data. Something like this (no error checking here): #include "WinHttp.au3" $hOpen = _WinHttpOpen() $hConnect = _WinHttpConnect($hOpen, "https://www.facebook.com") $hRequest = _WinHttpSimpleSendSSLRequest($hConnect) ; Query for CERT_CONTEXT pointer $tBuffer = DllStructCreate("ptr") DllCall($hWINHTTPDLL__WINHTTP, "bool", "WinHttpQueryOption", _ "handle", $hRequest, _ "dword", $WINHTTP_OPTION_SERVER_CERT_CONTEXT, _ "struct*", $tBuffer, _ "dword*", DllStructGetSize($tBuffer)) ConsoleWrite("> CERT_CONTEXT pointer: " & DllStructGetData($tBuffer, 1) & @CRLF) ; Close handles _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) $pContext = DllStructGetData($tBuffer, 1) Const $CERT_NAME_DNS_TYPE = 6 Const $CERT_NAME_SEARCH_ALL_NAMES_FLAG = 0x2 ; Read size of the needed buffer $aCall = DllCall("Crypt32.dll", "dword", "CertGetNameString", _ "ptr", $pContext, _ "dword", $CERT_NAME_DNS_TYPE, _ "dword", $CERT_NAME_SEARCH_ALL_NAMES_FLAG, _ "dword*", 0, _ "struct*", 0, _ "dword", 0) $iSize = $aCall[0] ; Create buffer $tStruct = DllStructCreate("byte[" & $iSize & "]") ; Read DNS names $aCall = DllCall("Crypt32.dll", "dword", "CertGetNameString", _ "ptr", $pContext, _ "dword", $CERT_NAME_DNS_TYPE, _ "dword", $CERT_NAME_SEARCH_ALL_NAMES_FLAG, _ "dword*", 0, _ "struct*", $tStruct, _ "dword", $iSize) ; Free CERT_CONTEXT DllCall("Crypt32.dll", "dword", "CertFreeCertificateContext", "ptr", $pContext) ; Split on NULL character and convert to array $aArr = StringSplit(BinaryToString(DllStructGetData($tStruct, 1)), Chr(0), 2) ConsoleWrite("Subject Alternative Name - DNS Name=" & @CRLF) For $i = 0 To UBound($aArr) - 1 ConsoleWrite(@TAB & $aArr[$i] & @CRLF) Next ...Sorry for not replying earlier.
    1 point
  10. kylomas

    Size Comparison

    Siryx, Not sure where you got the $aFiles =from it was not in the code I posted. As far as consolewrite's are concerned. Are you running this code from SciTE? Regarding 2D arrays, look at them like spread sheets. In this case the file name would be in the "A" column and the size would be in the "B" column. AutoIt offsets arrays from 0 so a reference to $aFiles[4][1] will give you the size of the fifth file. In the posted code the loop increment variable ($1) is used to point at the row, the columns are referenced explicitly. The Wiki has several informative tutorials concerning arrays and other AutoIt subjects. kylomas
    1 point
  11. something like this??? ; using a 2D array #include <Array.au3> #include <MsgBoxConstants.au3> Local $avArray[6][2] = [ _ ["String0", "SubString0"], _ ["String1", "SubString1"], _ ["String2", "SubString2"], _ ["String3", "SubString3"], _ ["String4", "SubString4"], _ ["String5", "SubString5"]] ;Deleted _ArrayDisplay($avArray, "$avArray") Local $sSearch = InputBox("_ArraySearch() demo", "String to find?") If @error Then Exit Local $iIndex = _ArraySearch($avArray, $sSearch, 0, 0, 0, 1, 1) If @error Then MsgBox($MB_SYSTEMMODAL, "Not Found", '"' & $sSearch & '" was not found on column ' & '.') Else MsgBox($MB_SYSTEMMODAL, "Found", '"' & $sSearch & '" was found in the array at position ' & $iIndex & ' on column ' & '.') EndIf
    1 point
  12. jguinch

    Size Comparison

    Nothing happens because kylomas and I used ConsoleWrite to show the FileDelete step. You have to add the FileDelete line to your code, in place of ConsoleWrite : FileDelete($aFiles[$1][0]) ; for kylomas's code FileDelete($sPath & "\" & $sFile) ; for my code
    1 point
  13. Maybe something like this? ; using a 2D array #include <Array.au3> #include <MsgBoxConstants.au3> Local $avArray[6][2] = [ _ ["String0", "SubString0"], _ ["String1", "SubString1"], _ ["String2", "SubString2"], _ ["String3", "SubString3"], _ ["String4", "SubString4"], _ ["String5", "SubString5"]] _ArrayDisplay($avArray, "$avArray") Local $sSearch = InputBox("_ArraySearch() demo", "String to find?") If @error Then Exit Local $FoundValue = _ArraySearch($avArray, $sSearch) MsgBox('','', $avArray[$FoundValue][1]) Exit
    1 point
  14. You can do that in AutoIt - yes. Please show your attempt and then we will look at trying to fix any issues you might be having.
    1 point
  15. mLipok

    Tidy.exe

    Just use it in SciTE4Au3 and you will be able to read in console something like this: >"C:\Program Files (x86)\AutoIt3\SciTE\tidy\tidy.exe" "Z:\TOOLs\Macro\FORUM\___FORUM -- na forum\QuickPDF\_Viewer\DPViewer_Example.au3"
    1 point
  16. Does that work like you want (on a limited sample)? #cs I would delete columns 15,13,12,11,9,8, and 7 from the array (marked * below) 1 4/26/15 6:40:07 AM 2 ZZ123123 3 10.0.0.1 4 U-def R:rulename 5 deny create 6 C:\Users\username\AppData\Roaming\value.exe * 7 * 8 _ * 9 10.0.0.1 10 C:\Users\username\AppData\Local\Temp\A6F5.tmp * 11 'File' access * 12 Notice * 13 SOL 14 My Site\Workstation\SITENAME Workstation\ * 15 109" #ce $s = "4/26/15 6:40:07 AM,ZZ123123,10.0.0.1,U-def R:rulename,deny create,C:\Users\username\AppData\Roaming\value.exe,,_,10.0.0.1,C:\Users\username\AppData\Local\Temp\A6F5.tmp,'File' access,Notice,SOL,My Site\Workstation\SITENAME Workstation\,109" $s = StringRegExpReplace($s, '(?U)^(.*,)(.*,)(.*,)(.*,)(.*,)(.*,)(?:.*,){3}(.*,)(?:.*,){3}(.*),.*$', '$1$2$3$4$5$6$7$8') $a = StringSplit($s, ',', 2) _ArrayDisplay($a)
    1 point
  17. kylomas

    Size Comparison

    Siryx, jguinch's example modified slightly. See comments in code... #include <array.au3> Local $sPath = "k:\temp" ; path name local $aFiles[10000][2] ; array to hold files col 0 = filename, col 1 = size local $idx = 0 ; index to offset array while processing files Local $hSearch = FileFindFirstFile($sPath & "\*.*") If $hSearch = -1 Then Exit ; find all files in path and populate array with fully qualified name and size While 1 $aFiles[$idx][0] = $sPath & '\' & FileFindNextFile($hSearch) If @error Then ExitLoop If @extended Then ContinueLoop $aFiles[$idx][1] = FileGetSize($aFiles[$idx][0]) $idx += 1 WEnd FileClose($hSearch) ; close search handle redim $aFiles[$idx][2] ; trim array to size actually used (count is in $idx) ; sort by size ascending _arraysort($aFiles,0,0,0,1) _arraydisplay($aFiles) ; iterate array deleting duplicately sized files for $1 = 1 to ubound($aFiles) - 1 if $aFiles[$1][1] = $aFiles[$1-1][1] then ConsoleWrite('delete file = ' & $aFiles[$1][0] & ' size = ' & $aFiles[$1][1] & @CRLF) EndIf next kylomas
    1 point
  18. StringRegExp returns an array and your code needs a string then you also could use StringRegExpReplace $text = 'C:\xxx\hh\hhhh\hhh\image.JPG' $out = StringRegExpReplace($text, '.*\\(.*)\\.*', "$1") msgbox(0,"", $out)
    1 point
  19. Local $aArray = _FileListToArrayRec("C:\test\app", "*app.exe", $FLTAR_FILES, 1, $FLTAR_SORT,$FLTAR_FULLPATH) $fileArray = UBound($aArray) -1 For $y = 1 To $fileArray _GUICtrlListView_AddItem($ListView, StringRegExp($aArray[$y],'.*\\(.*)\\',1)[0], 0) Next Should work with recent version (untested).
    1 point
  20. Hi all! After long time of silence in this topic I'm put my customized version of original Herons DBUG. Added: - sorting in variables list by any column and drag in any order. - by default 1D and 2D arrays showing in list (1D as [1 2 3 4 5 ... N] 2D as ["row1:column1 value" "row1:column2 value" "row1:column3 value" ... "row1:columnN value"]...[rowN:columnN value ], 3D and more dimensional arrays not showing - extended information toggle button [..] (useful for variables with type arrays, dllstruct or object) Changed: - DBUG window now has a minimal size, you cannot change it vertical and horizontal size to zero. - previously when you edit variable name or insert new one in edit mode when you click with mouse out of edit field name changed on name where you click (sorry for my english), use Enter (or Esc) for complete editing and Ctrl+Z for Undo. Use arrows button for scrolling left or right in edit mode. - clear and execute command buttons now docking around of appropriate edit field - command result window is now disable for input All modifications has a ; valdemar1977 comment at the end of line. How to use DBUG - put Dbug.au3 to Autoit include directory or user include directory (setup user include in SciTe settings - "Tools"->"SciTe Config"->"General 1"->"User Include Folder") - put IMAGES folder in Autoit home (location of AutoIt3.exe file) - add #include <Dbug.au3> in your code (or #include "FULL_PATH_TO_FILE\Dbug.au3" if you put it anywhere) - use ;STOP DBUG for excluding some part of you code from debugging, ;START DBUG will resume debug. Thank you Heron again! Dbug.zip
    1 point
  21. here is my code: ;myFileListToArray: ;~ example: ;~ $sPath = "D:\AutoIt\article\autoitv3.0" ;~ $aFile = myFileListToArray($sPath, "\.au3$", 1, "zt_,_private,BackUp,images") ;~ If IsArray($aFile) Then ;~ For $i = 1 To $aFile[0] Step 1 ;~ ConsoleWrite($i & "=" & $aFile[$i] & @CRLF) ;~ Next ;~ EndIf ;=============================================================================== ; ; Description: lists files or directory(subdirectory) in a specified path (Similar to using Dir with the /b /s Switch) ; 列出目录下所有文件或文件夹,包括子文件夹.(yidabu.com注:autoit官方版本_FileListToArray不包括搜索子文件夹,也不支持正则表达式) ; Syntax: myFileListToArray($sPath,$rPath=0, $iFlag = 0,$sPathExclude=0) ; Parameter(s): $sPath = Path to generate filelist for 要搜索的路径 ; $iFlag = determines weather to return file or folders or both ; $rPath = The regular expression to compare. StringRegExp Function Reference For details ; 用于搜索的正则表达式,用法同StringRegExp函数 ; $iFlag=0(Default) Return both files and folders 返回所有文件和文件夹 ; $iFlag=1 Return files Only 仅返回文件 ; $iFlag=2 Return Folders Only 仅返回文件夹 ; $sPathExclude = when word in path, the file/folder will exclude,mulite words separate by comma(,) ; 在路径中要要排除的词语,多个有,分隔 ; ; Requirement(s): autoit v3.2.2.0 ; Return Value(s): On Success - Returns an array containing the list of files and folders in the specified path ; On Failure - Returns the an empty string "" if no files are found and sets @Error on errors ; @Error=1 Path not found or invalid ; @Error=3 Invalid $iFlag ; @Error=4 No File(s) Found ; ; Author(s): by http://www.yidabu.com 一大步成功社区 http://bbs.yidabu.com/forum-2-1.html ; update: 20070125 ; Note(s): The array returned is one-dimensional and is made up as follows: ; $array[0] = Number of Files\Folders returned 返回文件/文件夹的数量 ; $array[1] = 1st File\Folder (not include $sPath) 第一个文件/文件夹 ; $array[2] = 2nd File\Folder (not include $sPath) ; $array[3] = 3rd File\Folder (not include $sPath) ; $array[n] = nth File\Folder (not include $sPath) ; Special Thanks to SolidSnake <MetalGX91 at GMail dot com> (his _FileListToArray) ;=============================================================================== Func myFileListToArray($sPath, $rPath = 0, $iFlag = 0, $sPathExclude = 0) Local $asFileList[1] ;yidabu.com提示因为要用递归调用$asFileList参数要单独出来 $asFileList = myFileListToArrayTemp($asFileList, $sPath, $rPath, $iFlag, $sPathExclude) Return $asFileList EndFunc ;==>myFileListToArray Func myFileListToArrayTemp(ByRef $asFileList, $sPath, $rPath = 0, $iFlag = 0, $sPathExclude = 0) Local $hSearch, $sFile If Not FileExists($sPath) Then Return SetError(1, 1, "") If Not ($iFlag = 0 Or $iFlag = 1 Or $iFlag = 2) Then Return SetError(3, 3, "") $hSearch = FileFindFirstFile($sPath & "\*") If $hSearch = -1 Then Return SetError(4, 4, "") While 1 $sFile = FileFindNextFile($hSearch) If @error Then SetError(0) ExitLoop EndIf ;yidabu.com提示已经被排除的路径就不要搜索子目录了 If $sPathExclude And StringLen($sPathExclude) > 0 Then $sPathExclude = StringSplit($sPathExclude, ",") $bExclude = False If IsArray($sPathExclude) Then For $ii = 1 To $sPathExclude[0] Step 1 If StringInStr($sPath & "\" & $sFile, $sPathExclude[$ii]) Then $bExclude = True ExitLoop EndIf Next EndIf If $bExclude Then ContinueLoop Select Case StringInStr(FileGetAttrib($sPath & "\" & $sFile), "D") ;如果遇到目录 Select Case $iFlag = 1 ;求文件时就递归 myFileListToArrayTemp($asFileList, $sPath & "\" & $sFile, $rPath, $iFlag, $sPathExclude) ContinueLoop ;求文件时跳过目录 Case $iFlag = 2 Or $iFlag = 0 ;求目录时分两种情况 If $rPath Then ;1如果要求对路径进行正则匹配 If Not StringRegExp($sPath & "\" & $sFile, $rPath, 0) Then ;正则匹配失败就递归 myFileListToArrayTemp($asFileList, $sPath & "\" & $sFile, $rPath, $iFlag, $sPathExclude) ContinueLoop ;正则匹配失败时跳过本目录 Else ;正则匹配成功就递归并把本目录加入匹配成功 myFileListToArrayTemp($asFileList, $sPath & "\" & $sFile, $rPath, $iFlag, $sPathExclude) EndIf Else ;2如果不要求对路径进行正则匹配递归并把本目录加入匹配成功 myFileListToArrayTemp($asFileList, $sPath & "\" & $sFile, $rPath, $iFlag, $sPathExclude) EndIf EndSelect Case Not StringInStr(FileGetAttrib($sPath & "\" & $sFile), "D") ;如果遇到文件 If $iFlag = 2 Then ContinueLoop ;求目录时就跳过 ;yidabu.com提示要求正则匹配路径且匹配失败时就跳过。遇文件就不要递归调用了。 If $rPath And Not StringRegExp($sPath & "\" & $sFile, $rPath, 0) Then ContinueLoop EndSelect ReDim $asFileList[UBound($asFileList) + 1] $asFileList[0] = $asFileList[0] + 1 $asFileList[UBound($asFileList) - 1] = $sPath & "\" & $sFile WEnd FileClose($hSearch) Return $asFileList EndFunc ;==>myFileListToArrayTemp ;myFileListToArray. oÝ÷ ØLZ^ëmâçë¢`´÷f®¶­sbb33c¶F"Ò×fÆTÆ7EFô'&gV÷C¶3¢gV÷C²ÂgV÷C²b3#²çF×b33c²gV÷C²ÂÂgV÷C²gV÷C²¤f÷"b33c¶ÒFòb33c¶F%³Ò7FW 6öç6öÆUw&FRb33c¶F%²b33c¶ÒfײÄb¤æW@ the result:
    1 point
  22. Yoriz

    GUICtrlCreateCombo

    Here is an example #include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 249, 115, 211, 125) $Combo_Screensize = GUICtrlCreateCombo("", 16, 24, 145, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL)) GUICtrlSetData(-1, "640×480|800×600|1024×768|1152×864|1280×768|1280×960|1280×1024|1600×1200") $hLabelX = GUICtrlCreateLabel("X = ", 16, 56, 150, 17) $hLabelY = GUICtrlCreateLabel("Y = ", 16, 80, 150, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Combo_Screensize $sReadCombo = GUICtrlRead($Combo_Screensize) $aSplit = StringSplit($sReadCombo,"×") $iX = $aSplit[1] $iY = $aSplit[2] GUICtrlSetData($hLabelX, "X = " & $iX) GUICtrlSetData($hLabelY, "Y = " & $iY) EndSwitch WEnd
    1 point
×
×
  • Create New...