Jump to content
Sign in to follow this  
Scriptmaster

The Editor

Recommended Posts

Scriptmaster

Here is my latest project,

It is a simple code editor that supports all text formats.

It will execute batch directly and will also execute maths.

It also has the simple feature of shellexecute (POINTLESS!)

1 error I found was that I dont know how to tell if the script* has been saved so it has to ask the user

I need to know that for executing batch where the file (if saved/opened) is executed using 'Run($location)'

GOTO bottom for latest version

Edit*:----the script made in the program. not the code for the program.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
GUICreate("Script", 600, 400)
GUISetState(@SW_SHOW)
HotKeySet("{F5}", "execute1")
HotKeySet("{F4}", "shellexecute1")
HotKeySet("{F3}", "Executebatch1")
GUICtrlCreateLabel("F3 Execute Batch, F4 ShellExecute, F5 Execute Math", 10, 10)
$edit = GUICtrlCreateEdit("", 4, 54, 594, 343)
$save = GUICtrlCreateButton("Save", 74, 30, 70, 20)
$new = GUICtrlCreateButton("New", 144, 30, 70, 20)
$stop = GUICtrlCreateButton("Exit", 4, 30, 70, 20)
$open = GUICtrlCreateButton("Open", 214, 30, 70, 20)
$help = GUICtrlCreateButton("Info", 284, 30, 70, 20)
$progress = GUICtrlCreateProgress(370, 29, 220, 22)
Func execute1()
$executeans = Execute(GUICtrlRead($edit))
MsgBox("", "", $executeans)
EndFunc   ;==>execute1
Func shellexecute1()
ShellExecute(GUICtrlRead($edit))
EndFunc   ;==>shellexecute1
Func Executebatch1()
$saveyn = MsgBox(4, "", "Have you saved?")
If $saveyn = 6 Then
  Run($location)
Else
  MsgBox(48, "Warning", "Save before executing batch!")
EndIf
EndFunc   ;==>Executebatch1
While 1
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Select
  Case $msg = $help
   MsgBox(64, "Editor", "By James B")
  Case $msg = $open
   $openfile = FileOpenDialog("open", "", "Text documents (*.bat;*.txt;*.vbs;)")
   $netopen = FileOpen($openfile)
   $read_file = FileRead($netopen)
   GUICtrlSetData($progress, 100)
   Sleep(300)
   GUICtrlSetData($edit, $read_file)
   Sleep(300)
   GUICtrlSetData($progress, 0)
  Case $msg = $new
   GUICtrlSetData($edit, "")
  Case $msg = $stop
   ExitLoop
  Case $msg = $save
   $ynsave = MsgBox(1, "Editor", "Save?")
   If $ynsave = 1 Then
    $location = FileSaveDialog("Save", @MyDocumentsDir, "Text documents (*.bat;*.txt;*.vbs;)", 2)
    GUICtrlSetData($progress, 100)
    Sleep(300)
    $exists = FileExists($location)
    If $exists = 1 Then
     FileDelete($location)
    EndIf
    FileWrite($location, GUICtrlRead($edit))
    Sleep(300)
    GUICtrlSetData($progress, 0)
   EndIf
EndSelect
WEnd
FileClose($openfile)
FileClose($location)

Please report errors but do not edit!

Edited by Scriptmaster

shutdown(1)

Share this post


Link to post
Share on other sites
martin

I dont know how to tell if the script has been saved

Maybe you mean you don't know if the script has been changed.

Search the forums for examples of $EN_CHANGE. You can set a flag to indicate a change was made every time the EN_CHANGE notification fires, and reset the flag whenever the script is saved.


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.

Share this post


Link to post
Share on other sites
Scriptmaster

Could I just find out if a variable has been declared with a dimple 1-0 return value?

I know I am in the wrong forum but I just wondered if that was poss

Edited by Scriptmaster

shutdown(1)

Share this post


Link to post
Share on other sites
martin

You mean could you find out if a variable is declared, with something like an IsDeclared function? Well you never know your luck..


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.

Share this post


Link to post
Share on other sites
Scriptmaster
Just what I need Edited by Scriptmaster

shutdown(1)

Share this post


Link to post
Share on other sites
Scriptmaster

Problem cured and V2.01 released

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
GUICreate("Script", 600, 400)
GUISetState(@SW_SHOW)
HotKeySet("{F5}", "execute1")
HotKeySet("{F4}", "shellexecute1")
HotKeySet("{F3}", "Executebatch1")
GUICtrlCreateLabel("F3 Execute Batch, F4 ShellExecute, F5 Execute Math", 10, 10)
$edit = GUICtrlCreateEdit("", 4, 54, 594, 343)
$save = GUICtrlCreateButton("Save", 74, 30, 70, 20)
$new = GUICtrlCreateButton("New", 144, 30, 70, 20)
$stop = GUICtrlCreateButton("Exit", 4, 30, 70, 20)
$open = GUICtrlCreateButton("Open", 214, 30, 70, 20)
$help = GUICtrlCreateButton("Info", 284, 30, 70, 20)
$progress = GUICtrlCreateProgress(370, 29, 220, 22)
Func execute1()
$executeans = Execute(GUICtrlRead($edit))
MsgBox("", "", $executeans)
EndFunc   ;==>execute1
Func shellexecute1()
ShellExecute(GUICtrlRead($edit))
EndFunc   ;==>shellexecute1
Func Executebatch1()
If Not IsDeclared("location") Then
  MsgBox(48, "Warning", "Save before executing batch!")
