Jump to content

Notepad Help


Recommended Posts

I am in the middle of Building a notepad clone known as Hunterpad, but I am stuck on the New function. I tried to make a function that exits Hunterpad and then Reopens it, but I cantwork out the code for that, any help? Here is my Code:

#include <GUIConstants.au3>
Opt("TrayMenuMode", 1)
$Form1 = GUICreate("Hunterpad", 1112, 561, 147, 112)
GUICtrlCreateEdit("", 0, 32, 1361, 673)
GUICtrlSetData(-1, "")
$File = GUICtrlCreateMenu("&File")
$New = GUICtrlCreateMenuItem("New", $File)
$MenuItem4 = GUICtrlCreateMenuItem("Save", $File)
$MenuItem5 = GUICtrlCreateMenuItem("Save As...", $File)
$MenuItem7 = GUICtrlCreateMenuItem("Print", $File)
$MenuItem6 = GUICtrlCreateMenuItem("Exit", $File)
$MenuItem1 = GUICtrlCreateMenu("&Edit")
$MenuItem8 = GUICtrlCreateMenuItem("Undo", $MenuItem1)
$MenuItem9 = GUICtrlCreateMenuItem("Redo", $MenuItem1)
$MenuItem2 = GUICtrlCreateMenu("&Tools")
$MenuItem10 = GUICtrlCreateMenuItem("Font..", $MenuItem2)
$MenuItem11 = GUICtrlCreateMenuItem("Size", $MenuItem2)
$MenuItem3 = GUICtrlCreateMenu("&Help")
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $New
  Exit Run("Hunterpad.exe")
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Check out my new site!Current Projects:[list][*]Hunter Console - A Small Gadget[*]HunterPad - Basic Notepad aimed at Programmers[*]Betters UP! - Betting Game[/list]
Link to comment
Share on other sites

  • Moderators

Dasttann777,

Try this: ;)

Case $New
    ; Open a new instance
    Run("Hunterpad.exe")
    ; Close the current instance
    Exit

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

Dasttann777,

a function that exits Hunterpad and then Reopens it

That is what you asked for and that is what I gave you. ;)

With your new information I suggest what you want to do is to empty the edit control:

#include <GUIConstants.au3>
Opt("TrayMenuMode", 1)
$Form1 = GUICreate("Hunterpad", 1112, 561, 147, 112)
$cEdit = GUICtrlCreateEdit("", 0, 32, 1361, 673) ; Note the ControlID <<<<<<<<<<<<<<<<<<<<<<<<<<<
GUICtrlSetData(-1, "")
$File = GUICtrlCreateMenu("&File")
$New = GUICtrlCreateMenuItem("New", $File)
$MenuItem4 = GUICtrlCreateMenuItem("Save", $File)
$MenuItem5 = GUICtrlCreateMenuItem("Save As...", $File)
$MenuItem7 = GUICtrlCreateMenuItem("Print", $File)
$MenuItem6 = GUICtrlCreateMenuItem("Exit", $File)
$MenuItem1 = GUICtrlCreateMenu("&Edit")
$MenuItem8 = GUICtrlCreateMenuItem("Undo", $MenuItem1)
$MenuItem9 = GUICtrlCreateMenuItem("Redo", $MenuItem1)
$MenuItem2 = GUICtrlCreateMenu("&Tools")
$MenuItem10 = GUICtrlCreateMenuItem("Font..", $MenuItem2)
$MenuItem11 = GUICtrlCreateMenuItem("Size", $MenuItem2)
$MenuItem3 = GUICtrlCreateMenu("&Help")
GUISetState(@SW_SHOW)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $New
            GUICtrlSetData($cEdit, "") ; Empty the control <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

That is a pretty basic thing to solve - have you done much coding before? If not then might I suggest the excellent tutorials that you will find here and here - it might save you a lot of frustration in the future. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Hi again, sorry for my continuous asking for help, but the tutorials are not giving me enough info. I want to create a save box that:

