GEOSoft Posted January 31, 2010 Share Posted January 31, 2010 (edited) This one worked but the lines from from.txt, are 1 line over the to.txt gotta add enter? and can you do it will delete the 8 that just copied from "from.txt" so if you repeat it the next 8 will be new lines Not sure what you mean here but try this $aText = StringRegExp(FileRead("from.txt"), "(?i)(.+)(?:\v)+", 3) If NOT @Error Then $sStr = "" For $i = 0 To Ubound($aText) -1 $sStr &= $aText[$i] & @CRLF If $i = 7 Then ExitLoop ;; Adjust the number of lines here >> Desired number of lines -1 Next $hFile = FileOpen("to.txt", 2) FileWrite($hFile, StringStripWS($sStr, 2)) FileClose($hFile) EndIf Edited January 31, 2010 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
JohnOne Posted January 31, 2010 Share Posted January 31, 2010 Gives this error_FileWriteToLine($Sourcefile, 1, "", 1)^ ERRORAdd this to top of script#include <File.au3> AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
voidale Posted January 31, 2010 Author Share Posted January 31, 2010 well wow guys everyone thanks alot for the help This code works perfect #include <File.au3> Local $Sourcefile = "from.txt" Local $destinationfile = "to.txt" Local $aFileLines[9] For $i = 1 To 8 $read = FileReadLine($Sourcefile,$i) $aFileLines[$i] = $read Next For $x=1 To 8 _FileWriteToLine($Sourcefile, 1, "", 1) Next For $i = 1 To 8 FileWriteLine($destinationfile,$aFileLines[$i]) Next Link to comment Share on other sites More sharing options...
czardas Posted January 31, 2010 Share Posted January 31, 2010 (edited) ---- ORIGINAL CODE DELETED ---- Improved version: #include <File.au3> $countLines = _FileCountLines("to.txt") While 1 For $x = 1 To 8 If $countLines = 0 Then ExitLoop 2 EndIf $ReadLine=FileReadLine("to.txt", 1) _FileWriteToLine("to.txt", 1, "", 1) FileWriteLine("output.txt", $ReadLine) $countLines -= 1 Next MsgBox(0, "Transfer Info", "8 lines transferred successfully." & @CRLF & "Click ok to continue.") WEnd MsgBox(0, "Finished", "Exact copy of original file completed" & @CRLF & "8 lines at a time.") I'm not really sure what exactly you are trying to do, but maybe this helps. Edited January 31, 2010 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
voidale Posted January 31, 2010 Author Share Posted January 31, 2010 (edited) having hard time with ControlClick now this is the code Run("File.exe") WinWait("File", "File") If Not WinActive("File", "File") Then WinActivate("file", "File") ControlClick("File", "File", "Button4") it opens the exe and takes a focus fine but it won't click Buttun4 (Got it using the info tool) any ideas? Edited January 31, 2010 by voidale Link to comment Share on other sites More sharing options...
voidale Posted January 31, 2010 Author Share Posted January 31, 2010 having hard time with ControlClick now this is the code Run("File.exe") WinWait("File", "File") If Not WinActive("File", "File") Then WinActivate("file", "File") ControlClick("File", "File", "Button4") it opens the exe and takes a focus fine but it won't click Buttun4 (Got it using the info tool) any ideas? still can't figure out how to make it work ;s Link to comment Share on other sites More sharing options...
NerdFencer Posted January 31, 2010 Share Posted January 31, 2010 Here is a function that does the move simply with error checking... Just stick it in and it'll work. Func Move_lines() Local $from = StringSplit(FileRead("from.txt"),@CRLF,1) For $i=1 To _lower(8,$from[0]) FileWriteLine("to.txt",$from[$i]) Next If $from[0]>8 Then FileDelete("from.txt") For $i=9 To $from[0] FileWriteLine("from.txt",$from[$i]) Next Else FileWrite("from.txt","") EndIf EndFunc Func _lower($a,$b) If $a<$b Then Return $a Return $b EndFunc _________[u]UDFs[/u]_________-Mouse UDF-Math UDF-Misc Constants-Uninstaller Shell Link to comment Share on other sites More sharing options...
voidale Posted February 1, 2010 Author Share Posted February 1, 2010 still can't figure out how to make it work ;sPlease guys any idea about the control click it won't work for me Link to comment Share on other sites More sharing options...
somdcomputerguy Posted February 1, 2010 Share Posted February 1, 2010 Sometimes ControlClick won't work, although it usually does on an unactivated app, so it surely should on an activated one.. Try a MouseClick at the right coords.. And post the InfoTool output too so it can be read by others here.. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
NerdFencer Posted February 1, 2010 Share Posted February 1, 2010 If you are going to click coordinates, then make sure that you are using coordinates relative to the window position (WinGetPos) so that it is independent of screen resolution. _________[u]UDFs[/u]_________-Mouse UDF-Math UDF-Misc Constants-Uninstaller Shell Link to comment Share on other sites More sharing options...
voidale Posted February 1, 2010 Author Share Posted February 1, 2010 Here is the window info trying to get a click over button4 >>>> Window <<<< Title: Vista V1.3 Class: WindowsForms10.window.8.app.0.378734a Position: 90, 90 Size: 905, 589 Style: 0x16CF0000 ExStyle: 0x00050100 Handle: 0x00000000000106A8 >>>> Control <<<< Class: WindowsForms10.BUTTON.app.0.378734a Instance: 3 ClassnameNN: WindowsForms10.BUTTON.app.0.378734a3 Name: Button4 Advanced (Class): [NAME:Button4] ID: 67282 Text: SEND Position: 684, 58 Size: 195, 55 ControlClick Coords: 57, 38 Style: 0x5601000B ExStyle: 0x00000000 Handle: 0x00000000000106D2 >>>> Mouse <<<< Position: 840, 222 Cursor ID: 0 Color: 0xD8D8D8 don't really find simple examples to use WinGetPos this is what i got so far $size = WinGetPos("[Vista V1.3]") MsgBox(0, "Active window stats (x,y,width,height):", $size) (send a msg box with 0 MouseClick("left", $size, 1) this will be the correct cords? Link to comment Share on other sites More sharing options...
voidale Posted February 1, 2010 Author Share Posted February 1, 2010 Here is the window info trying to get a click over button4 >>>> Window <<<< Title: Vista V1.3 Class: WindowsForms10.window.8.app.0.378734a Position: 90, 90 Size: 905, 589 Style: 0x16CF0000 ExStyle: 0x00050100 Handle: 0x00000000000106A8 >>>> Control <<<< Class: WindowsForms10.BUTTON.app.0.378734a Instance: 3 ClassnameNN: WindowsForms10.BUTTON.app.0.378734a3 Name: Button4 Advanced (Class): [NAME:Button4] ID: 67282 Text: SEND Position: 684, 58 Size: 195, 55 ControlClick Coords: 57, 38 Style: 0x5601000B ExStyle: 0x00000000 Handle: 0x00000000000106D2 >>>> Mouse <<<< Position: 840, 222 Cursor ID: 0 Color: 0xD8D8D8 don't really find simple examples to use WinGetPos this is what i got so far $size = WinGetPos("[Vista V1.3]") MsgBox(0, "Active window stats (x,y,width,height):", $size) (send a msg box with 0 MouseClick("left", $size, 1) this will be the correct cords? Anyone? Link to comment Share on other sites More sharing options...
JohnOne Posted February 1, 2010 Share Posted February 1, 2010 this will be the correct cords?NoBecause wingetpos returns a 2 dimansional array AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
voidale Posted February 2, 2010 Author Share Posted February 2, 2010 NoBecause wingetpos returns a 2 dimansional arraydo you know the code? Link to comment Share on other sites More sharing options...
somdcomputerguy Posted February 2, 2010 Share Posted February 2, 2010 The example here knows - Function WinGetPos - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
voidale Posted February 2, 2010 Author Share Posted February 2, 2010 The example here knows - Function WinGetPosno idea how to use it, im sorry if it's noob question ;s Link to comment Share on other sites More sharing options...
somdcomputerguy Posted February 2, 2010 Share Posted February 2, 2010 MouseClick("left", $size[0], $size[1]) - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
voidale Posted February 2, 2010 Author Share Posted February 2, 2010 MouseClick("left", $size[0], $size[1]) $size = WinGetPos("[Vista V1.3]") MouseClick("left", $size[0], $size[1]) Subscript used with non-Array variable.: MouseClick("left", $size[0], $size[1]) MouseClick("left", $size^ ERROR Link to comment Share on other sites More sharing options...
whim Posted February 2, 2010 Share Posted February 2, 2010 'Subscript used with non-Array variable' means your WinGetPos failed ... Maybe you've specified the wrong Window title ? >>>> Window <<<< Title: Vista V1.3 Class: WindowsForms10.window.8.app.0.378734a Position: 90, 90 Size: 905, 589 Style: 0x16CF0000 ExStyle: 0x00050100 Handle: 0x00000000000106A8try $size = WinGetPos("Vista V1.3") ; check for failure If Not $size = 0 Then MouseClick("left", $size[0], $size[1]) Else MsgBox(0, "error", "WinGetPos Error !") EndIf HTH, whim Link to comment Share on other sites More sharing options...
somdcomputerguy Posted February 2, 2010 Share Posted February 2, 2010 (edited) That should work. The square brackets in the title are causing the error, because wingetpos fails. Edited February 2, 2010 by snowmaker - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. 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