Else
  Run($location)
EndIf
EndFunc   ;==>Executebatch1
While 1
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Select
  Case $msg = $help
   MsgBox(64, "Editor", "By James B")
  Case $msg = $open
   $openfile = FileOpenDialog("open", "", "Text documents (*.bat;*.txt;*.vbs;*au3;)")
   $netopen = FileOpen($openfile)
   $read_file = FileRead($netopen)
   GUICtrlSetData($progress, 100)
   Sleep(300)
   GUICtrlSetData($edit, $read_file)
   Sleep(300)
   GUICtrlSetData($progress, 0)
  Case $msg = $new
   GUICtrlSetData($edit, "")
  Case $msg = $stop
   ExitLoop
  Case $msg = $save
   $ynsave = MsgBox(1, "Editor", "Save?")
   If $ynsave = 1 Then
    $location = FileSaveDialog("Save", @MyDocumentsDir, "Text documents (*.bat;*.txt;*.vbs;*au3;)", 2)
    GUICtrlSetData($progress, 100)
    Sleep(300)
    $exists = FileExists($location)
    If $exists = 1 Then
     FileDelete($location)
    EndIf
    FileWrite($location, GUICtrlRead($edit))
    Sleep(300)
    GUICtrlSetData($progress, 0)
   EndIf
EndSelect
WEnd
FileClose($openfile)
FileClose($location)
Edited by Scriptmaster

shutdown(1)

Share this post


Link to post
Share on other sites
Scriptmaster

V2.53

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
GUICreate("Script", 600, 400)
GUISetState(@SW_SHOW)
HotKeySet("{F5}", "execute1")
HotKeySet("{F6}", "htmlshow1")
HotKeySet("{F4}", "shellexecute1")
HotKeySet("{F3}", "Executebatch1")
GUICtrlCreateLabel("F3 Execute Batch, F4 ShellExecute, F5 Execute Math, F6 Show HTML", 10, 10)
$edit = GUICtrlCreateEdit("", 4, 54, 594, 343)
$save = GUICtrlCreateButton("Save", 74, 30, 70, 20)
$new = GUICtrlCreateButton("New", 144, 30, 70, 20)
$stop = GUICtrlCreateButton("Exit", 4, 30, 70, 20)
$open = GUICtrlCreateButton("Open", 214, 30, 70, 20)
$help = GUICtrlCreateButton("Info", 284, 30, 70, 20)
$progress = GUICtrlCreateProgress(370, 29, 220, 22)
Func execute1()
$executeans = Execute(GUICtrlRead($edit))
MsgBox("", "", $executeans)
EndFunc   ;==>execute1
Func htmlshow1()
Filewrite("C:/tmp/editorhtml.html", GUIctrlread($edit))
shellexecute("C:/tmp/editorhtml.html")
Filedelete("C:/tmp/editorhtml.html")
endfunc
Func shellexecute1()
ShellExecute(GUICtrlRead($edit))
EndFunc   ;==>shellexecute1
Func Executebatch1()
If Not IsDeclared("location") Then
  MsgBox(48, "Warning", "Save before executing batch!")
Else
  Run($location)
EndIf
EndFunc   ;==>Executebatch1
While 1
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Select
  Case $msg = $help
   MsgBox(64, "Editor", "By James B")
  Case $msg = $open
   $openfile = FileOpenDialog("open", "", "Text documents (*.bat;*.txt;*.vbs;*.au3;*.html;)")
   $netopen = FileOpen($openfile)
   $read_file = FileRead($netopen)
   GUICtrlSetData($progress, 100)
   Sleep(300)
   GUICtrlSetData($edit, $read_file)
   Sleep(300)
   GUICtrlSetData($progress, 0)
  Case $msg = $new
   GUICtrlSetData($edit, "")
  Case $msg = $stop
   ExitLoop
  Case $msg = $save
   $ynsave = MsgBox(1, "Editor", "Save?")
   If $ynsave = 1 Then
    $location = FileSaveDialog("Save", @MyDocumentsDir, "Text documents (*.bat;*.txt;*.vbs;*au3;*.html;)", 2)
    GUICtrlSetData($progress, 100)
    Sleep(300)
    $exists = FileExists($location)
    If $exists = 1 Then
     FileDelete($location)
    EndIf
    FileWrite($location, GUICtrlRead($edit))
    Sleep(300)
    GUICtrlSetData($progress, 0)
   EndIf
EndSelect
WEnd
FileClose($openfile)
FileClose($location)

shutdown(1)

Share this post


Link to post
Share on other sites
Scriptmaster

Will Be updated soon so stay tuned.


shutdown(1)

Share this post


Link to post
Share on other sites
Scriptmaster

Soon it will support autoit and coloured text!