1. Saves the File(My one opens up the dialog, but wont save.

2.Once Saved, does not need to be saved again.

Here is my Code:

#include <GUIConstants.au3>
#include <WinAPI.au3>
Opt("TrayMenuMode", 1)
$Form1 = GUICreate("Hunterpad", 1112, 561, 147, 112)
$cEdit = GUICtrlCreateEdit("", 0, 32, 1361, 673) ; Note the ControlID <<<<<<<<<<<<<<<<<<<<<<<<<<<
GUICtrlSetData(-1, "")
$File = GUICtrlCreateMenu("&File")
$New = GUICtrlCreateMenuItem("New", $File)
$MenuItem4 = GUICtrlCreateMenuItem("Save", $File)
$MenuItem5 = GUICtrlCreateMenuItem("Save As...", $File)
$Save = GUICtrlCreateMenuItem("Open",$File)
$MenuItem7 = GUICtrlCreateMenuItem("Print", $File)
$MenuItem6 = GUICtrlCreateMenuItem("Exit", $File)
$MenuItem1 = GUICtrlCreateMenu("&Edit")
$MenuItem8 = GUICtrlCreateMenuItem("Undo", $MenuItem1)
$MenuItem9 = GUICtrlCreateMenuItem("Redo", $MenuItem1)
$MenuItem2 = GUICtrlCreateMenu("&Tools")
$MenuItem10 = GUICtrlCreateMenuItem("Font..", $MenuItem2)
$MenuItem11 = GUICtrlCreateMenuItem("Size", $MenuItem2)
$MenuItem3 = GUICtrlCreateMenu("&Help")
GUISetState(@SW_SHOW)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $New
            GUICtrlSetData($cEdit, "") ; Empty the control <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        Case $GUI_EVENT_CLOSE
            Exit
  Case $MenuItem4
   FileSaveDialog("Save","C:","All(*.*)",16,"untitled")
    EndSwitch
WEnd
Check out my new site!Current Projects:[list][*]Hunter Console - A Small Gadget[*]HunterPad - Basic Notepad aimed at Programmers[*]Betters UP! - Betting Game[/list]
Link to comment
Share on other sites

  • Moderators

Dasttann777,

The dialog only returns the name of the file to save, you still have to save it yourself. ;)

And you will need to check if the content has been changed if you want to prevent saving the same data again:

Case $MenuItem4
    ; Get current content of edit control
    $sCurrent_Edit = GUICtrlRead($cEdit)
    ; Has it changed?
    If $sCurrent_Edit <> $sSaved_Edit Then
        ; Get a filename to save to
        $sFile = FileSaveDialog("Save", "C:", "All(*.*)", 16, "untitled")
        ; Open a file overwriting any existing one
        $hFile FileOpen($sFile, 2)
        ; Write the file with the current data
        FileWrite($hFile, $sCurrent_Edit)
        ; Close the file
        FileClose($hFile)
        ; Store the current content for future comparisons
        $sSaved_Edit = $sCurrent_Edit
    EndIf

Personally I would look at hashing the edit content with _Crypt_HashData so that the size of the comparison variable does not get too large - but we might leave that to another day. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

The code is not working:

#include <GUIConstants.au3>
#include <WinAPI.au3>
Opt("TrayMenuMode", 1)
$Form1 = GUICreate("Hunterpad", 1112, 561, 147, 112)
$cEdit = GUICtrlCreateEdit("", 0, 32, 1361, 673) ; Note the ControlID <<<<<<<<<<<<<<<<<<<<<<<<<<<
GUICtrlSetData(-1, "")
$File = GUICtrlCreateMenu("&File")
$New = GUICtrlCreateMenuItem("New", $File)
$MenuItem4 = GUICtrlCreateMenuItem("Save", $File)
$MenuItem5 = GUICtrlCreateMenuItem("Save As...", $File)
$Save = GUICtrlCreateMenuItem("Open",$File)
$MenuItem7 = GUICtrlCreateMenuItem("Print", $File)
$MenuItem6 = GUICtrlCreateMenuItem("Exit", $File)
$MenuItem1 = GUICtrlCreateMenu("&Edit")
$MenuItem8 = GUICtrlCreateMenuItem("Undo", $MenuItem1)
$MenuItem9 = GUICtrlCreateMenuItem("Redo", $MenuItem1)
$MenuItem2 = GUICtrlCreateMenu("&Tools")
$MenuItem10 = GUICtrlCreateMenuItem("Font..", $MenuItem2)
$MenuItem11 = GUICtrlCreateMenuItem("Size", $MenuItem2)
$MenuItem3 = GUICtrlCreateMenu("&Help")
GUISetState(@SW_SHOW)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $New
            GUICtrlSetData($cEdit, "") ; Empty the control <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        Case $GUI_EVENT_CLOSE
            Exit
  Case $MenuItem4
    ; Get current content of edit control
    $sCurrent_Edit = GUICtrlRead($cEdit)
    ; Has it changed?
    If $sCurrent_Edit <> $sSaved_Edit Then
        ; Get a filename to save to
        $sFile = FileSaveDialog("Save", "C:", "All(*.*)", 16, "untitled")
        ; Open a file overwriting any existing one
        $hFile FileOpen($sFile, 2)
        ; Write the file with the current data
        FileWrite($hFile, $sCurrent_Edit)
        ; Close the file
        FileClose($hFile)
        ; Store the current content for future comparisons
        $sSaved_Edit = $sCurrent_Edit
    EndIf
