LukeJrs Posted August 22, 2007 Share Posted August 22, 2007 Okie here my Work so far. CODE Send("!{PRINTSCREEN}") ShellExecute ("wordpad.exe" , "" , "" , "", @SW_HIDE) Sleep(1000) ControlSend("Document", "", "RICHEDIT50W1", "This is a line of text in the notepad window") ControlSend("Document", "", "RICHEDIT50W1", ("^{v}")) Sleep(1000) WinSetState("Document -", "", @SW_SHOW It Open words and write and also paste a picture and now i need to save it automaticly like filewrite does how can it be done? I tried filesavedialog no good unless im using it wrong.. The thing is the wordpad executable is .rtf CODE $file = FileOpen("test.rtf", 1) ; Check if file opened for writing OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf FileWrite($file, "Line1") FileWrite($file, "Still Line1" & @CRLF) FileWrite($file, "Line2") FileClose($file) HOW can I save image inside that test.rtf automaticly using paste etc? Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 22, 2007 Share Posted August 22, 2007 Okie here my Work so far. It Open words and write and also paste a picture and now i need to save it automaticly like filewrite does how can it be done? I tried filesavedialog no good unless im using it wrong.. The thing is the wordpad executable is .rtf HOW can I save image inside that test.rtf automaticly using paste etc? Like this: expandcollapse popup$sFile = 'Test_ScreenShot.rtf' $sFilePath = @ScriptDir & '\' & $sFile ; Get screen shot Send("!{PRINTSCREEN}") ; Run wordpad ShellExecute("wordpad.exe", "", "", "", @SW_SHOW) WinWait("Document - ") WinActivate("Document - ") WinWaitActive("Document - ") ; Paste text ControlSend("Document", "", "RICHEDIT50W1", "This is a line of text in the notepad window") ControlSend("Document", "", "RICHEDIT50W1", ("^{v}")) Sleep(1000) ; Save file ControlSend("Document", "", "", "!f") ; File Sleep(500) ControlSend("Document", "", "", "a") ; Save As WinWait("Save As") WinActivate("Save As") WinWaitActive("Save As") ControlSend("Save As", "", "Edit1", $sFilePath) ; File Name Sleep(500) ControlSend("Save As", "", "", "!s") ; Save Sleep(1000) ; Watch for overwrite dialog While 1 If WinExists("Save As", "already exists") Then ControlSend("Save As", "already exists", "", "!y") ; Yes to overwrite Sleep(1000) If Not WinExists("Save As") Then ExitLoop WEnd ; Close wordpad WinWait($sFile & " - WordPad") WinActivate($sFile & " - WordPad") WinWaitActive($sFile & " - WordPad") ControlSend($sFile & " - WordPad", "", "", "!f") ; File Sleep(500) ControlSend($sFile & " - WordPad", "", "", "x") ; Exit You can fancify it using more in-depth control manipulation, but that gets the basics. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
LukeJrs Posted August 22, 2007 Author Share Posted August 22, 2007 (edited) thanks for your help What if I wanted modified existen wordpad files and open it add more txt and picture? FileOpen? I also notice this method doesn't work in SW_HIDE tried many can't really get this working on hide Edited August 22, 2007 by LukeJrs Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 22, 2007 Share Posted August 22, 2007 thanks for your help What if I wanted modified existen wordpad files and open it add more txt and picture? FileOpen?I also notice this method doesn't work in SW_HIDE tried many can't really get this working on hideIt's there for you to modify as required. Look more closely at ShellExecute() in the help file. If you are opening an existing file, pass the filename in double quotes as the parameter, and "Open" as the verb.Since all the simulated actions use ControlSend(), it might work while hidden, I'm not sure. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law 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