Jump to content

Help:SaveToFile . how to deal with Filename


Recommended Posts

When I copy some text online,I always want to save then in txt.

I had do it use " New - new txt file" on a right click

Now i write a AutoIt script to do it.

HotKeySet("{ESC}", "Terminate")
Func Terminate()
  exit
EndFunc
HotKeySet("{F2}", "SaveTo")
  $sPath =@WorkingDir&"\"
While 1
 Sleep(1000)
 Wend
Func SaveTo()
     $bak = ClipGet()    
     $Title=@YEAR&"-"&@MON&"-"&@MDAY&"-"&@HOUR&@MIN&@SEC
     $FileNmae=$sPath&$Title&".txt"      
     FileWrite ($FileNmae, $bak )     
EndFunc

Now ,after I had copied from the IE,I cound save them by press "F2".

But there is a problem:

I want the file'name is the first line of which i had copied.

so ,I rewrite the script.

HotKeySet("{ESC}", "Terminate")
Func Terminate()
  exit
EndFunc
HotKeySet("{F2}", "SaveTo")
  $sPath =@WorkingDir&"\"
While 1
 Sleep(1000)
 Wend
Func SaveTo()
     $bak = ClipGet()    
     $Posi = StringInStr ( $bak, @CR)
     $Title=Stringleft($bak,$Posi-1)
     $FileNmae=$sPath&$Title&".txt"      
     FileWrite ($FileNmae, $bak )     
EndFunc

But it cannot work.

I thought some Character cannot be set as filename in Win2k.

maybe i could use "StringReplace" to clean them.

And I am working on Chinese Winows2000 pro,

how to deal with the unicode problem?

Maybe someone could write the UDF about UNICODE?

Thank you for your reply. :)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...