EndSwitch
WEnd
Check out my new site!Current Projects:[list][*]Hunter Console - A Small Gadget[*]HunterPad - Basic Notepad aimed at Programmers[*]Betters UP! - Betting Game[/list]
Link to comment
Share on other sites

  • Moderators

Dasttann777,

Apologies I missed a critical line when I cut and pasted: ;)

Local $sSaved_Edit = "" ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $New
            GUICtrlSetData($cEdit, "") ; Empty the control 
        Case $GUI_EVENT_CLOSE
            Exit
        Case $MenuItem4
            ; Get current content of edit control
            $sCurrent_Edit = GUICtrlRead($cEdit)
            ; Has it changed?
            If $sCurrent_Edit <> $sSaved_Edit Then
                ; Get a filename to save to
                $sFile = FileSaveDialog("Save", "C:", "All(*.*)", 16, "untitled")
                ; Open a file overwriting any existing one
                $hFile = FileOpen($sFile, 2)
                ; Write the file with the current data
                FileWrite($hFile, $sCurrent_Edit)
                ; Close the file
                FileClose($hFile)
                ; Store the current content for future comparisons
                $sSaved_Edit = $sCurrent_Edit
            EndIf
    EndSwitch
WEnd

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

I have managed to Create 4 New Functions on my own, but now I want to create a change font dialogue, but when I try and create one, the Main GUI does not stay on the screen, but disappears after a second, any help?

#include <GUIConstants.au3>
#include <WinAPI.au3>
#Include <GuiEdit.au3>
Opt("TrayMenuMode", 1)
$Form1 = GUICreate("Hunterpad", 1112, 561, 147, 112)
$cEdit = GUICtrlCreateEdit("", 0, 32, 1361, 673)
GUICtrlSetData(-1, "")
$File = GUICtrlCreateMenu("&File")
$New = GUICtrlCreateMenuItem("New", $File)
$MenuItem4 = GUICtrlCreateMenuItem("Save", $File)
$MenuItem5 = GUICtrlCreateMenuItem("Save As...", $File)
$Save = GUICtrlCreateMenuItem("Open",$File)
$MenuItem7 = GUICtrlCreateMenuItem("Print", $File)
$MenuItem6 = GUICtrlCreateMenuItem("Exit", $File)
$MenuItem1 = GUICtrlCreateMenu("&Edit")
$MenuItem8 = GUICtrlCreateMenuItem("Undo     Ctrl-Z", $MenuItem1)
$MenuItem9 = GUICtrlCreateMenuItem("Redo     Ctrl-Y", $MenuItem1)
$MenuItem2 = GUICtrlCreateMenu("&Tools")
$MenuItem10 = GUICtrlCreateMenuItem("Font..", $MenuItem2)
$MenuItem11 = GUICtrlCreateMenuItem("Size", $MenuItem2)
$MenuItem3 = GUICtrlCreateMenu("&Help")
GUISetState(@SW_SHOW)
Local $sSaved_Edit = ""
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $New
            GUICtrlSetData($cEdit, "") ; Empty the control
        Case $GUI_EVENT_CLOSE
            Exit
  Case $Save
   $FileOpen = FileOpenDialog("","","(*.*)")
   $FileRead = FileRead($FileOpen)
   Send($FileRead)
  Case $MenuItem7
   $sPrintFile = "c:image.png"
