6 Replies - 2619 Views - Last Post: 09 July 2010 - 12:23 PM Rate Topic: -----

#1 navr91  Icon User is offline

  • New D.I.C Head

Reputation: 6
  • View blog
  • Posts: 44
  • Joined: 12-July 09

Write to an Open (unsaved) Text File

Posted 08 July 2010 - 12:30 PM

So I want my program to open up an empty notepad window, and then fill it in and let the user save it as whatever they want. Is this possible in VB .NET, and if so, do you have any pointers?

Note: I don't want to save to write to a file and then save it. I know how to do that. I want to write to a notepad window (an unsaved file).

I hope this makes sense and I hope it's possible. Thanks for your help as always!
Is This A Good Question/Topic? 0
  • +

Replies To: Write to an Open (unsaved) Text File

#2 Jack Eagles1  Icon User is offline

  • Pugnacious Penguin (inspired by no2pencil)
  • member icon

Reputation: 183
  • View blog
  • Posts: 1,152
  • Joined: 10-December 08

Re: Write to an Open (unsaved) Text File

Posted 08 July 2010 - 12:48 PM

Yeah, I have an idea, but it's reallllyyy messy and unlikely to work... but still, here we go!

   Process.Start("notepad.exe")
   Dim found As Boolean = False
   Do Until found = True
      System.Threading.Thread.Sleep(100)
      For Each p As Process In Process.GetProcesses
           If p.ProcessName = "notepad" Then
              found = True
           End If
      Next
   Loop
   SendKeys.Send("Whatever you want to say..." & Environment.NewLine & "And you can make new lines too!")
   


This post has been edited by Jack Eagles1: 08 July 2010 - 03:15 PM

Was This Post Helpful? 0
  • +
  • -

#3 NemY  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 39
  • Joined: 27-January 10

Re: Write to an Open (unsaved) Text File

Posted 08 July 2010 - 01:32 PM

Sorry about that, I missed a important part in the first post. Very sorry.

This post has been edited by NemY: 08 July 2010 - 01:43 PM

Was This Post Helpful? 0
  • +
  • -

#4 navr91  Icon User is offline

  • New D.I.C Head

Reputation: 6
  • View blog
  • Posts: 44
  • Joined: 12-July 09

Re: Write to an Open (unsaved) Text File

Posted 09 July 2010 - 11:07 AM

Thanks for your help, guys. I guess there may be no clean solution to this. Anyone else have any ideas?
Was This Post Helpful? 0
  • +
  • -

#5 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4463
  • View blog
  • Posts: 7,779
  • Joined: 08-June 10

Re: Write to an Open (unsaved) Text File

Posted 09 July 2010 - 11:36 AM

I've looked. I can't find that notepad has any command line parameters for this kind of thing. At best, you'll be able to do it in a very hacky way, like focusing the window and sending keystrokes. Probably not the best way of doing things.

Are you married to using Notepad though? It's pretty easy to "recreate" notepad as a form in your application. You could give it all the same behaviors.
Was This Post Helpful? 0
  • +
  • -

#6 rgfirefly24  Icon User is offline

  • D.I.C Lover
  • member icon


Reputation: 267
  • View blog
  • Posts: 1,470
  • Joined: 07-April 08

Re: Write to an Open (unsaved) Text File

Posted 09 July 2010 - 11:49 AM

This should help you get started

Apend Text to Notepad
Was This Post Helpful? 0
  • +
  • -

#7 Shadar  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 46
  • View blog
  • Posts: 157
  • Joined: 26-May 09

Re: Write to an Open (unsaved) Text File

Posted 09 July 2010 - 12:23 PM

Maybe I'm missiong something but isnt the point to allow the user to save text. Why not create a quick RTF editor and and allow him to save it?

Why use notepad at all?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1