FREE0N Posted yesterday at 10:31 AM Share Posted yesterday at 10:31 AM expandcollapse popup#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, "") Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted yesterday at 10:40 AM Moderators Share Posted yesterday at 10:40 AM FREE0N, Welcome to the AutoIt forums. This script appears to me to be automating a game server (Steam) - is that indeed the case? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
FREE0N Posted yesterday at 10:58 AM Author Share Posted yesterday at 10:58 AM 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. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted yesterday at 11:31 AM Moderators Share Posted yesterday at 11:31 AM FREEON, Quote Yes it is necessary for playing cs2. 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 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts