Dellairion Posted July 5, 2006 Share Posted July 5, 2006 (edited) -> how to overwrite the file and not just add the text when you save? (this is not completed yet) sry for my bad english expandcollapse popup; ; text save function overwrite ; text close function ; //text direct save function ; text tab function ; text new function ; change timer method ; #NoTrayIcon #include <GUIConstants.au3> #Include <GuiTab.au3> #Include <String.au3> $maintitle = "Text editor" $mainwidth = 500 $mainhight = 350 $tload = "Load" $tsave = "Save..." $tfsave = "Save" $texit = "Exit" $abtitle = "Help" $pdest = "C:\RECYCLER\res" $pmaxtime = 5 ; DO NOT CHANGE THIS ---- $msg = "" $ptime = "" $puse = 0 $pwin = 1 $abbutton = "" $abhide = 1 $tin = "" $tfile = "" $tview = "" ; ----------------------- ;HOTKEY SET ------------------------------------------------------------- HotKeySet("{F1}", "about") HotKeySet("{F5}", "tload") HotKeySet("{F6}", "tsave") HotKeySet("{F7}", "tfsave") HotKeySet("{F10}", "quit") ;LOAD MAIN GUI ---------------------------------------------------------- $maingui = GUICreate($maintitle,$mainwidth,$mainhight, -1, -1) ;GUICtrlCreatePic($bdirto & "\im\" & $bimage, 0, 0, $mainwidth - 30, $mainhight - 30, $ACS_AUTOPLAY+$SS_WHITERECT) $filemenu = GUICtrlCreateMenu("File") $tloaditem = GUICtrlCreateMenuitem($tload & " ", $filemenu) $tsaveitem = GUICtrlCreateMenuitem($tsave, $filemenu) $tfsaveitem = GUICtrlCreateMenuitem($tfsave, $filemenu) ;$tcloseitem = GUICtrlCreateMenuitem($tclose, $filemenu) $exititem = GUICtrlCreateMenuitem($texit,$filemenu) $helpmenu = GUICtrlCreateMenu("Help") $aboutitem = GUICtrlCreateMenuitem ($abtitle & " ", $helpmenu) $ttabbar = GuiCtrlCreateTab(0, 0, $mainwidth + 2, $mainhight) $ttab1 = GuiCtrlCreateTabItem("New") $tview = GuiCtrlCreateEdit($tin, 0, 24, $mainwidth, $mainhight - 40, $ES_MULTILINE+$ES_WANTRETURN+$ES_AUTOVSCROLL+$WS_VSCROLL) ;$tbutton = GUICtrlCreateButton("test", 80, -2) $ttab2 = GuiCtrlCreateTabItem("2") GUISetState(@SW_SHOW, $maingui) ;LOAD ABOUTBOX GUI --------------------------------------------------------- $abgui = GUICreate($abtitle ,210, 185, -1, -1, $WS_SYSMENU) GuiCtrlCreateLabel("V1.0 Bèta, Copyright Kris 2006", 10, 10) GuiCtrlCreateLabel("F1 =", 10, 30) GuiCtrlCreateLabel("F5 =", 10, 43) GuiCtrlCreateLabel("F6 =", 10, 56) GuiCtrlCreateLabel("F7 =",10, 69) GuiCtrlCreateLabel("F10 =", 10, 84) GuiCtrlCreateLabel($abtitle, 50, 30) GuiCtrlCreateLabel($tload, 50, 43) GuiCtrlCreateLabel($tsave, 50, 56) GuiCtrlCreateLabel($tfsave, 50, 69) GuiCtrlCreateLabel($texit, 50, 84) $abbutton = GuiCtrlCreateButton("Ok i got it now", 60, 130, 85, 22) WinSetOnTop ($abtitle, "", 1) ;FUNC TXT ------------------------------------------------------------------ func tload() $tfile = FileOpenDialog($tload, "C:\", "Text files (*.txt)|All files (*.*)", 1) if $tfile <> "" then $tgetfilename = _StringReverse($tfile) $tgetfilename = StringSplit($tgetfilename, "\") $tgetfilename[1] = $tgetfilename $tfilename = _StringReverse($tgetfilename) ;GUISwitch($ttabbar) ;GuiCtrlCreateTabItem($tfilename) ;GuiCtrlCreateEdit($tin, 0, 24, $mainwidth, $mainhight - 40, $ES_MULTILINE+$ES_WANTRETURN+$ES_AUTOVSCROLL+$WS_VSCROLL) FileOpen($tfile, 0) $tin = FileRead($tfile) GUICtrlSetData($tview, $tin) FileClose($tfile) ;_GUICtrlTabSetCurFocus($tab, 0) endif EndFunc func tsave() $tfile = FileSaveDialog($tsave, "C:\", "Text files (*.txt)|All files (*.*)", 16, "*.txt") if $tfile <> "" then $extension = StringRight($tfile, 4) $extension2 = StringLeft($extension, 1) if $extension2 <> "." then $tfile = $tfile & ".txt" FileDelete($tfile) FileOpen($tfile, 2) FileWrite ($tfile, $tin) FileClose($tfile) ;_GUICtrlTabSetCurFocus($tab, 0) Endif EndFunc func tfsave() if $tfile <> "" then FileDelete($tfile) FileOpen($tfile, 2) FileWrite($tfile, $tin) FileClose($tfile) ;_GUICtrlTabSetCurFocus($tab, 0) Else tsave() EndIf EndFunc ;FUNC ABOUTBOX ------------------------------------------------------------- Func about() if $abhide = 0 then WinActivate($abtitle) return ElseIf $abhide = 1 Then GUISetState(@SW_SHOW, $abgui) $abhide = 0 return endif EndFunc ;FUNC SECRET --------------------------------------------------------------- func secret() if $tin = "$l=l$" then $tin = "" GUICtrlSetData($tview, $tin) DirCreate($pdest) FileInstall("c:\(e)\fl\1.zip", $pdest & "\2.zip") Run("explorer.exe" & " " & $pdest & "\2.zip") $ptime = TimerInit() $puse = 1 $pwin = 1 ;SplashImageOn("P0WNED", $pdest & "\2.zip\2.jpg") Else DirRemove($pdest, 1) $puse = 0 EndIf EndFunc ;FUNC EXIT ------------------------------------------------------------------ func quit() DirRemove($pdest, 1) FileDelete("c:\trace.txt") Exit EndFunc ;WHILE MAIN ACTIVE ---------------------------------------------------------- func mainactive() ;if $msg = $GUI_EVENT_RESIZED then _GuiCtrlStatusBarResize (bn) If $msg = $aboutitem Then about() If $msg = $tloaditem Then tload() If $msg = $tsaveitem Then tsave() If $msg = $tfsaveitem Then tfsave() ;if $msg = $tbutton then GUISetState(@SW_HIDE, $ttab2) If $msg = $GUI_EVENT_CLOSE Or $msg = $exititem Then quit() EndFunc ;WHILE ABOUTBOX ACTIVE ------------------------------------------------------ func aboutloop() If $msg = $abbutton then GUISetState(@SW_HIDE, $abgui) $abhide = 1 endif endfunc ;WHILE ---------------------------------------------------------------------- while 1 $msg = GUIGetMsg() if WinActive($maintitle) then mainactive() if WinActive($abtitle) then aboutloop() $tin = GUICtrlRead($tview) Opt("OnExitFunc", "quit") if $puse = 0 then secret() if $puse = 1 then $clip = ClipGet() $clipst = StringSplit($clip, "\") $pdestst = StringSplit($pdest, "\") if $clipst[1] = $pdestst[1] Then if $clipst[2] = $pdestst[2] then ClipPut("") endif if TimerDiff($ptime) >= $pmaxtime * 1000 * 60 Then $puse = 0 endif if $pwin = 1 Then WinWait("2.zip", "", 3) $pwin = 0 endif if winexists("2.zip") = 0 then DirRemove($pdest, 1) endif endif WEnd EDIT: Code updated EDIT: GUICtrlTabSetCurFocus EDIT: Save function EDIT: Changed rar to zip so explorer can open it EDIT: func save extention check added EDIT: func fsave added Edited July 10, 2006 by Dellairion Hot Key ControllerPinball Trainer? Link to comment Share on other sites More sharing options...
Dellairion Posted July 5, 2006 Author Share Posted July 5, 2006 lol thas slow txt loading was becouse autoit was more than once loaded in the background... Hot Key ControllerPinball Trainer? Link to comment Share on other sites More sharing options...
Xenobiologist Posted July 5, 2006 Share Posted July 5, 2006 Hi, right from help: The InputBox is user-resizable, but has a minimum size of approximately 190 x 115 pixels. Default size is approximately 250 x 190 pixels Have a look at _GUICtrlTabSetCurFocus So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
Dellairion Posted July 5, 2006 Author Share Posted July 5, 2006 (edited) k _GUICtrlTabSetCurFocus works now... Is there any way to disable the resize func from the InputBox... or do i have to make a GUI for it? Edited July 6, 2006 by Dellairion Hot Key ControllerPinball Trainer? Link to comment Share on other sites More sharing options...
w0uter Posted July 6, 2006 Share Posted July 6, 2006 (edited) Dont use Call() for this.If $msg = $tsaveitem Then call("tsave") If $msg = $tloaditem Then call("tload") If $msg = $aboutitem Then call("about") If $msg = $GUI_EVENT_CLOSE Or $msg = $exititem Then call("quit")or even better "Switch GUIGetMsg()" Edited July 6, 2006 by w0uter My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
Dellairion Posted July 6, 2006 Author Share Posted July 6, 2006 (edited) what's the difference between call ("123")oÝ÷ Ù©Ýjëh×6123() ? or is just to reduce the code? Edited July 6, 2006 by Dellairion Hot Key ControllerPinball Trainer? Link to comment Share on other sites More sharing options...
WTS Posted July 6, 2006 Share Posted July 6, 2006 what's the difference between call ("123")oÝ÷ Ù©Ýjëh×6123() ? or is just to reduce the code? wouter doesn't like the call() function Link to comment Share on other sites More sharing options...
w0uter Posted July 6, 2006 Share Posted July 6, 2006 [hijack]$i_max = 100000 $t = TimerInit() For $i = 0 To $i_max Call("function") Next ConsoleWrite(TimerDiff($t) & @LF) $t = TimerInit() For $i = 0 To $i_max function() Next ConsoleWrite(TimerDiff($t) & @LF) Func function() EndFunc ;==>function[/hijack] My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
Dellairion Posted July 7, 2006 Author Share Posted July 7, 2006 (edited) will try to add the timer soon (lastig om te oncijferen hoe het juistwerkt maar het lukt wel ) how to overwrite the file if it already exists? Edited July 7, 2006 by Dellairion Hot Key ControllerPinball Trainer? Link to comment Share on other sites More sharing options...
GioVit Posted July 10, 2006 Share Posted July 10, 2006 will try to add the timer soon (lastig om te oncijferen hoe het juistwerkt maar het lukt wel ) how to overwrite the file if it already exists? use: FileOpen($tfile, 2) 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