Run('Rundll32.exe "' & @SystemDir & 'mshtml.dll",PrintHTML "' & $sPrintFile & '"', @SystemDir)
Case $MenuItem6
Exit
        Case $MenuItem4
            ; Get current content of edit control
            $sCurrent_Edit = GUICtrlRead($cEdit)
            ; Has it changed?
            If $sCurrent_Edit <> $sSaved_Edit Then
                ; Get a filename to save to
                $sFile = FileSaveDialog("Save", "C:", "All(*.*)", 16, "untitled")
                ; Open a file overwriting any existing one
                $hFile = FileOpen($sFile, 2)
                ; Write the file with the current data
                FileWrite($hFile, $sCurrent_Edit)
                ; Close the file
                FileClose($hFile)
                ; Store the current content for future comparisons
                $sSaved_Edit = $sCurrent_Edit
   EndIf
  Case $MenuItem8
   _GUICtrlEdit_Undo($cEdit)
  Case $MenuItem10
   GUICreate("Font")
   $FONTCHANGE = GUICtrlCreateButton("Change",100,100)
   $FontExample = GUICtrlCreateLabel("The quick brown fox jumps over the lazy dog",50,50)
   GUISetState(@SW_SHOW)
  Case $FONTCHANGE
   GUICtrlSetFont($FontExample, +1)
   EndSwitch
  WEnd
Edited by Dasttann777
Check out my new site!Current Projects:[list][*]Hunter Console - A Small Gadget[*]HunterPad - Basic Notepad aimed at Programmers[*]Betters UP! - Betting Game[/list]
Link to comment
Share on other sites

  • Moderators

Dasttann777,

Take a look at the Managing Multiple GUIs tutorial in the Wiki - that will show you how to deal with dialogs such as the one you are creating. :)

A couple of tips:

- 1. Give your menuitems sensible names - it will make coding much easier. :D

- 2. Do you really think your GUICtrlSetFont code will work as it is? To what are you adding 1 each time you press the button? ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Dasttann777,

Great you're getting into AutoIt, but I'm just curious to know, are you building a 'Notepad clone' to improve your knowledge of AutoIt or Notepad?

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

I am building a Clone so I can learn the Ropes of Autoit, that is all.

And I am still working on the FOnt, I just needed help with this problem.

Best way I'd recommend a user learn autoit is by randomly searching for cool scripts, play with them and change stuff until you mess it up. Gives you a good feel of how autoit works.

I've also made a habit of saving every script that seems interesting to me in a folder called "script bank", it's already grown to be 150+ mb and it's very damn handy to use when creating new scripts because I tend to separate functions that do an intended action into categories, this way I can just do a quick search through the folder, and I'll have a working script in no-time after a few copy and paste maneuvers.

I've probably got at least 30% of all the scripts in the example section separated and categorized in there.

Link to comment
Share on other sites

Best way I'd recommend a user learn autoit is by randomly searching for cool scripts, play with them and change stuff until you mess it up. Gives you a good feel of how autoit works.

I've also made a habit of saving every script that seems interesting to me in a folder called "script bank", it's already grown to be 150+ mb and it's very damn handy to use when creating new scripts because I tend to separate functions that do an intended action into categories, this way I can just do a quick search through the folder, and I'll have a working script in no-time after a few copy and paste maneuvers.

I've probably got at least 30% of all the scripts in the example section separated and categorized in there.

Yeah Okay, thanks for the advice!!
Check out my new site!Current Projects:[list][*]Hunter Console - A Small Gadget[*]HunterPad - Basic Notepad aimed at Programmers[*]Betters UP! - Betting Game[/list]
Link to comment
Share on other sites

  • 2 weeks later...

Hi

I have done quite well so far, but I am having trouble on this one function. I am trying to create a HTML Button, that when pressed will send the phrase "<html></html>", but when I made the function, it just played up. Here is the Code:

