Don't like ads? PRO users don't see any ads ;-)

Notepad in AutoIt

By: ShadowzKnowledge on Oct 21st, 2011  |  syntax: AutoIt  |  size: 1.74 KB  |  hits: 426  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. ;=>> [AutoIt Notepad] coded by SdK <<=
  2. ;visit my YouTube Channel:
  3. ;http://www.youtube.com/user/ShadowzKnowledge
  4.  
  5.  
  6. ;Das Script ist nur ein Beispiel wie man MenĂ¼s einsetzen kann!!
  7.  
  8. #include <GUIConstantsEx.au3>
  9. #include <StaticConstants.au3>
  10. #include <WindowsConstants.au3>
  11.  
  12. Global $filepath = "//"
  13.  
  14. $Form1 = GUICreate("[AutoIt] Notepad", 600, 250)
  15. $Edit1 = GUICtrlCreateEdit("", 0, 0, 600, 250)
  16.  
  17. ;===============================
  18. $mainmenu = GUICtrlCreateMenu("File")
  19. $item1 = GUICtrlCreateMenuItem("New", $mainmenu)
  20. $item2 = GUICtrlCreateMenuItem("Open", $mainmenu)
  21. $item3 = GUICtrlCreateMenuItem("Save", $mainmenu)
  22. $item4 = GUICtrlCreateMenuItem("Exit", $mainmenu)
  23. ;===============================
  24.  
  25. GUISetState(@SW_SHOW)
  26.  
  27.  
  28. While 1
  29.         $nMsg = GUIGetMsg()
  30.         Switch $nMsg
  31.                 Case $GUI_EVENT_CLOSE
  32.                         Exit
  33.                 Case $item1 ;=> New
  34.                         GUICtrlSetData($Edit1,"")
  35.                         WinSetTitle($Form1,"","[AutoIt] Notepad")
  36.                 Case $item2 ;=> Open
  37.                         $fopend = FileOpenDialog("Pls select file ...", @ScriptDir, "(*.*)")
  38.                         If Not @error Then
  39.                                 $filepath = $fopend
  40.                                 $fread = FileRead($filepath)
  41.                                 GUICtrlSetData($Edit1, $fread)
  42.                                 WinSetTitle($Form1, "", _GetFileName($filepath))
  43.                         EndIf
  44.                 Case $item3 ;=> Save
  45.                         if ($filepath <> "//") Then
  46.                                 FileDelete($filepath)
  47.                                 FileWrite($filepath,GUICtrlRead($Edit1))
  48.                                 MsgBox(0,"","File has been saved!")
  49.                         Else
  50.                                 $fsaved = FileSaveDialog("Save file as ...",@ScriptDir,"(*.*)")
  51.                                 If Not @error Then
  52.                                         $filepath = $fsaved
  53.                                         FileWrite($filepath,GUICtrlRead($Edit1))
  54.                                         MsgBox(0,"","File has been saved!")
  55.                                 EndIf
  56.                         EndIf
  57.                 Case $item4 ;=> Exit
  58.                         Exit
  59.         EndSwitch
  60. WEnd
  61.  
  62.  
  63. Func _GetFileName($filename)
  64.         $ar = StringSplit($filename, "\")
  65.         Return $ar[$ar[0]]
  66. EndFunc   ;==>_GetFileName