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

    • Emmhor1
      By Emmhor1
      Hi All,

      MAIN QUESTION:
      Is it possible to Call specific function within a GUI

      So I have a script with multiple functions although I don't want to use every function every time.
      My Idea is to create a simple GUI which allows me to select what functions I want to use then run the funtions by clicking a button.
      I have already made a GUI which allows me to select specific .exe's I would like to run after selection it runs the .exe one by one.
      This script is on my work laptops and cannot access it right now.
       
      Who can help me with this?
      GUIcreate
      Func1 
      Func2
      Func3
      Then have a boxes which allows me to select the specif Func.(I used GUIChecked and Unchecked in my other script)
      Then a button which executes/calls the selected functions
    • ademon
      By ademon
      Hi. I can open the editor with out problems but I can not compile because it is placed on another partition diferent from C.
      Can you provide an update of this bug?


    • Blois
      By Blois
      Hi Guis,
       
      I need to create keyboard shortcut to navigate the tabs and activate them, but I could not use the code below:
      #include <TabConstants.au3> #include <WindowsConstants.au3> #include <GuiTab.au3> #include <GUIConstantsEx.au3> HotKeySet("^{TAB}", "_TabRight") HotKeySet("^+{TAB}", "_TabLeft") $gui = GUICreate("test",450, 300) $Tab1 = GUICtrlCreateTab(20, 24, 425, 201) $TabSheet1 = GUICtrlCreateTabItem("Tabsheet 1") $lbContagemGrupos2 = GUICtrlCreateLabel("aaaa", 50, 50) GUICtrlSetColor(-1, 0x0000FF) GUICtrlCreateTabItem("") $TabSheet2 = GUICtrlCreateTabItem(" ") $TabSheet3 = GUICtrlCreateTabItem(" ") GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func _TabRight() $CurPos = _GUICtrlTab_GetCurSel($Tab1) _GUICtrlTab_SetCurSel($Tab1, $CurPos + 1) $tab = "$TabSheet" & $CurPos GUICtrlSetState($TabSheet1 + $CurPos, $GUI_SHOW) Return EndFunc Func _TabLeft() $CurPos = _GUICtrlTab_GetCurSel($Tab1) _GUICtrlTab_SetCurSel($Tab1, $CurPos - 1) $tab = "$TabSheet" & $CurPos GUICtrlSetState($TabSheet1 + $CurPos, $GUI_SHOW) Return EndFunc Exit  
      can you help me?
    • lenclstr746
      By lenclstr746
      Hi guys,
      Some functions of my script are running slowly. Very slow. What is the reason?
      My Code:
      <snip>
    • Pricehacker
      By Pricehacker
      Hello again!
      I have tried searching for quite some time now but couldn´t find a single working way to change the class of your GUI that doesn´t include changing it manually after its compilation.
      First or "AutoIt v3 GUI" is a pretty boring name tbh and i would like to spice it up a bit, also, and more importantly, I would like to identify my windows by something other than its title as it will change depending on some factors and im using two different programs independently as multi threading isn't supported.
      Any help is appreciated! Thank you!
×