All Activity
- Past hour
-
@bladem2003 You may want to try my UDF here
- Today
-
nrg joined the community
-
Hi, how can I get the value of $sDataToSend in _WM_COPYDATA? _WM_COPYDATA only returns the string in $vRet. I want to make a selection based on the lParam and return a value or string
-
Help needed search for PowerPoint slides - (Moved)
MDP replied to MDP's topic in AutoIt General Help and Support
Never mind... I got it. I was making a simple mistake. -
Norm73 reacted to a post in a topic: Problem selecting listview item to tick a checkbox
-
ioa747 reacted to a post in a topic: GUISetHelp Placement
-
ioa747, The second example looks to be more appropriate! Thanks again! Much appreciated!
-
mr-es335 reacted to a post in a topic: GUISetHelp Placement
-
mr-es335 reacted to a post in a topic: GUISetHelp Placement
-
hewhocorrupts joined the community
-
or you could take this approach, where things have their place ;~ ----------------------------------------------- #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <GuiListView.au3> #include <MsgBoxConstants.au3> ; ----------------------------------------------- Global $hGUI = GUICreate("Title", 220, 75) ; ----------------------------------------------- ; COLUMN 1 BUTTONS Global $_sCol1Row1 = GUICtrlCreateButton("Item 1", 10, 10, 200, 25) Global $_sCol1Row2 = GUICtrlCreateButton("Item 1", 10, 40, 200, 25) Global $idUserDocs = GUICtrlCreateDummy() ; ----------------------------------------------- Local $aAccelKeys[1][2] = [["{F1}", $idUserDocs]] GUISetAccelerators($aAccelKeys) ; ----------------------------------------------- GUISetState(@SW_SHOW, $hGUI) ; ----------------------------------------------- While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit ; ----------------- ; COLUMN 1 BUTTONS Case $_sCol1Row1 _MyFunction1() Case $_sCol1Row2 _MyFunction2() Case $idUserDocs _UserDocs() EndSwitch WEnd ; ----------------------------------------------- ; COLUMN 1 BUTTONS ; ----------------------------------------------- Func _MyFunction1() MsgBox(0, "", "Inside _MyFunction1") EndFunc ;==>_MyFunction1 ; ----------------------------------------------- Func _MyFunction2() MsgBox(0, "", "Inside _MyFunction2") EndFunc ;==>_MyFunction2 ; ----------------------------------------------- Func _UserDocs() Local $sPdfProgram = "C:\Program Files (x86)\FoxitReader\Foxit Reader.exe" Local $sPdfFile = "C:\Working\TestMe.pdf" ; ----------------------------------------------- ShellExecute($sPdfProgram, $sPdfFile) EndFunc ;==>_UserDocs ; -----------------------------------------------
-
I placed it immediately after the appearance of the gui, because that seemed to me the most appropriate position (it could have been included earlier) ;~ ----------------------------------------------- #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <GuiListView.au3> #include <MsgBoxConstants.au3> ; ----------------------------------------------- Global $hGUI = GUICreate("Title", 220, 75) ; ----------------------------------------------- ; COLUMN 1 BUTTONS Global $_sCol1Row1 = GUICtrlCreateButton("Item 1", 10, 10, 200, 25) Global $_sCol1Row2 = GUICtrlCreateButton("Item 1", 10, 40, 200, 25) ; ----------------------------------------------- GUISetState(@SW_SHOW, $hGUI) _UserDocs() ; ----------------------------------------------- While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit ; ----------------- ; COLUMN 1 BUTTONS Case $_sCol1Row1 _MyFunction1() Case $_sCol1Row2 _MyFunction2() EndSwitch WEnd ; ----------------------------------------------- ; COLUMN 1 BUTTONS ; ----------------------------------------------- Func _MyFunction1() MsgBox(0, "", "Inside _MyFunction1") EndFunc ;==>_MyFunction1 ; ----------------------------------------------- Func _MyFunction2() MsgBox(0, "", "Inside _MyFunction2") EndFunc ;==>_MyFunction2 ; ----------------------------------------------- Func _UserDocs() Local $sPdfProgram = "C:\Program Files (x86)\FoxitReader\Foxit Reader.exe" Local $sPdfFile = "C:\Working\TestMe.pdf" ; ----------------------------------------------- GUISetHelp('"' & $sPdfProgram & '" "' & $sPdfFile & '"') EndFunc ;==>_UserDocs ; -----------------------------------------------
-
Good day, In the following sample, where is the preferred placement of the GUISetHelp Function? And, may I also "Why" is this placement preferred? ; ----------------------------------------------- #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <GuiListView.au3> #include <MsgBoxConstants.au3> ; ----------------------------------------------- Global $hGUI = GUICreate("Title", 220, 75) ; ----------------------------------------------- ; COLUMN 1 BUTTONS Global $_sCol1Row1 = GUICtrlCreateButton("Item 1", 10, 10, 200, 25) Global $_sCol1Row2 = GUICtrlCreateButton("Item 1", 10, 40, 200, 25) ; ----------------------------------------------- GUISetState(@SW_SHOW, $hGUI) ; ----------------------------------------------- While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit ; ----------------- ; COLUMN 1 BUTTONS Case $_sCol1Row1 _MyFunction1() Case $_sCol1Row2 _MyFunction2() EndSwitch WEnd ; ----------------------------------------------- ; COLUMN 1 BUTTONS ; ----------------------------------------------- Func _MyFunction1() MsgBox(0, "", "Inside _MyFunction1") EndFunc ;==>_MyFunction1 ; ----------------------------------------------- Func _MyFunction2() MsgBox(0, "", "Inside _MyFunction2") EndFunc ;==>_MyFunction2 ; ----------------------------------------------- Here is the GUISetHelp Function: ; ----------------------------------------------- Func _UserDocs() Local $sPdfProgram = "C:\Program Files (x86)\FoxitReader\Foxit Reader.exe" Local $sPdfFile = "C:\Working\TestMe.pdf" ; ----------------------------------------------- GUISetHelp('"' & $sPdfProgram & '" "' & $sPdfFile & '"') EndFunc ;==>_UserDocs ; ----------------------------------------------- I have attached a test pdf as well. As always, any clarification would be greatly appreciated! TestMe.pdf
-
FREEON, Welcome to the AutoIt forum. Unfortunately you appear to have missed the Forum rules on your way in. Please read them now - particularly the bit about not discussing game server automation - and then you will understand why you will get no help and this thread will now be locked. See you soon with a legitimate question I hope. M23
-
Help needed search for PowerPoint slides - (Moved)
water replied to MDP's topic in AutoIt General Help and Support
Did you have a look at the PowerPoint UDF, function _PPT_TextFind? The link to the PPT UDF can be found in my signature. -
Yes it is necessary for playing cs2. To obtain coordinates from the getpos command which saves the log to the console.log file. We need to extract the line setpos and so on and save it to our new file along the path for cfg files with the extension *.cfg And then in training mode we simply read our file and teleport to the desired point to practice skills. But I encountered a problem that I cannot read or delete files through a variable. But if I do this with a full path link without variables, then the script works correctly. so there is no error with privileges, but the error is somewhere in the incorrect entry of a variable and the processing of commands for recording deletion I tried to resolve the issue that the task did not seem difficult and confusing for you.
-
#RequireAdmin ; We execute the script with admin rights because win11 may have rights and access conflicts. I haven’t figured out yet whether we need these rights ; Process name. To get the path because he can change $process = "test.exe" ; Waiting for the process to start ; Checking a running process While Not ProcessExists($process) ToolTip("test.exe not activated", 0, 0) Sleep(1000) WEnd ; Remove the tooltip when the process is running ToolTip("") ; Getting an object WMI $obj = ObjGet("WinMgmts:\\.\root\cimv2") ;Running a WMI query to get the process path $que = $obj.ExecQuery('SELECT * FROM Win32_Process WHERE Caption="' & $process & '"') ; Variable for storing our folders where test.exe is launched from $res = "" ; Looping through query results For $o In $que $res &= $o.ExecutablePath & @CRLF Next ; Output of the result for checking test.exe what it shows there MsgBox(0, "", $res) ; Removing part of the path and adding a new one, which would give us the path to store the data we need for the console.log file If StringInStr($res, "bin\win64") Then $res1 = StringReplace($res, "bin\win64\test.exe", "log\console.log") EndIf ; Write the result to the clipboard ;ClipPut($res1) ; Outputting a new path, for example D:\Steam\steamapps\common\test\game\log\console.log MsgBox(0, "new path", $res1) ; Checking file existence console.log If FileExists(StringStripWS($res1, 3)) Then MsgBox(0, "log", "The file exists") Else MsgBox(0, "logт", "File not found - (perform the action that needs to be created) console.log") EndIf ; Reading the console.log file and searching for lines Local $file = FileOpen(StringStripWS($res1, 3), 0) If $file = -1 Then MsgBox(0, "Error", "Failed to open file: " & $res1) Exit EndIf ;Declaring a variable to search for strings using a regular expression 12/02 01:58:41 pos1 -367.000000 -808.000000 143.944260;pos2 0.000000 -177.000046 0.000000 ;and cut off the extra (date, time) text in the line Local $line, $cooXYZ = "" While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop If StringRegExp($line, '^\d{2}/\d{2} \d{2}:\d{2}:\d{2} pos1 -?\d+\.\d+ -?\d+\.\d+ -?\d+\.\d+;pos2 -?\d+\.\d+ -?\d+\.\d+ -?\d+\.\d+$') Then $cooXYZ = StringRegExpReplace($line, '^\d{2}/\d{2} \d{2}:\d{2}:\d{2} ', '') ExitLoop EndIf WEnd FileClose($file) ; Output of the result of processing and trimming lines If $cooXYZ <> "" Then MsgBox(0, "Coordinates", $cooXYZ) Else MsgBox(0, "log2", "Line with coordinates not found") EndIf ; Write the result to the clipboard ;ClipPut($cooXYZ) ; Creating a new path to create the testfilie.txt file at the desired path from the process variable Local $filePath = StringReplace($res, "bin\win64\test.exe", "test\cfg\testfile.txt") MsgBox(0, "Checking our path testfilie.txt", $filePath ) ; Checking the existence of a directory and creating it if it is missing Local $dir = StringLeft($filePath, StringInStr($filePath, "\", 0, -1) - 1) If Not FileExists($dir) Then DirCreate($dir) EndIf ; EVERYTHING STILL DOESN'T WORK ; IF I SPECIFY A SIMPLE PATH WITHOUT A VARIABLE THEN IT WORKS IF THERE IS AN ERROR FROM THE VARIABLE ERROR ; IT IS NOT ABLE TO DELETE NOR WRITE THE FILE IT DOES NOT WORK FOR THE TEST I CREATED THE FILES MANUALLY. NOTHING ; Write a line of text to the file testfilie.txt along the path $filePath Local $file = FileOpen(StringInStr($filePath), 2) If $file = -1 Then MsgBox(0, "error", "Failed to create file: " & $filePath & @CRLF & "Check permissions and existence of directories.") Exit EndIf FileWrite($file, $cooXYZ) FileClose($file) ; Output of the result MsgBox(0, "log3", "The file was successfully created and the text was written: " & $filePath) ; Clearing the console.log file We delete the file and create it again to make it easier to find and weight. If FileExists($res1) Then FileDelete($res1) EndIf FileWrite($res1, "")
-
FREE0N joined the community
-
Help needed search for PowerPoint slides - (Moved)
Melba23 replied to MDP's topic in AutoIt General Help and Support
Moved to the appropriate AutoIt General Help and Support forum, as the Developer General Discussion forum very clearly states: Moderation Team -
Maybe it will be useful to someone To use UDF you need to copy 2 files PLINK.EXE and PSCP.EXE and edit the path if needed! ;#include <AutoItConstants.au3> ;Opt("MustDeclareVars", 1) ;0=no, 1=require pre-declaration Global $Path_SSH_Plink_EXE = '"' & @ScriptDir & '\x86\plink.exe' & '"' Global $Path_PSCP_EXE = '"' & @ScriptDir & '\x86\pscp.exe' & '"' ;~ Global $iHost = 'x.x.x.x' ;~ Global $iPort = '22' ;~ Global $iUserName = 'root' ;~ Global $iUserPassword = 'passssssssss' ;~ ;----------------------------------------------------------------------------------------------- ;~ _SSH_SendCmd($iHost, 22, $iUserName, $iUserPassword, 'ls -lS') ;~ ;----------------------------------------------------------------------------------------------- ;~ _EG_Run_Multi_Command($iHost, $iPort, $iUserName, $iUserPassword) ;~ ;----------------------------------------------------------------------------------------------- ;~ FileDelete(@ScriptDir & '\z.exe') ;~ _SSH_SendFile(@ScriptDir & '\putty.exe', '/tmp/z.exe', $iHost, 22, $iUserName, $iUserPassword) ;~ _SSH_SendCmd($iHost, 22, $iUserName, $iUserPassword, 'ls -lS /tmp/', False) ;~ _SSH_GetFile(@ScriptDir & '\z.exe', '/tmp/z.exe', $iHost, 22, $iUserName, $iUserPassword) ;~ _SSH_SendCmd($iHost, 22, $iUserName, $iUserPassword, 'rm -rf /tmp/*', False) ;~ _SSH_SendCmd($iHost, 22, $iUserName, $iUserPassword, 'ls -lS /tmp/', False) ;~ ConsoleWrite('- FileExists z.exe: ' & FileExists(@ScriptDir & '\z.exe') & @CRLF) ;~ FileDelete(@ScriptDir & '\z.exe') ;~ ;----------------------------------------------------------------------------------------------- ;~ DirRemove(@ScriptDir & '\_x88', 1) ;~ _SSH_SendCmd($iHost, 22, $iUserName, $iUserPassword, 'rm -rf /tmp/*', False) ;~ _SSH_SendCmd($iHost, 22, $iUserName, $iUserPassword, 'ls -lS /tmp/', False) ;~ _SSH_SendCmd($iHost, 22, $iUserName, $iUserPassword, 'mkdir /tmp/x86/', False) ;~ _SSH_SendFolder(@ScriptDir & '\x86', '/tmp/x86', $iHost, 22, $iUserName, $iUserPassword) ;~ _SSH_SendCmd($iHost, 22, $iUserName, $iUserPassword, 'ls -lS /tmp/', False) ;~ _SSH_SendCmd($iHost, 22, $iUserName, $iUserPassword, 'ls -lS /tmp/x86/', False) ;~ FileDelete(@ScriptDir & '\_x88') ;~ DirCreate(@ScriptDir & '\_x88') ;~ _SSH_GetFolder(@ScriptDir & '\_x88', '/tmp/x86', $iHost, 22, $iUserName, $iUserPassword) ;~ _SSH_SendCmd($iHost, 22, $iUserName, $iUserPassword, 'rm -rf /tmp/*', False) ;~ _SSH_SendCmd($iHost, 22, $iUserName, $iUserPassword, 'ls -lS /tmp/', False) ;~ ConsoleWrite('- FileExists _x88: ' & DirGetSize(@ScriptDir & '\_x88') & @CRLF) ;~ DirRemove(@ScriptDir & '\_x88', 1) ;~ ;----------------------------------------------------------------------------------------------- ;~ DirRemove(@ScriptDir & '\_x99', 1) ;~ _SSH_SendCmd($iHost, 22, $iUserName, $iUserPassword, 'rm -rf /tmp/*', False) ;~ _SSH_SendCmd($iHost, 22, $iUserName, $iUserPassword, 'ls -lS /tmp/', False) ;~ _SSH_SendCmd($iHost, 22, $iUserName, $iUserPassword, 'mkdir /tmp/_xx/', False) ;~ _SSH_SendFolder(@ScriptDir & '\_xx', '/tmp/', $iHost, 22, $iUserName, $iUserPassword, True) ;~ _SSH_SendCmd($iHost, 22, $iUserName, $iUserPassword, 'ls -lS /tmp/', False) ;~ _SSH_SendCmd($iHost, 22, $iUserName, $iUserPassword, 'ls -lS /tmp/_xx/', False) ;~ FileDelete(@ScriptDir & '\_x99') ;~ DirCreate(@ScriptDir & '\_x99') ;~ _SSH_GetFolder(@ScriptDir & '\_x99', '/tmp/_xx', $iHost, 22, $iUserName, $iUserPassword, True) ;~ ConsoleWrite('- FileExists _x99: ' & DirGetSize(@ScriptDir & '\_x99') & @CRLF) ;~ _SSH_SendCmd($iHost, 22, $iUserName, $iUserPassword, 'rm -rf /tmp/*', False) ;~ _SSH_SendCmd($iHost, 22, $iUserName, $iUserPassword, 'ls -lS /tmp/', False) ;~ DirRemove(@ScriptDir & '\_x99', 1) ;~ ;----------------------------------------------------------------------------------------------- Func _EG_Run_Multi_Command($iHost, $iPort, $iUserName, $iUserPassword) Local $Plink_PID = _SSH_Plink_Connect($iHost, $iPort, $iUserName, $iUserPassword) ConsoleWrite('! $Plink_PID: ' & $Plink_PID & @CRLF) Local $sOutput, $sOutput_tmp If $Plink_PID > 0 Then _SSH_Plink_SendCmd($Plink_PID, @CR) $sOutput_tmp = _SSH_Plink_SendCmd($Plink_PID, 'ls /tmp/') ConsoleWrite('- ' & $sOutput_tmp & @CRLF) For $i = 1 To 5 $sOutput_tmp = _SSH_Plink_SendCmd($Plink_PID, ' mkdir /tmp/Dir_' & $i) ConsoleWrite('- ' & $sOutput_tmp & @CRLF) $sOutput &= $sOutput_tmp & @CRLF Next ;$sOutput_tmp = _SSH_Plink_SendCmd($Plink_PID, 'rm -rf /tmp/*') ;ConsoleWrite('- ' & $sOutput_tmp & @CRLF) ;$sOutput &= $sOutput_tmp & @CRLF $sOutput_tmp = _SSH_Plink_SendCmd($Plink_PID, 'ls /tmp/') ConsoleWrite('- ' & $sOutput_tmp & @CRLF) $sOutput &= $sOutput_tmp & @CRLF If ProcessExists($Plink_PID) Then ProcessClose($Plink_PID) EndIf ClipPut($sOutput) EndFunc ;==>_EG_Run_Multi_Command Func _SSH_GetFile($LocalFilePath, $RemoteFilePath, $sHost, $sPort, $sUserName, $sUserPassword) ;Copy single file Local $sCommand = ' -P ' & $sPort & ' -l ' & $sUserName & ' -pw ' & $sUserPassword & ' ' & $sHost & ':' & $RemoteFilePath & ' "' & $LocalFilePath & '" ' Return __PSCP_Execute($sCommand) EndFunc ;==>_SSH_GetFile Func _SSH_GetFolder($LocalFolderPath, $RemoteFolderPath, $sHost, $sPort, $sUserName, $sUserPassword, $sRecur = False) If $sRecur Then ;Copy all files & folders in a folder Local $sCommand = ' -P ' & $sPort & ' -l ' & $sUserName & ' -pw ' & $sUserPassword & ' -r ' & $sHost & ':"' & $RemoteFolderPath & '" "' & $LocalFolderPath & '"' Return __PSCP_Execute($sCommand) Else ;Copy all files in a folder Local $sCommand = ' -P ' & $sPort & ' -l ' & $sUserName & ' -pw ' & $sUserPassword & ' ' & $sHost & ':"' & $RemoteFolderPath & '/*" "' & $LocalFolderPath & '"' Return __PSCP_Execute($sCommand) EndIf EndFunc ;==>_SSH_GetFolder Func _SSH_SendFile($LocalFilePath, $RemoteFilePath, $sHost, $sPort, $sUserName, $sUserPassword) ;Copy single file Local $sCommand = ' -P ' & $sPort & ' -l ' & $sUserName & ' -pw ' & $sUserPassword & ' "' & $LocalFilePath & '" ' & $sHost & ':' & $RemoteFilePath Return __PSCP_Execute($sCommand) EndFunc ;==>_SSH_SendFile Func _SSH_SendFolder($LocalFolderPath, $RemoteFolderPath, $sHost, $sPort, $sUserName, $sUserPassword, $sRecur = False) If $sRecur Then ;Copy all files & folders in a folder Local $sCommand = ' -P ' & $sPort & ' -l ' & $sUserName & ' -pw ' & $sUserPassword & ' -r "' & $LocalFolderPath & '" ' & $sHost & ':"' & $RemoteFolderPath & '"' Return __PSCP_Execute($sCommand) Else ;Copy all files in a folder Local $sCommand = ' -P ' & $sPort & ' -l ' & $sUserName & ' -pw ' & $sUserPassword & ' "' & $LocalFolderPath & '\*" ' & $sHost & ':"' & $RemoteFolderPath & '"' Return __PSCP_Execute($sCommand) EndIf EndFunc ;==>_SSH_SendFolder Func _SSH_SendCmd($sHost, $sPort, $sUserName, $sUserPassword, $sRequest, $sleep = True) Local $sCommand = '-ssh -no-antispoof ' & $sHost & ' -P ' & $sPort & ' -l ' & $sUserName & ' -pw ' & $sUserPassword & ' ' & $sRequest If $sleep Then $sCommand &= ' ; sleep 1' ; sleep prevents truncation of output by fast server disconnect ConsoleWrite($Path_SSH_Plink_EXE & ' ' & $sCommand & @CRLF) Local $Plink_PID = Run($Path_SSH_Plink_EXE & ' ' & $sCommand, '', @SW_HIDE, 9) Local $sStdoutRead, $sData While ProcessExists($Plink_PID) $sStdoutRead = StdoutRead($Plink_PID) If @error Then ExitLoop If $sStdoutRead <> '' Then $sData &= $sStdoutRead $sStdoutRead = '' WEnd $sStdoutRead = '' While ProcessExists($Plink_PID) $sStdoutRead = StderrRead($Plink_PID) If @error Then ExitLoop If $sStdoutRead <> '' Then $sData &= $sStdoutRead $sStdoutRead = '' WEnd ConsoleWrite($sData & @CRLF) If ProcessExists($Plink_PID) Then ProcessClose($Plink_PID) Return __SanitizeOutput($sData) ; returns the full plink command output EndFunc ;==>_SSH_SendCmd Func _SSH_Plink_Connect($sHost, $sPort, $sUserName, $sUserPassword) Local $sCommand = '-ssh -no-antispoof ' & $sHost & ' -P ' & $sPort & ' -l ' & $sUserName & ' -pw ' & $sUserPassword ; sleep prevents truncation of output by fast server disconnect ConsoleWrite($Path_SSH_Plink_EXE & ' ' & $sCommand & @CRLF) Local $Plink_PID = Run($Path_SSH_Plink_EXE & ' ' & $sCommand, '', @SW_HIDE, 7) Local $sStdoutRead, $sData, $error1, $error2 While True $sStdoutRead = StdoutRead($Plink_PID) $error1 = @error If $sStdoutRead <> '' Then $sData &= $sStdoutRead $sStdoutRead = '' $sStdoutRead = StderrRead($Plink_PID) $error2 = @error If $sStdoutRead <> '' Then $sData &= $sStdoutRead ;ConsoleWrite($sData & @CRLF) If StringInStr(StringRight($sData, 1), "#") Then Return $Plink_PID If StringInStr(StringRight($sData, 2), "# ") Then Return $Plink_PID If StringInStr($sData, "Welcome") Then Return $Plink_PID If $error2 And $error2 Then ExitLoop $sStdoutRead = '' $error1 = '' $error2 = '' WEnd Return SetError(1, 0, $Plink_PID) EndFunc ;==>_SSH_Plink_Connect Func _SSH_Plink_SendCmd($Plink_PID, $sCMD) Local $sStdoutRead, $sData, $error1, $error2 ConsoleWrite('> _SSH_Plink_SendCmd [' & $Plink_PID & ']: ' & $sCMD & @CRLF) StdinWrite($Plink_PID, $sCMD & @CR) Sleep(250) While True Sleep(100) $sStdoutRead = StdoutRead($Plink_PID) $error1 = @error ;If $error Then ExitLoop If $sStdoutRead <> '' Then $sData &= $sStdoutRead $sStdoutRead = '' $sStdoutRead = StderrRead($Plink_PID) $error2 = @error If $error2 And $error2 Then ExitLoop If $sStdoutRead <> '' Then $sData &= $sStdoutRead $sStdoutRead = '' $error1 = '' $error2 = '' ;ConsoleWrite($sData & @CRLF) If StringInStr(StringRight($sData, 1), "#") Then Return __SanitizeOutput($sData) If StringInStr(StringRight($sData, 2), "# ") Then Return __SanitizeOutput($sData) WEnd Return __SanitizeOutput($sData) EndFunc ;==>_SSH_Plink_SendCmd Func __SanitizeOutput($str) Local $sBell = BinaryToString("0x07", 4), $sESC = BinaryToString("0x1B", 4) $str = StringReplace($str, BinaryToString("0xC3A2E282ACCB9C", 4), "'") ; '‘' $str = StringReplace($str, BinaryToString("0xC3A2E282ACE284A2", 4), "'") ; '’' $str = StringReplace($str, $sESC & "[?2004h", "") $str = StringReplace($str, $sESC & "[?2004l" & @CR, "") If StringInStr($str, $sBell) Then ; � Local $lines = StringSplit($str, @CRLF) Local $p1, $p2 For $i = 1 To $lines[0] $p1 = StringInStr($str, $sESC & "]0;") ; � If $p1 <> 0 Then $p2 = StringInStr($str, $sBell, 1, 1, $p1) If $p2 <> 0 Then $str = StringLeft($str, $p1 - 1) & StringRight($str, StringLen($str) - $p2) EndIf EndIf Next EndIf ; Matching Pattern: ESC\[[0-107][;0-107][;0-255]m ; leading zeros are matched ; Matches ANSI Codes: SGR, 3-bit color, 4-bit color and 8-bit color $str = StringRegExpReplace($str, $sESC & "\[([0-1]0[0-7]|\d?\d)?(;[0-1]0[0-7]|;\d?\d)?(;[0-1]?\d?\d|;(0|2)[0-5][0-5])?m", "") ; Matching Pattern: ESC\[(38|48);2;[0-255];[0-255];[0-255]m ; leading zeros are matched ; Matches ANSI Codes: True Color (24-bit) $str = StringRegExpReplace($str, $sESC & "\[(38|48);2;([0-1]?\d?\d|(0|2)[0-5][0-5]);([0-1]?\d?\d|(0|2)[0-5][0-5]);([0-1]?\d?\d|(0|2)[0-5][0-5])m", "") Return $str EndFunc ;==>__SanitizeOutput Func __PSCP_Execute($sCommand) Local $sStdoutRead, $sData, $error1, $error2 Local $PSCP_PID = Run($Path_PSCP_EXE & ' ' & $sCommand, '', @SW_HIDE, 7) ConsoleWrite('> __PSCP_Execute [' & $PSCP_PID & ']: ' & $sCommand & @CRLF) Sleep(250) While True Sleep(100) $sStdoutRead = StdoutRead($PSCP_PID) $error1 = @error ;If $error Then ExitLoop If $sStdoutRead <> '' Then $sData &= $sStdoutRead $sStdoutRead = '' $sStdoutRead = StderrRead($PSCP_PID) $error2 = @error If $error2 And $error2 Then ExitLoop If $sStdoutRead <> '' Then $sData &= $sStdoutRead $sStdoutRead = '' $error1 = '' $error2 = '' ;ConsoleWrite($sData & @CRLF) WEnd Return __SanitizeOutput($sData) EndFunc ;==>__PSCP_Execute > Any suggestions and contributions are welcome!
-
- _ssh_getfile
- _ssh_getfolder
-
(and 3 more)
Tagged with:
-
Help needed search for PowerPoint slides - (Moved)
spudw2k replied to MDP's topic in AutoIt General Help and Support
If you restructure / relabel the slides, might make your problem easier to solve. e.g. Verse 1 Verse 1 Chorus 1 Chorus 1 Verse 2 Verse 2 Chorus 2 Chorus 2 Verse 3 Verse 3 Chorus 3 Chorus 3 -
Well, I've wasted enough time on this myself so I thought I would reach out for help. I'm sure the solution is simple; I'm just overlooking it. I want to search through a group of PowerPoint music slides and copy out certain song numbers and verses with their corresponding chorus. The verse number can vary (for example song number 500 verses 1 and 3). Verses may take up more than a single slide and choruses follow the verses and may take up more than a single slide. I have the search working... it finds the slide number... then finds the verses but I only want to copy the chorus for the selected verses. My code currently grabbing all the chorus slides, which I don't want. I can't seem to figure this part out. So, here is an example. Slide set: Verse 1 Verse 1 Chorus Chorus Verse 2 Verse 2 Chorus Chorus Verse 3 Verse 3 Chorus Chorus So, if I search for verses 1 and 3, I want this to be my results. (Verse 2 slides are their chorus are skipped) Verse 1 Verse 1 Chorus Chorus Verse 3 Verse 3 Chorus Chorus I'm looking for a strategy or algorithm for doing this type of search. I hope this makes sense.
-
maybe this ? Func something() Switch $22 Case $aaa, $bbb, $ccc, $ddd, $eee ; lines of code here, common to $aaa, $bbb, $ccc, $ddd, $eee then... If $22 = $ccc Or $22 = $ddd Then ContinueCase Case $hhh ; moved here to allow the previous ContinueCase ; lines of code executed when $22 = $ccc or $ddd or $hhh Case $fff Case $ggg Case $iii EndSwitch EndFunc
-
Global $aaa, $bbb, $ccc, $ddd, $eee, $fff, $ggg, $hhh, $iii, $22 $ccc = "$ccc" $hhh = "$hhh" $22 = $ccc ConsoleWrite("$22=" & $22 & @CRLF) something() ConsoleWrite("$22=" & $22 & @CRLF) func something() switch $22 case $aaa, $bbb, $ccc, $ddd, $eee ConsoleWrite(" 1 $22=" & $22 & @CRLF) switch $22 case $ccc, $ddd $22 = $hhh ConsoleWrite(" 2 $22=" & $22 & @CRLF) Return something() endswitch case $fff case $ggg case $hhh ;Something else here $22 = "Something else here" ConsoleWrite(" 3 $22=" & $22 & @CRLF) case $iii endswitch Endfunc After a second (or even third) look, this seems like a safer approach to me. Global $aaa, $bbb, $ccc, $ddd, $eee, $fff, $ggg, $hhh, $iii, $22 $ccc = "Value of ccc" $hhh = "Value of hhh" $22 = $ccc ConsoleWrite("$22=" & $22 & @CRLF) something() ConsoleWrite("$22=" & $22 & @CRLF) Func something() Local $bOneMoreTime = True While $bOneMoreTime $bOneMoreTime = False Switch $22 Case $aaa, $bbb, $ccc, $ddd, $eee ConsoleWrite(" 1 $22=" & $22 & @CRLF) Switch $22 Case $ccc, $ddd $22 = $hhh ConsoleWrite(" 2 $22=" & $22 & @CRLF) $bOneMoreTime = True EndSwitch Case $fff Case $ggg Case $hhh $22 = "Something else here" ConsoleWrite(" 3 $22=" & $22 & @CRLF) Case $iii EndSwitch WEnd EndFunc
-
I'm trying to jump to a case if certain conditions are met in a preceding case. I tried coding it like the example below, but it doesn't work. It works up to "case $ccc, $ddd" but it doesn't then jump to "case $hhh". Is there some way to accomplish this? func something() switch $22 case $aaa, $bbb, $ccc, $ddd, $eee switch $22 case $ccc, $ddd $22 = $hhh endswitch case $fff case $ggg case $hhh ;Something else here case $iii endswitch Endfunc
- Yesterday
-
RegEx a function with its parameters
argumentum replied to argumentum's topic in AutoIt General Help and Support
...I update a lot. Please refresh the page every so often if replying . -
RegEx a function with its parameters
argumentum replied to argumentum's topic in AutoIt General Help and Support
; looking to discern the parameters with RegExp ConsoleWriteDebug(anyFunc(' ;''1''', "2""", @ScriptLineNumber) & @CRLF, 3) ; don't add @ScriptLineNumber ConsoleWriteDebug(anyFunc(' ;''1''', "2""", @ScriptLineNumber) & @CRLF) ; add @ScriptLineNumber ConsoleWriteDebug('This, is'' a string' & @CRLF) ; add @ScriptLineNumber ConsoleWriteDebug("This, ;is' a string" & @CRLF) ; add @ScriptLineNumber ConsoleWriteDebug('This, ;is'' a string' & @CRLF, @ScriptLineNumber) ; don't add @ScriptLineNumber ConsoleWriteDebug("This, is' a string" & @CRLF, 88, 1, 2) ; don't add @ScriptLineNumber ;~ ConsoleWriteDebug("This is' a string" & @CRLF, @ScriptLineNumber, 1, 2) ; don't touch Local $sString = "This is' a string" ConsoleWriteDebug($sString & @CRLF, 11) ; don't add @ScriptLineNumber ConsoleWriteDebug($sString, 12) ; don't add @ScriptLineNumber ConsoleWriteDebug($sString) ; add @ScriptLineNumber ConsoleWriteDebug($sString & @CRLF) ; add @ScriptLineNumber ConsoleWrite(@CRLF & _Add_ScriptLineNumber(FileRead(@ScriptFullPath)) & @CRLF) Func _Add_ScriptLineNumber($sScript) ; , $sFuncName = "ConsoleWriteDebug", $iAddAtParameterNumber = 2) Local $aRegex, $iPos, $aScript = StringSplit($sScript, @CRLF, 1) $sScript = "" Local $i_Base, $i_apostrophe_1, $i_quotation_1, $i_comma_1 For $n = 1 To UBound($aScript) - 1 If StringInStr($aScript[$n], 'Func ConsoleW' & 'riteDebug(') Or _ Not StringInStr($aScript[$n], 'ConsoleW' & 'riteDebug(') Or _ StringInStr($aScript[$n], ';') < StringInStr($aScript[$n], 'ConsoleW' & 'riteDebug(') Then $sScript &= $aScript[$n] & @CRLF ContinueLoop EndIf ConsoleWrite('=== === === === === === === === === === === === === === === === ' & @CRLF) $aRegex = StringRegExp($aScript[$n], 'ConsoleW' & 'riteDebug\(.*\)', 1) For $m = 0 To UBound($aRegex) - 1 ConsoleWrite('@@ $aRegex (' & @ScriptLineNumber & ') : [' & $m & '] >' & $aRegex[$m] & '<' & @CRLF) Next If UBound($aRegex) <> 1 Then $sScript &= $aScript[$n] & ' ;;; skipped 4 ;;;' & @CRLF ConsoleWrite('> skipped' & @CRLF) ContinueLoop EndIf If StringInStr($aRegex[0], "ConsoleW' & 'riteDebug($") Then ; on variable If StringInStr($aRegex[0], ",") Then $sScript &= $aScript[$n] & ' ;;; skipped 3 ;;;' & @CRLF ConsoleWrite('> skipped 3' & @CRLF) Else $sScript &= StringReplace($aScript[$n], $aRegex[0], StringTrimRight($aRegex[0], 1) & ', @ScriptLineNumber)') & " ;;; DONE 3 ;;;" & @CRLF ConsoleWrite('> DONE 3' & @CRLF) EndIf ContinueLoop EndIf If StringInStr($aRegex[0], ")", 0, -2) Then ; on function If StringInStr($aRegex[0], ",", 0, -1) > StringInStr($aRegex[0], ")", -2) Then $sScript &= $aScript[$n] & ' ;;; skipped 4 ;;;' & @CRLF ConsoleWrite('> skipped 4' & @CRLF) Else $sScript &= StringReplace($aScript[$n], $aRegex[0], StringTrimRight($aRegex[0], 1) & ', @ScriptLineNumber)') & " ;;; DONE 4 ;;;" & @CRLF ConsoleWrite('> DONE 4' & @CRLF) EndIf ContinueLoop EndIf $sRegex = StringTrimRight(StringReplace($aRegex[0], 'ConsoleW' & 'riteDebug(', ''), 1) $sSpecialChr = StringLeft($sRegex, 1) $aStringSplitSV = _StringSplitSV($sRegex, ",", $sSpecialChr) ;~ For $m = 0 To UBound($aStringSplitSV) - 1 ;~ ConsoleWrite('@@ SplitSV (' & @ScriptLineNumber & ') : [' & $m & '] >' & $aStringSplitSV[$m] & '<' & @CRLF) ;~ Next If UBound($aStringSplitSV) = 1 Then Switch $sSpecialChr Case '"', "'" $sScript &= StringReplace($aScript[$n], $aRegex[0], 'ConsoleW' & 'riteDebug(' & $aStringSplitSV[0] & ', @ScriptLineNumber)') & " ;;; DONE 1 ;;;" & @CRLF ConsoleWrite('> DONE 1' & @CRLF) Case Else $sScript &= $aScript[$n] & ' ;;; need to discern ;;;' & @CRLF ConsoleWrite('> need to discern' & @CRLF) EndSwitch ElseIf UBound($aStringSplitSV) > 1 Then $sScript &= $aScript[$n] & ' ;;; skipped 2 ;;;' & @CRLF ConsoleWrite('> skipped 2' & @CRLF) Else $sScript &= $aScript[$n] & ' ;;; no clue ;;;' & @CRLF ConsoleWrite('> no clue' & @CRLF) EndIf Next ConsoleWrite('=== === === === === === === === === === === === === === === === finished.' & @CRLF) Return $sScript ; with the added ", @ScriptLineNumber)" where needed EndFunc ;==>_Add_ScriptLineNumber Func ConsoleWriteDebug($sStr = @CRLF, $iLine = @ScriptLineNumber, $iError = @error, $iExtended = @extended) Local $iRet = ConsoleWrite("@@ Debug (" & $iLine & ") : " & $sStr & (StringRight($sStr, 2) = @CRLF ? "" : @CRLF)) Return SetError($iError, $iExtended, $iRet) ; https://www.autoitscript.com/forum/topic/139260-autoit-snippets/?do=findComment&comment=1538974 EndFunc ;==>ConsoleWriteDebug Func anyFunc($1 = "", $2 = "", $3 = "") Return 'anyFunc' & $1 & $2 & $3 EndFunc ;==>anyFunc Func _StringSplitSV($sString, $sSepChr = ",", $sSpecialChr = '"') ; https://www.autoitscript.com/forum/topic/105756-string-split-escapeignore-quoted-delimiters/?do=findComment&comment=747333 Return StringRegExp($sString, "\G(?:\Q" & $sSepChr & "\E|^)((?>[^\Q" & $sSepChr & $sSpecialChr & "\E]*(?:" & $sSpecialChr & "[^\Q" & $sSpecialChr & "\E]*" & $sSpecialChr & ")?)+)", 3) EndFunc ;==>_StringSplitSV ok, this does it. If any one can either brake it or make it better, post -
How to do StringRegExpReplace in my example?
Nine replied to HezzelQuartz's topic in AutoIt General Help and Support
As @Musashi said, there is not blank line at the end beside the fact that the last line : 0000287B: 80 00 Is also finished by @CRLF like all the others before. If you don't want it just use StringStripWS and remove those trailing characters. -
@CYCho today I was able to test your 1st script at my brother's home (Win11 x64) Here is the display on his computer, using charset 129 : ... _GUICtrlRichEdit_SetFont($hRichEdit, 14, "Arial", 129) ; $HANGEUL_CHARSET = 129 _GUICtrlRichEdit_AppendText($hRichEdit, @CRLF & "1. This is text" & @CRLF & "2. ▶/❚❚ This is more text") ... So the 2nd "This is more text" appears bolder compared to the 1st one (as you noticed) IIRC charset 130 (the Korean $JOHAB_CHARSET) displayed same as 129 And when no charset parameter was set, then both "This is more text" looked same. For what it's worth...
-
How to do StringRegExpReplace in my example?
Musashi replied to HezzelQuartz's topic in AutoIt General Help and Support
(Aside : my console output is identical to @Nine 's.) However, as soon as you write the output to a file, there is one (not two as in your case) blank line. This is comprehensible, as the last line does fulfill the RegEx pattern and is therefore replaced by “”. I would prefer the array variant (as already suggested by Nine) - this provides more flexible access to the individual elements. -
RegEx a function with its parameters
argumentum replied to argumentum's topic in AutoIt General Help and Support
; looking to discern the parameters with RegExp ConsoleWriteDebug(anyFunc(' ''1''', "2""", @ScriptLineNumber) & @CRLF) ; add @ScriptLineNumber ConsoleWriteDebug('This, is'' a string' & @CRLF) ; add @ScriptLineNumber Func anyFunc($1 = "", $2 = "", $3 = "") Return 'anyFunc' & $1 & $2 & $3 EndFunc ;==>anyFunc Nice @ioa747. I bet you removed anyFunc() because it wasn't there ( in the 1st post ), or didn't refresh this posting's page. In any case, in a ConsoleWrite() when you run a function inside and you'd wanna see the function's output your current code brakes the output script. I do that ( run func() inside a ConsoleWrite() ) a lot. I was adding stuff as I went along, looking to brake the code with less than ideal circumstances, like having commas or parenthesis or some other character that would confuse the function that adds the @ScriptLineNumber to the script.