Sign in to follow this  
Followers 0
confused2gether

Notepad Save file in user desktop directory as HTML

8 posts in this topic

I am writing a quick and easy script for creating some HTML signatures and I have it prompt user for info then it launches Notepad and types out all of the code and then saves the file as EmailSignature.html but it always seems to save it in different locations. Is there anyway of making sure that it saves it on the desktop of the current user rather than wherever Notepad's default is?

Share this post


Link to post
Share on other sites



How are you issuing the save command?


[sub]Quantum mechanics: The dreams stuff is made of[/sub]

Share this post


Link to post
Share on other sites

How are you issuing the save command?

By closing the file and then using the Save As window.

Windows Vista Version

WinClose("Untitled - Notepad")
WinWaitActive("Notepad")
Send("!s")
WinWaitActive("Save As")
Send("!t")
Send("{RIGHT}")
Send("{RIGHT}")
Send("{ENTER}")
Send("!n")
Send("EmailSignature.html")
Send("{ENTER}")

Windows XP Version

WinClose("Untitled - Notepad")
WinWaitActive("Notepad")
Send("!y")
WinWaitActive("Save As")
Send("!t")
Send("{RIGHT}")
Send("{RIGHT}")
Send("{ENTER}")
Send("!n")
Send("EmailSignature.html")
Send("{ENTER}")

The send right and enter are to select ALL FILES instead of .TXT in the window. If you have a better way I should go, let me know.

Share this post


Link to post
Share on other sites

You might not want to do this but why not just write the HTML straight to a file:

Dim $htmlCode
Dim $File

$htmlCode &= "<html>" & @CRLF
$htmlCode &= "<head>" & @CRLF
$htmlCode &= "<title>This is some sample html</title>" & @CRLF
$htmlCode &= "</head>" & @CRLF

$File = FileOpen("C:\test.html", 2)
FileWrite($File, $htmlCode)
FileClose($File)

[sub]Quantum mechanics: The dreams stuff is made of[/sub]

Share this post


Link to post
Share on other sites

You might not want to do this but why not just write the HTML straight to a file:

Dim $htmlCode
Dim $File

$htmlCode &= "<html>" & @CRLF
$htmlCode &= "<head>" & @CRLF
$htmlCode &= "<title>This is some sample html</title>" & @CRLF
$htmlCode &= "</head>" & @CRLF

$File = FileOpen("C:\test.html", 2)
FileWrite($File, $htmlCode)
FileClose($File)
Im guessing too that works behind the scenes and is silent which is million times better than what im doing right now lol. Although this is just a simple quickie program, silent would still be nice. Now im guessing that if I needed to have it input information it would be something like this:

$htmlCode &= "<a href = {ASC 034}mailto:" & $emailAddress & "{ASC 034}>" & $emailAddress & "</a>" & @CRLF

$emailAddress would be coming from an inputbox

{ASC 034} is the double quote

Does that seem correct?

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Your correct, that would be behind the scenes.

What you have looks correct to me.

Edited by DarkMatter

[sub]Quantum mechanics: The dreams stuff is made of[/sub]

Share this post


Link to post
Share on other sites

Seems correct, but to have it save to the desktop change:

$File = FileOpen("C:\test.html", 2)

to

$File = FileOpen(@DesktopDir & "\test.html", 2)

Share this post


Link to post
Share on other sites

Awesome. Looks all good to me. I will try it out and let you know if I have any issues.

Thanks

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0