shutdown(1)

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  

  • Similar Content

    • Blueman
      By Blueman
      Hey Guys,
      Maybe you can help me with something small.
      It is not terrible but it slows down my script and after a while even crash the script.

      First i explain what i have;
      I have a GUI with a lot of GUICtrlCreateInput controls, lets say 600 pieces.
      All the controls are hidden when the GUI is displayed, i have 3 buttons attached to 200 pieces each.
      When i press button-1 the first 200 controls are showed,
      When i press button-2 the first 200 controls are hidden and the next 200 controls are showed,
      etc, etc.
      This is working perfectly but after a while the GUI is getting slower and slower.
      After a while the controls aren't responding anymore and the script crashes.
      When i compile the script to 64-Bits version the speed is a lot better but you can still see the script slowing down each time i use the buttons.
      I think there has to be a buffer somewhere that is filling each time i show and hide the controls, but how can i clear that buffer without restarting the script?
      Deleting and re-creating the controls didn't help, deleting the entire gui (and controls) and re-creating it didn't help also.
      The only thing that is working is restarting the script.

      Thanks guys!

      PS: If you need a working example i can add it to this topic, just let me know. It is not rocket science, i just create the controls and show/hide them with a while loop and 3 buttons.
       
    • TheDcoder
      By TheDcoder

      ProxAllium
      ProxAllium is a GUI frontend to Tor, it aims to make the usage of Tor easier by directly exposing its SOCK5 proxy which can be used to access the Tor network. The GUI is designed to be simple and user-friendly and it has a few other features... namely:
      Fully portable - doesn't write outside its own directory Integrated with Tor via the controller interface and properly communicates with it Minimize to tray Option to start with Windows Interface to configure bridges if Tor is censored in your region Many customization options are available via the config.ini file Screenshots:
      The code is made with pure AutoIt, is fully open source and you are free to adapt it to your needs
      The GitHub repository hosts all the releases and code. As a bonus it has a somewhat sparsely documented Tor UDF which can be used to control Tor, the code also demonstrates the proper usage of my Process UDF which might be interesting if you want to deal with processes.
       
      As some of my friends know, I no longer use Windows as my main operating system. I switched to Linux a few months back as my primary operating system and haven't looked back since. Unfortunately that meant I could no longer use my own program due to it being Windows only... after a few months of playing around with C and making a basic program, I have decided to rewrite all of ProxAllium into C and make it cross-platform. Sadly this means that the AutoIt version of ProxAllium will not receive any major updates now.
      Let me know if this is something you guys would use, I used it daily with my IRC client to connect via Tor (to protect my I.P). I hope you enjoy using my program!
    • morion84
      By morion84
      Hi, when I call a MsgBox function I can use a "$MB_SERVICE_NOTIFICATION" flag so it will be displayed "on the current active desktop, even if there is no user logged on to the computer.". That works just great. Is there a way to do the same to Autoit GUI Form so it will be visible on desktop even if running from system account and user is not logged?
    • remin
      By remin
      I do have one autoit script file with multiple functions.
      p.e.
       
      #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <String.au3> #include <GuiButton.au3> #include <Constants.au3> #include <EditConstants.au3> #include <Misc.au3> #include <MsgBoxConstants.au3> #include <HotString.au3> Func ACase() $Form4=GUICreate("ACase", 100, 195, 290, 142) etc etc GUISetState(@SW_SHOW, $Form4) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE SUB_Write2ini(....) ;I write a few things in an ini file Case $a Case $b etc EndSwitch WEnd EndFunc Func BCase() $Form5=GUICreate("BCase", 100, 195, 290, 142) etc etc GUISetState(@SW_SHOW, $Form5) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE SUB_Write2ini(....) ;I write a few things in an ini file Case $a Case $b etc EndSwitch WEnd EndFunc When I activate the 1st function (ACase), using a shortcut and the 2nd function (BCase) (with a different shortcut) and I click on a button in whatever of these 2 Gui's, I can't use the other Gui anymore. It doesn't do the right thing as if autoit only remembers the Gui I first used.
      What did I wrong? How can I let autoit know which GUI is active and to connect to the function of that Gui?
      Hope I made myself clear.
       
    • vin1
      By vin1
      i have a script that selects  a text file and deletes a line (text input required) in the text file selected
      i have to make it remove all lines found on a file i name, toRemoveLines.txt
      it has to remove lines from all text files found in a folder
      this is the script that has to be modified
      where it says "select file" it has to be "select folder"
      where it says "line text input" it has to be all lines from a text file
      #Include <File.au3> Global $success = False $file_name = FileOpenDialog("Select file", @ScriptDir, "All files (*.*)", 1+4) $line_text_input = InputBox("Line's text", "Line must contain following text:", "line contains this text") $file_count_lines = _FileCountLines($file_name) for $i = 0 to $file_count_lines $Lines_text_output = FileReadLine($file_name, $i) if StringInStr($Lines_text_output, $line_text_input) then _FileWriteToLine($file_name, $i, "", 1) $success = True ExitLoop EndIf Next if $success = True Then MsgBox(0, "Success", "Line has been deleted") Else MsgBox(0, "Failure", "Line wasn't found") EndIf  
×