#include <GUIConstants.au3>
#include <WinAPI.au3>
Opt("TrayMenuMode", 1)
$Form1 = GUICreate("Hunterpad", 1112, 561, 147, 112)
$cEdit = GUICtrlCreateEdit("", 0, 32, 1361, 673)
GUICtrlSetData(-1, "")
$File = GUICtrlCreateMenu("&File")
$New = GUICtrlCreateMenuItem("New", $File)
$MenuItem4 = GUICtrlCreateMenuItem("Save", $File)
$MenuItem5 = GUICtrlCreateMenuItem("Save As...", $File)
$Save = GUICtrlCreateMenuItem("Open", $File)
$MenuItem7 = GUICtrlCreateMenuItem("Print", $File)
$MenuItem6 = GUICtrlCreateMenuItem("Exit", $File)
$MenuItem1 = GUICtrlCreateMenu("&Edit")
$MenuItem8 = GUICtrlCreateMenuItem("Undo  (Press Ctrl-Z)", $MenuItem1)
$MenuItem9 = GUICtrlCreateMenuItem("Redo  (Press Ctrl-Y)", $MenuItem1)
$MenuItem3 = GUICtrlCreateMenu("&Help")
$About = GUICtrlCreateMenuItem("About... (Shuts down Hunterpad)", $MenuItem3)
$HTU = GUICtrlCreateMenuItem("&Help (Shuts down Hunterpad)", $MenuItem3)
$HTML = GUICtrlCreateButton("&Html",20,5)
GUISetState(@SW_SHOW)
Local $sSaved_Edit = ""
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $HTML
   Send("<html></html>")
  Case $New
   GUICtrlSetData($cEdit, "") ; Empty the control
  Case $GUI_EVENT_CLOSE
   Exit
  Case $Save
   $FileOpen = FileOpenDialog("", "", "(*.*)")
   $FileRead = FileRead($FileOpen)
   Send($FileRead)
  Case $MenuItem7
   $sPrintFile = "c:image.png"
  Case $HTU
   MsgBox(0, "Help", "Hunterpad is easy to use, and very basic.                                                     ||Change Notes: 1.0 - Hunterpad Released                                             Here are the current Hotkeys: Ctrl-Z - Undo Ctrl-Y - Redo")
  Case $About
   MsgBox(0, "About", "Made by Dasttann_Software Designer_Website Builder_Computer Fanatic>>>>>>>>>>>Hunter Version: 1.0>>>>>>>>>>>>>>")
   Run('Rundll32.exe "' & @SystemDir & 'mshtml.dll",PrintHTML "' & $sPrintFile & '"', @SystemDir)
  Case $MenuItem6
   Exit
   Case $MenuItem4
   ; Get current content of edit control
   $sCurrent_Edit = GUICtrlRead($cEdit)
   ; Has it changed?
   If $sCurrent_Edit <> $sSaved_Edit Then
    ; Get a filename to save to
    $sFile = FileSaveDialog("Save", "C:", "All(*.*)", 16, "untitled")
    ; Open a file overwriting any existing one
    $hFile = FileOpen($sFile, 2)
    ; Write the file with the current data
    FileWrite($hFile, $sCurrent_Edit)
    ; Close the file
    FileClose($hFile)
    ; Store the current content for future comparisons
    $sSaved_Edit = $sCurrent_Edit
   EndIf
  EndSwitch
WEnd
Check out my new site!Current Projects:[list][*]Hunter Console - A Small Gadget[*]HunterPad - Basic Notepad aimed at Programmers[*]Betters UP! - Betting Game[/list]
Link to comment
Share on other sites

You should know by now that when you want to add data to an AutoIt Edit control you use GUICtrlSetData not Send.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Thankyou so much for the help.

I am in the middle of adding mre functions to my Hunterpad known as "Traps", in which you type in a group of text, and then when you click on the Release Button, the text you wrote in the Trap Window will be inserted into the text. I have done quite well so far, but the text replaces all of my other text, instead of adding it. Should I use a string, or what do I do?

My Code:

