tbodine88 Posted April 2, 2009 Posted April 2, 2009 I am writing a script to read the contents of a cmd window. expandcollapse popup#include <Misc.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> Global $title = "" Global $targetid = 0 Global $winX Global $winY Global $lastCutTime Global $nextCutTime ;-------------------------------------------------------------------------- ; Changes the Target Window ; Output: $title, $tagetid ;-------------------------------------------------------------------------- Func changeTarget() $title = IniRead(@ScriptDir & "\wintitle.ini", "Main", "WinTitle", "none") $targetid = WinGetHandle($title) EndFunc ;==>changeTarget ;---------------------------------------------------------------------------- ; CutPaste ; Copies the whole PCSP window to $text ; $lastText gets the old value of $text ; ; Input: ; $targetid ; Output: ; $text ; $lastText ; $lastCutTime ; $nextCutTime ; $needPageDown ;---------------------------------------------------------------------------- Func CutPaste() Local $_Wintitle Local $mm = AutoItSetOption("MouseCoordMode", 0) $_Wintitle = _WinAPI_GetWindowText($targetid) WinWait($_Wintitle, "") If Not WinActive($_Wintitle, "") Then WinActivate($_Wintitle, "") WinWaitActive($_Wintitle, "") MouseMove(20, 13) MouseDown("main") MouseUp("main") MouseMove(20, 187) MouseMove(140, 187) Sleep(100) MouseMove(157, 187) MouseDown("main") MouseUp("main") MouseMove(7, 30) MouseDown("main") MouseMove(797, 449) MouseUp("main") Send("{ENTER}") $lastText = $text $text = ClipGet() $lastCutTime = @HOUR * 3600 + @MIN * 60 + @SEC $nextCutTime = $lastCutTime + $delay $needPageDown = True AutoItSetOption("MouseCoordMode", $mm) EndFunc ;==>CutPaste changeTarget() $delay = 5 for $i = 1 to 22 CutPaste() Filewrite("Screen.txt",$text) next It was working until I wrote a script to invoke this code multiple times rapidly within a minute. Rebooting doesn't fix the problem. BTW cutting and pasting from the CMD window to a notepad manually continues to work fine. 1. How can I fix this? 2. How can I avoid this happening in the future ? Thanks
reb Posted April 2, 2009 Posted April 2, 2009 Does your program work if you exit your program then re-run it? I had the same problem but it would work as above. if your program works as described I can tell you how I solved my delema. REB MEASURE TWICE - CUT ONCE
tbodine88 Posted April 3, 2009 Author Posted April 3, 2009 Does your program work if you exit your program then re-run it?I had the same problem but it would work as above.if your program works as described I can tell you how I solved my delema.REBWell it worked at when I was in the office now It doesn't. Rebooting the PLC and the compouter has no effect.
reb Posted April 3, 2009 Posted April 3, 2009 I think we share a similar problem. What I had to do was move my code (similar to your Func CutPaste()) to a different program then run it multiple times (Run(@WorkingDir & "\your prog name.exe") . It can be called multiple times and should work every time. I use this to do text to speech in my E-Sword Bible. Regards REB MEASURE TWICE - CUT ONCE
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