Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/19/2022 in all areas

  1. I've wanted to post this for a while. It's a great script to help debug control data....perfect scenario, when you have a 'Button' grouping, and spy tools cannot focus on those controls within the button bounds (groups). I also use it to verify that a given ID is not present more than once...if not, that's how I identify the control in future scripts. Output can be filtered by: 1) Filter by IsVisible 2) Filter by matching class (ex Button, Label, Static) 3) Filter by containing text #include <Array.au3> #include <WinAPI.au3> ConsoleWrite("Make your window active!" & @CRLF) Sleep(5000) GetAllWindowsControls(WinGetHandle("[ACTIVE]")) Func GetAllWindowsControls($hCallersWindow, $bOnlyVisible=Default, $sStringIncludes=Default, $sClass=Default) If Not IsHWnd($hCallersWindow) Then ConsoleWrite("$hCallersWindow must be a handle...provided=[" & $hCallersWindow & "]" & @CRLF) Return False EndIf ; Get all list of controls If $bOnlyVisible = Default Then $bOnlyVisible = False If $sStringIncludes = Default Then $sStringIncludes = "" If $sClass = Default Then $sClass = "" $sClassList = WinGetClassList($hCallersWindow) ; Create array $aClassList = StringSplit($sClassList, @CRLF, 2) ; Sort array _ArraySort($aClassList) _ArrayDelete($aClassList, 0) ; Loop $iCurrentClass = "" $iCurrentCount = 1 $iTotalCounter = 1 If StringLen($sClass)>0 Then For $i = UBound($aClassList)-1 To 0 Step - 1 If $aClassList[$i]<>$sClass Then _ArrayDelete($aClassList,$i) EndIf Next EndIf For $i = 0 To UBound($aClassList) - 1 If $aClassList[$i] = $iCurrentClass Then $iCurrentCount += 1 Else $iCurrentClass = $aClassList[$i] $iCurrentCount = 1 EndIf $hControl = ControlGetHandle($hCallersWindow, "", "[CLASSNN:" & $iCurrentClass & $iCurrentCount & "]") $text = StringRegExpReplace(ControlGetText($hCallersWindow, "", $hControl), "[\n\r]", "{@CRLF}") $aPos = ControlGetPos($hCallersWindow, "", $hControl) $sControlID = _WinAPI_GetDlgCtrlID($hControl) $bIsVisible = ControlCommand($hCallersWindow, "", $hControl, "IsVisible") If $bOnlyVisible And Not $bIsVisible Then $iTotalCounter += 1 ContinueLoop EndIf If StringLen($sStringIncludes) > 0 Then If Not StringInStr($text, $sStringIncludes) Then $iTotalCounter += 1 ContinueLoop EndIf EndIf If IsArray($aPos) Then ConsoleWrite("Func=[GetAllWindowsControls]: ControlCounter=[" & StringFormat("%3s", $iTotalCounter) & "] ControlID=[" & StringFormat("%5s", $sControlID) & "] Handle=[" & StringFormat("%10s", $hControl) & "] ClassNN=[" & StringFormat("%19s", $iCurrentClass & $iCurrentCount) & "] XPos=[" & StringFormat("%4s", $aPos[0]) & "] YPos=[" & StringFormat("%4s", $aPos[1]) & "] Width=[" & StringFormat("%4s", $aPos[2]) & "] Height=[" & StringFormat("%4s", $aPos[3]) & "] IsVisible=[" & $bIsVisible & "] Text=[" & $text & "]." & @CRLF) Else ConsoleWrite("Func=[GetAllWindowsControls]: ControlCounter=[" & StringFormat("%3s", $iTotalCounter) & "] ControlID=[" & StringFormat("%5s", $sControlID) & "] Handle=[" & StringFormat("%10s", $hControl) & "] ClassNN=[" & StringFormat("%19s", $iCurrentClass & $iCurrentCount) & "] XPos=[winclosed] YPos=[winclosed] Width=[winclosed] Height=[winclosed] Text=[" & $text & "]." & @CRLF) EndIf If Not WinExists($hCallersWindow) Then ExitLoop $iTotalCounter += 1 Next EndFunc ;==>GetAllWindowsControls
    1 point
  2. From same author there is a command line tool called Sejda: http://www.sejda.org/ Here how to list commands available: #cs ---------------------------------------------------------------------------- Adaptado de guinness Snippets ( CMD ) https://www.autoitscript.com/wiki/Main_Page #ce ---------------------------------------------------------------------------- ;https://www.autoitscript.com/wiki/Main_Page #include <Constants.au3> ConsoleWrite( _GetDOSOutput('"' & @ScriptDir & '\sejda-console-2.10.4\bin\sejda-console.bat"') & @CRLF) Func _GetDOSOutput($sCommand) Local $iPID, $sOutput = "" $iPID = Run('"' & @ComSpec & '" /c ' & $sCommand, "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) While 1 $sOutput &= StdoutRead($iPID, False, False) If @error Then ExitLoop EndIf Sleep(10) WEnd Return $sOutput EndFunc ;==>_GetDOSOutput some of the commands returned: pdftojpeg Converts a PDF document to multiple JPEG images (one image per page). pdftomultipletiff Converts a PDF document to multiple TIFF images (one image per page). pdftosingletiff Converts a PDF document to a single TIFF image (TIFF format supports multiple images written to a single file). ... Use "sejda-console <command> -h" for help regarding a specific command Help for pdftojpeg command: #include <Constants.au3> ConsoleWrite( _GetDOSOutput('"' & @ScriptDir & '\sejda-console-2.10.4\bin\sejda-console.bat" pdftojpeg -h') & @CRLF) Func _GetDOSOutput($sCommand) Local $iPID, $sOutput = "" $iPID = Run('"' & @ComSpec & '" /c ' & $sCommand, "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) While 1 $sOutput &= StdoutRead($iPID, False, False) If @error Then ExitLoop EndIf Sleep(10) WEnd Return $sOutput EndFunc ;==>_GetDOSOutput Converts a PDF document to multiple JPEG images (one image per page). Example usage: sejda-console pdftojpeg -f /tmp/file1.pdf -o /tmp Usage: sejda-console pdftojpeg options [--existingOutput -j value] : policy to use when an output file with the same name already exists. {overwrite, skip, fail}. Default is 'fail' (optional) --files -f value... : pdf files to operate on. A list of existing pdf files (EX. -f /tmp/file1.pdf or -f /tmp/password_protected_file2.pdf:secret123) (required) [--help -h] : prints usage information. Can be used to detail options for a command '-h command' (optional) --output -o value : output directory (required) [--outputPrefix -p value] : prefix for the output files name (optional) [--pageSelection -s value] : page selection script. You can set a subset of pages to convert. Accepted values: 'num1-num2' or 'num-' or 'num1,num2-num3..' (EX. -s 4,12-14,8,20-) (optional) [--resolution -r value] : resolution in dpi. Default is 72 (optional) Here an example for pdftosingletiff #include <Constants.au3> Global $iPID, $sOutput = "" ;$iPID = Run(@ComSpec & " /C " & '"' & @ScriptDir & '\sejda-console-2.10.4\bin\sejda-console.bat" merge -h', "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) ;$iPID = Run(@ComSpec & " /C " & '"' & @ScriptDir & '\sejda-console-2.10.4\bin\sejda-console.bat" merge -l C:\files.csv -o C:\output.pdf --overwrite', "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) Global $sFolder = "C:\escaner\", $sFileName = '', $sText = '' ;Assign a Local variable the search handle of all files in the directory. Local $hSearch = FileFindFirstFile($sFolder & "*.pdf") ;Check if the search was successful, if not display a message and exit If $hSearch = -1 Then MsgBox($MB_SYSTEMMODAL, "", "Error: No files/directories matched the search pattern.") Exit EndIf While 1 $sFileName = FileFindNextFile($hSearch) ; If there is no more file matching the search. If @error Then ExitLoop $sText &= " " & $sFolder & $sFileName WEnd ;Close the search handle. FileClose($hSearch) $sText = StringMid($sText,2) ;$iPID = Run(@ComSpec & " /C """ & @ScriptDir & "\sejda-console-2.10.4\bin\sejda-console.bat"" merge -l C:\FILEST~1\files.csv -o C:\FILEST~1\output.pdf --overwrite", "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) ;$sFileShort= FileGetShortName($sFolder) ;$iPID = Run(@ComSpec & " /C """ & @ScriptDir & "\sejda-console-2.10.4\bin\sejda-console.bat"" merge -l " & $sFileShort & "files.csv -o " & $sFileShort & "output.pdf --overwrite", "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) $iPID = Run(@ComSpec & " /C """ & @ScriptDir & "\sejda-console-2.10.4\bin\sejda-console.bat"" pdftosingletiff -f " & $sText & " -o " & $sFolder & "\output.tiff -r 100 --colorType gray_scale --overwrite", "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) ProcessWaitClose($iPID) $sOutput = StdoutRead($iPID) ConsoleWrite($sOutput) Similar with other commands like simplesplit: #include <Constants.au3> Global $iPID, $sOutput = "" ;$iPID = Run(@ComSpec & " /C " & '"' & @ScriptDir & '\sejda-console-2.10.4\bin\sejda-console.bat" merge -h', "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) ;$iPID = Run(@ComSpec & " /C " & '"' & @ScriptDir & '\sejda-console-2.10.4\bin\sejda-console.bat" merge -l C:\files.csv -o C:\output.pdf --overwrite', "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) Global $sFolder = "C:\escaner\", $sFileName = '', $sText = '' ;Assign a Local variable the search handle of all files in the directory. Local $hSearch = FileFindFirstFile($sFolder & "*.pdf") ;Check if the search was successful, if not display a message and exit If $hSearch = -1 Then MsgBox($MB_SYSTEMMODAL, "", "Error: No files/directories matched the search pattern.") Exit EndIf While 1 $sFileName = FileFindNextFile($hSearch) ; If there is no more file matching the search. If @error Then ExitLoop $sText &= " " & $sFolder & $sFileName WEnd ;Close the search handle. FileClose($hSearch) $sText = StringMid($sText,2) ;$iPID = Run(@ComSpec & " /C """ & @ScriptDir & "\sejda-console-2.10.4\bin\sejda-console.bat"" merge -l C:\FILEST~1\files.csv -o C:\FILEST~1\output.pdf --overwrite", "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) ;$sFileShort= FileGetShortName($sFolder) ;$iPID = Run(@ComSpec & " /C """ & @ScriptDir & "\sejda-console-2.10.4\bin\sejda-console.bat"" merge -l " & $sFileShort & "files.csv -o " & $sFileShort & "output.pdf --overwrite", "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) $iPID = Run(@ComSpec & " /C """ & @ScriptDir & "\sejda-console-2.10.4\bin\sejda-console.bat"" simplesplit -f " & $sText & " -o " & $sFolder & " -s all -j overwrite", "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) ProcessWaitClose($iPID) $sOutput = StdoutRead($iPID) ConsoleWrite($sOutput)
    1 point
  3. ShellExecute(@ScriptDir & "\jvm\bin\java.exe","-jar " & @ScriptDir & "\learnLambda-1.0.jar", "", "", @SW_HIDE); or Run(@ComSpec & " /c " & ".\jvm\bin\java.exe -jar " & ".\learnLambda-1.0.jar", "", @SW_HIDE); Edit: @SW_HIDE belongs in the 5th parameter of ShellExecute.
    1 point
  4. LAMLE, Just do the one check like this: For $stt = 0 To 2 ; Only 3 elements to check If $test[$stt] <> "" Then $list[$stt] = $test[$stt] EndIf Next M23
    1 point
  5. LAMLE, Welcome to the AutoIt forums. Your script will stop with an error as you are running the loop 4 times on a 3-element array. Remember the AutoIt arrays start at element 0. And what do you want to happen if the input is ""? You have no code to run in that event. M23
    1 point
  6. ioa747

    SciTE PlusBar

    Directly no. Run the script will run the SciTE to. or look the post from above, how to make the integration to SciTE as tool
    1 point
  7. try to get the data into an array and then use arraysearch to search the array refer to code below (copied from @boludoz) #include <StringConstants.au3> #include <Array.au3> Global $g_sString = "Bob,24|Jane,25|Julian,26|" Global $g_sDelimRow = '|' Global $g_sDelimCol = ',' Global $g_aArray2D = StringSplit2D($g_sString, $g_sDelimCol, $g_sDelimRow) _ArrayDisplay($g_aArray2D, @ScriptName) Func StringSplit2D($sMatches = "Hola-2-5-50-50-100-100|Hola-6-200-200-100-100", Const $sDelim_Item = "-", Const $sDelim_Row = "|", $bFixLast = Default) Local $iValDim_1, $iValDim_2 = 0, $iColCount ; Fix last item or row. If $bFixLast <> False Then Local $sTrim = StringRight($sMatches, 1) If $sTrim = $g_sDelimRow Or $sTrim = $sDelim_Item Then $sMatches = StringTrimRight($sMatches, 1) EndIf Local $aSplit_1 = StringSplit($sMatches, $sDelim_Row, $STR_NOCOUNT + $STR_ENTIRESPLIT) $iValDim_1 = UBound($aSplit_1, $UBOUND_ROWS) Local $aTmp[$iValDim_1][0], $aSplit_2 For $i = 0 To $iValDim_1 - 1 $aSplit_2 = StringSplit($aSplit_1[$i], $sDelim_Item, $STR_NOCOUNT + $STR_ENTIRESPLIT) $iColCount = UBound($aSplit_2) If $iColCount > $iValDim_2 Then $iValDim_2 = $iColCount ReDim $aTmp[$iValDim_1][$iValDim_2] EndIf For $j = 0 To $iColCount - 1 $aTmp[$i][$j] = $aSplit_2[$j] Next Next Return $aTmp EndFunc ;==>StringSplit2D for the keypress u can use the HotKeySet function
    1 point
×
×
  • Create New...