#include <GUIConstants.au3>
#include <GuiStatusBar.au3>
#include <WinAPI.au3>
Opt("TrayMenuMode", 1)
$Form1 = GUICreate("Hunterpad", 1112, 561, 147, 112)
$cEdit = GUICtrlCreateEdit("", 0, 32, 1361, 673)
GUICtrlSetData(-1, "")
GUICtrlCreateLabel(StringLen($cEdit),50,10)
$File = GUICtrlCreateMenu("&File")
$New = GUICtrlCreateMenuItem("New", $File)
$MenuItem4 = GUICtrlCreateMenuItem("Save", $File)
$MenuItem5 = GUICtrlCreateMenuItem("Save As...", $File)
$Save = GUICtrlCreateMenuItem("Open", $File)
$MenuItem7 = GUICtrlCreateMenuItem("Print", $File)
$MenuItem6 = GUICtrlCreateMenuItem("Exit", $File)
$MenuItem1 = GUICtrlCreateMenu("&Edit")
$MenuItem8 = GUICtrlCreateMenuItem("Undo  (Press Ctrl-Z)", $MenuItem1)
$MenuItem9 = GUICtrlCreateMenuItem("Redo  (Press Ctrl-Y)", $MenuItem1)
$MenuItem3 = GUICtrlCreateMenu("&Help")
$About = GUICtrlCreateMenuItem("About... (Shuts down Hunterpad)", $MenuItem3)
$HTU = GUICtrlCreateMenuItem("&Help ", $MenuItem3)
$HTML = GUICtrlCreateButton("&Html",20,5)
$Pin1 = GUICtrlCreateButton("Rusty Trap",100,5)
$Release = GUICtrlCreateButton("Release Rusty",160,5)
_GUICtrlStatusBar_Create($cEdit)
GUISetState(@SW_SHOW)
Local $sSaved_Edit = ""
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $HTML
   GUICtrlSetData($cEdit,"<html><head></head><body></body></html>")
  Case $Pin1
   $PinI = InputBox("Rusty Trap", "Have a document Draft, that you do not want to lose, but need to temporarily store? Copy and Paste the Text into here, you can reuse it with the Release Rusty Button!(Use Carefully as it will replace all of your current text")
  Case $New
   GUICtrlSetData($cEdit, "") ; Empty the control
  Case $GUI_EVENT_CLOSE
   Exit
  Case $Release
   GUICtrlSetData($cEdit,$PinI)
  Case $Save
   $FileOpen = FileOpenDialog("", "", "Html Documents(* .html)|Text Documents(*.txt)|All(*.*)")
   $FileRead = FileRead($FileOpen)
   Send($FileRead)
  Case $MenuItem7
   $sPrintFile = "c:image.png"
  Case $HTU
   MsgBox(0, "Help", "Hunterpad is easy to use, and very basic.                                                     ||Change Notes: 1.0 - Hunterpad Released                                             Here are the current Hotkeys: Ctrl-Z - Undo Ctrl-Y - Redo")
  Case $About
   MsgBox(0, "About", "Made by Dasttann_Software Designer_Website Builder_Computer Fanatic>>>>>>>>>>>Hunter Version: 1.0>>>>>>>>>>>>>>")
   Run('Rundll32.exe "' & @SystemDir & 'mshtml.dll",PrintHTML "' & $sPrintFile & '"', @SystemDir)
  Case $MenuItem6
   Exit
   Case $MenuItem4
   ; Get current content of edit control
   $sCurrent_Edit = GUICtrlRead($cEdit)
   ; Has it changed?
   If $sCurrent_Edit <> $sSaved_Edit Then
    ; Get a filename to save to
    $sFile = FileSaveDialog("Save", "C:", "All(*.*)", 16, "untitled")
    ; Open a file overwriting any existing one
    $hFile = FileOpen($sFile, 2)
    ; Write the file with the current data
    FileWrite($hFile, $sCurrent_Edit)
    ; Close the file
    FileClose($hFile)
    ; Store the current content for future comparisons
    $sSaved_Edit = $sCurrent_Edit
   EndIf
  EndSwitch
WEnd

Much Help will be appreciated

;)

Edited by Dasttann777
Check out my new site!Current Projects:[list][*]Hunter Console - A Small Gadget[*]HunterPad - Basic Notepad aimed at Programmers[*]Betters UP! - Betting Game[/list]
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...