boniakowski Posted May 12, 2021 Share Posted May 12, 2021 (edited) Hello everyone, I have already read about 50 pages and I cannot find the solution to my question. I need to read a cmd window that is permanently updating data that originally runs from a batch file. It must always read the information that is updated until a line with certain specific information appears, for example: [10:46:51] INFO - ======================== Summary 2021-05-12 10:46:51 ======================== [10:46:51] INFO - |ID|Device|Hashrate|Accept|Reject|Inv|Powr|Temp|Fan|CClk|GMClk|MUtl|Eff/Watt| [10:46:51] INFO - | 0|1050ti| 6.144 M| 34860| 259| 0| 0| 78| 84|1620| 3605| 100| 0.000 | [10:46:51] INFO - |------------------+------+------+---+----+---------------------------------| [10:46:51] INFO - | Total: 6.144 M| 34860| 259| 0| 0| Uptime: 4D 12:57:45 CPU: 35% | [10:46:51] INFO - ============================================================================= [10:46:51] INFO - kawpow - On Pool 10m: 7.502 M 4h: 5.957 M 24h: 5.920 M [10:46:53] INFO - kawpow - #34861 Share accepted, 287 ms. [DEVICE 0, #34861] [10:46:57] INFO - kawpow - #34862 Share accepted, 283 ms. [DEVICE 0, #34862] [10:47:04] INFO - kawpow - #34863 Share accepted, 302 ms. [DEVICE 0, #34863] [10:47:05] INFO - kawpow - New job: eu.ravenminer.com:3838, ID: 726f, HEIGHT: 1750812, DIFF: 58.54M [10:47:05] INFO - Generate new CUDA kernel [583605]. this example its a GPU mining, but its for something similar. and when a line appears that says overclocking somewhere, a specific action is triggered such as restarting the computer. I've already read StdOutRead but I don't want to run the batch file from Run(@ComSpec & " /c, etc ...............) I just need to read from an already running window and perform the action. Give me a hand? Thank you Edited May 12, 2021 by boniakowski Link to comment Share on other sites More sharing options...
Developers Jos Posted May 12, 2021 Developers Share Posted May 12, 2021 Have you checked these commands in the Helpfile and their examples?: Run() StdoutRead() StderrRead() Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
boniakowski Posted May 12, 2021 Author Share Posted May 12, 2021 4 minutes ago, Jos said: Have you checked these commands in the Helpfile and their examples?: Run() StdoutRead() StderrRead() Jos Yes, but i want to use Run for the batch file, and i dont understand how to use PID y if i not use Run command. i need to read an open external window. thks for your answer and help. Link to comment Share on other sites More sharing options...
Developers Jos Posted May 12, 2021 Developers Share Posted May 12, 2021 What is the issue with running it via a batch file? Should work fine as long as the batchfile remains running and doesn't shell the program and exit. ...so .... we need more details and your current script you tried that isn't working .... and tell use what happens. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
boniakowski Posted May 12, 2021 Author Share Posted May 12, 2021 1 hour ago, Jos said: What is the issue with running it via a batch file? Should work fine as long as the batchfile remains running and doesn't shell the program and exit. ...so .... we need more details and your current script you tried that isn't working .... and tell use what happens. Jos I appreciate your help, I really don't want them to do things for me, but I haven't used autoit for more than 4 years and I've forgotten a lot of things, I'm not a programmer, I do it as a hobby. The theme is like this: I have a miner that runs a .bat at the start of windows, I can safely run it through autoit, but I wanted to learn how to get a window already open. well let's continue ... in the miner the information is constantly appearing that is updated second by second, but I have had some problems with one of my plates and it gives me an overclock error, so ... at that moment the error appears I I need the pc to reboot. the issue is that I don't remember how to read an already open cmd window and go looking for that information. I apologize for not being very clear perhaps, but I really do not remember how to do some things that for the more experienced should be very very simple. Thank you. Link to comment Share on other sites More sharing options...
argumentum Posted May 12, 2021 Share Posted May 12, 2021 and what if the overclocking messes with the CUDA cores and you only find that something is wrong when it crashes but meanwhile, the GPU was not calculating good hashes anyway !. Don't over-over-clock. It'll be better than rebooting. ( my 2 cents., I don't mine ) Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
boniakowski Posted May 12, 2021 Author Share Posted May 12, 2021 16 minutes ago, argumentum said: and what if the overclocking messes with the CUDA cores and you only find that something is wrong when it crashes but meanwhile, the GPU was not calculating good hashes anyway !. Don't over-over-clock. It'll be better than rebooting. ( my 2 cents., I don't mine ) yes its right, but i dont over clock my gpus, but in some moment the miner crash, its not all the time, maybe one time on a week, but always do that when i ám in my job and i´ll take some hours to reboot them. sometimes i can reboot with teamviewer, but if the cpu its freezed. i cant do nothing. i prefer one script monitoring and as soon as it happens, take action for me. argumentum 1 Link to comment Share on other sites More sharing options...
robertocm Posted May 12, 2021 Share Posted May 12, 2021 ;Nine, Dec 5 2020 ;https://www.autoitscript.com/forum/topic/204575-script-to-paste-text-into-windows-cmd/?do=findComment&comment=1470232 Global $sText, $hDOS = WinGetHandle("[CLASS:ConsoleWindowClass]") If $hDOS Then ;https://stackoverflow.com/questions/11543578/copy-text-from-a-windows-cmd-window-to-clipboard ClipPut("echo help|clip") ControlSend($hDOS, "", "", ClipGet() & @CRLF) ControlSend($hDOS, "", "", "dir|clip" & @CRLF) $sText = ClipGet() MsgBox(0, "", $sText) ;This doesn't seem to work: ;$sText = WinGetText($hDOS) Else Exit MsgBox(0, "", "Console not found") EndIf Link to comment Share on other sites More sharing options...
JockoDundee Posted May 12, 2021 Share Posted May 12, 2021 54 minutes ago, boniakowski said: the issue is that I don't remember how to read an already open cmd window and go looking for that information. what process opened the command window in the first place? Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
boniakowski Posted May 12, 2021 Author Share Posted May 12, 2021 12 minutes ago, JockoDundee said: what process opened the command window in the first place? The precess in this case es "NBminer.exe" Link to comment Share on other sites More sharing options...
argumentum Posted May 12, 2021 Share Posted May 12, 2021 Global $sText, $hDOS = WinGetHandle("[CLASS:ConsoleWindowClass]") If $hDOS Then ;~ ;https://stackoverflow.com/questions/11543578/copy-text-from-a-windows-cmd-window-to-clipboard ;~ ClipPut("echo help|clip") ;~ ControlSend($hDOS, "", "", ClipGet() & @CRLF) ;~ ControlSend($hDOS, "", "", "dir|clip" & @CRLF) ;~ $sText = ClipGet() ;~ MsgBox(0, "", $sText) ;~ ;This doesn't seem to work: ;~ ;$sText = WinGetText($hDOS) ControlSend($hDOS, "", "", "^a" & @CRLF) ControlSend($hDOS, "", "", "^c" & @CRLF) MsgBox(0, "", ClipGet()) Else Exit MsgBox(0, "", "Console not found") EndIf see if that does it. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
JockoDundee Posted May 12, 2021 Share Posted May 12, 2021 46 minutes ago, argumentum said: see if that does it. What are the @CRLFs for? Maybe a sleep(100) after the ^c to make sure? Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
argumentum Posted May 12, 2021 Share Posted May 12, 2021 ..did not pay much attention when I edited the code. Is not needed. JockoDundee 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
JockoDundee Posted May 12, 2021 Share Posted May 12, 2021 53 minutes ago, argumentum said: Is not needed. Ah, I see them now in the original code. I’m just so used to everything you write being sui generis... Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now