d4rk Posted July 11, 2008 Share Posted July 11, 2008 Hello every1, I have this code to make a save dir for my files, .TXT and .HTML Everything seems go down when i have .TXT and .HTML, i meant how can i detect if the user save as TXT ? or HTML, as you can see in my code, i save it with & ".txt" , but how about if user save them as .HTML ? Thanks for reply $File=FileSaveDialog("Save These Code","","Text files (*.txt)|HTML files (*.htm;*.html)") _Write() Func _Write() FileWrite($File & ".txt",GUICtrlRead($RawHTML)) FileClose($File & ".txt") EndFunc [quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys Link to comment Share on other sites More sharing options...
d3mon Posted July 11, 2008 Share Posted July 11, 2008 Hello, I think you can make a select between Html & txt , if the user select (.txt) and save so that will be .txt if he select (.html) that will be .html so you have to search how to do multi select for extentions... No-life of autoit...what could be better ?LAST SCRIPTS WITH AUTO-IT : CLICK HERE Link to comment Share on other sites More sharing options...
DaRam Posted July 11, 2008 Share Posted July 11, 2008 Something like this? muttley $File=FileSaveDialog("Save These Code","","Text files (*.txt)|HTML files (*.htm;*.html)") If StringLower(StringRight($File,3))="htm" OR StringLower(StringRight($File,4))="html" Then ; HTM/HTML Else ; TXT EndIf Link to comment Share on other sites More sharing options...
d4rk Posted July 11, 2008 Author Share Posted July 11, 2008 (edited) Thanks for reply, $File=FileSaveDialog("Save These Code","","Text files (*.txt)|HTML files (*.htm;*.html)") _Write() Func _Write() FileWrite($File,GUICtrlRead($RawHTML)) FileClose($File) EndFuncoÝ÷ Øò¢êîØb±Ê{*.ßÙe±ç«mçâì"VÞ±«Þu»XÇ9Dâ·l{^Ȩ+wöÆ®IèÁø¥{Fòµë"¢yrq©ìj÷¢µ«]8i×b 7èX¥y©©ªê-·jºh®«¨¶f«¨µ»¶©®åzkajØ¢}ý¶IèÂ0¶z{b(¶®±êÜ©àzØ^±é^rب6«jdájy,~ëzrnëZºÚ"µÍÌÍÑ[OQ[TØ]QX[ÙÊ ][ÝÔØ]HÙHÛÙI][ÝË ][ÝÉ][ÝË ][ÝÕ^[È _S[È NÊ[ I][ÝÊBÙØÞ ][ÝÉ][ÝË ÌÍÑ[J The code show the file name, it doesn't have an Extension, so every try to find its extension is impossible Edited July 11, 2008 by d4rk [quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys Link to comment Share on other sites More sharing options...
d3mon Posted July 11, 2008 Share Posted July 11, 2008 (edited) If Its possible to have the file with extention look that : $var=FileOpenDialog("EXE FILE",@ProgramFilesDir,"Exe Files (*.exe)",1+2) If @error Then MsgBox(4096,"","No File(s) chosen") Else $var=StringSplit($var,'\') $i=1 While 2 If $var[$i]=$var[$var[0]] Then MsgBox(0,'$var['&$i&']',""&$var[$var[0]]) ExitLoop EndIf $i=$i+1 WEnd EndIf Edited July 11, 2008 by d3mon No-life of autoit...what could be better ?LAST SCRIPTS WITH AUTO-IT : CLICK HERE Link to comment Share on other sites More sharing options...
d4rk Posted July 11, 2008 Author Share Posted July 11, 2008 Thanks for you code, it seems works ... [quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys Link to comment Share on other sites More sharing options...
martin Posted July 11, 2008 Share Posted July 11, 2008 (edited) Thanks for you code, it seems works ... It's not obvious to me how that works when the return doesn't include the extension. Maybe you can get something out of this expandcollapse popup$g1 = GUICreate("save and find extension") GUIRegisterMsg(7000, "gettype") $AutoItexePath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\AutoIt", "InstallDir") Global $type = "unknown",$rectype = False $ftemp = FileOpen("fotemp.au3", 2) FileWriteLine($ftemp, '#Include <SendMessage.au3>') FileWriteLine($ftemp, 'opt("wintitlematchmode",2)') FileWriteLine($ftemp, 'Global $t1 = "hgtr",$ans = 1') FileWriteLine($ftemp, 'winWait("Save These Code","",10)') FileWriteLine($ftemp, 'while WinExists("Save These Code","")') FileWriteLine($ftemp, '$t = WingetText("Save These Code","")');,"[CLASS:Combo3;instance:3]")') FileWriteLine($ftemp, '$txt = stringinstr($t,"*.txt")') FileWriteLine($ftemp, '$htm = stringinstr($t,"*.htm")') FileWriteLine($ftemp, 'if $txt and not $htm then $ans = 1') FileWriteLine($ftemp, 'if not $txt and $htm then $ans = 2') FileWriteLine($ftemp, 'wend') FileWriteLine($ftemp, '$Wh1 = wingethandle("save and find extension")') FileWriteLine($ftemp, '_SendMessage($Wh1,7000,$ans)') FileClose($ftemp) Run('"' & $AutoItexePath & '\AutoIt3.exe "' & ' "' & @ScriptDir & '\fotemp.au3"') $File = FileSaveDialog("Save These Code", "", "Text files (*.txt)|HTML files (*.htm;*.html)") ConsoleWrite("File name returned = " & $File & @CRLF) While Not $rectype Sleep(10) WEnd ConsoleWrite("Extension chosen is " & $type & @CRLF) If StringInStr($File,'.') = 0 Then $File = $File & $type ConsoleWrite("Correct file name is " & $File & @CRLF) Func gettype($Hwnd, $mg, $wparam, $lparam) Switch $wparam Case 1 $type = ".txt" Case 2 $type = ".htm" EndSwitch $rectype = True EndFunc ;==>gettype EDIT: improved the example but same idea. Edited July 11, 2008 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
d4rk Posted July 12, 2008 Author Share Posted July 12, 2008 (edited) @Martin Thanks, But the script only works when you click on an existed file, if you type a new name then no extension is show ... Edited July 12, 2008 by d4rk [quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys Link to comment Share on other sites More sharing options...
martin Posted July 18, 2008 Share Posted July 18, 2008 @MartinThanks, But the script only works when you click on an existed file, if you type a new name then no extension is show ...Not for me when I run the code I posted. If I select htm from the file type combo, and type abcdef as the file name then the name abcdef.htm is written in the console output of SciTE.The whole point of my post was that you could find the extension when only the name was given without the extension.Can you give me an example of what you tried? Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
d4rk Posted July 19, 2008 Author Share Posted July 19, 2008 Weird, i do the same as you but i can't get the extension, it only works when i click on an already exist file ... but thanks anyway, i give up that script and start somewhere else. [quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys Link to comment Share on other sites More sharing options...
martin Posted July 19, 2008 Share Posted July 19, 2008 Weird, i do the same as you but i can't get the extension, it only works when i click on an already exist file ... but thanks anyway, i give up that script and start somewhere else.I am using this script so I would be interested to know what goes wrong. Can you tell me what the message is when you run this? expandcollapse popup$g1 = GUICreate("save and find extension") GUIRegisterMsg(7000, "gettype") $AutoItexePath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\AutoIt", "InstallDir") Global $type = "unknown",$rectype = False $ftemp = FileOpen("fotemp.au3", 2) FileWriteLine($ftemp, '#Include <SendMessage.au3>') FileWriteLine($ftemp, 'opt("wintitlematchmode",2)') FileWriteLine($ftemp, 'Global $t1 = "hgtr",$ans = 1') FileWriteLine($ftemp, 'winWait("Save These Code","",10)') FileWriteLine($ftemp, 'while WinExists("Save These Code","")') FileWriteLine($ftemp, '$t = WingetText("Save These Code","")');,"[CLASS:Combo3;instance:3]")') FileWriteLine($ftemp, '$txt = stringinstr($t,"*.txt")') FileWriteLine($ftemp, '$htm = stringinstr($t,"*.htm")') FileWriteLine($ftemp, 'if $txt and not $htm then $ans = 1') FileWriteLine($ftemp, 'if not $txt and $htm then $ans = 2') FileWriteLine($ftemp, 'wend') FileWriteLine($ftemp, '$Wh1 = wingethandle("save and find extension")') FileWriteLine($ftemp, '_SendMessage($Wh1,7000,$ans)') FileClose($ftemp) Run('"' & $AutoItexePath & '\AutoIt3.exe "' & ' "' & @ScriptDir & '\fotemp.au3"') $File = FileSaveDialog("Save These Code", "", "Text files (*.txt)|HTML files (*.htm;*.html)") ConsoleWrite("File name returned = " & $File & @CRLF) While Not $rectype Sleep(10) WEnd MsgBox(0,"Extension chosen is ", $type) $File = $File & $type MsgBox( 0,"Correct file name is ",$File) Func gettype($Hwnd, $mg, $wparam, $lparam) Switch $wparam Case 1 $type = ".txt" Case 2 $type = ".htm" EndSwitch $rectype = True EndFunc ;==>gettype Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
d4rk Posted July 19, 2008 Author Share Posted July 19, 2008 Hey muttley This ones works , but in the post #7 isn't ... maybe you should release this sooner. Thx [quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys Link to comment Share on other sites More sharing options...
martin Posted July 19, 2008 Share Posted July 19, 2008 Hey muttley This ones works , but in the post #7 isn't ... maybe you should release this sooner.ThxThat's good.I assume that the one in post 7 didn't work because you had a '.' somewhere in the file path, and I had a condition that if '.' was not in the file name then the extension was added. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. 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