Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/15/2014 in all areas

  1. Jon

    AutoIt v3.3.13.4 Beta

    Also enabled an updated version of the experimental datatype from way back. An idea of the syntax is below Dim $var[] $var["hello1"] = "1111" $var["HELLO1"] = "1111 - CAPS" $var.hello2 = "2222" $var[3] = "3333" $var.Append("4444") MsgBox(0, "", $var["hello1"]) MsgBox(0, "", $var["HELLO1"]) MsgBox(0, "", $var.hello2) MsgBox(0, "", $var[3]) MsgBox(0, "", $var[4]) MsgBox(0, "Exists - hello1", $var.Exists("hello1")) MsgBox(0, "Exists - hello9", $var.Exists("hello9")) For $key In $var.keys() MsgBox(0, "Keys", "Key: " & $key & @CRLF & "Key type: " & VarGetType($key)) Next For $item In $var MsgBox(0, "Items", "Item: " & $item) Next $var.Remove("hello2") For $key In $var.keys() MsgBox(0, "Keys", "Key: " & $key & @CRLF & "Key type: " & VarGetType($key)) Next Experimental, may be removed, yadda yadda yadda. It's like a php map/lua table combo. Keys are string or integer and order is maintained based on the order they are added. String keys are case sensitive (for now). Keys can be enumerated with Keys() in a For In loop. Key type can be checked with VarGetType/IsString. Items can be enumerated with For In loop. Check if a key exists using Exists() Remove items using Remove() Unnamed items can be added using Append(). These are given the largest integer key so far (php influence). Maybe remove Append() and overload the += operator - not sure. Edit: Oh and I had to rewrite half of the COM parser to make this work how I wanted. I may have broken all of COM.
    3 points
  2. If you have been using AutoIt for any length of time you will know that it is a great, and powerful scripting language. As with all powerful languages there comes a downside. Virus creation by those that are malicious. AutoIt has no virii installed on your system, and if a script you have created has been marked as a virus, (and you're not malicious) then this is a false positive. They found a set of instructions in an AutoIt EXE out there somewhere, took the general signature of the file, and now all AutoIt EXE's are marked (or most of them). This can be due to several reasons. AutoIt is packed with UPX. UPX is an open source software compression packer. It is used with many virii (to make them smaller). Malicious scripter got the AutoIt script engine recognized as a virus. And I am sure there are more ways your executable could be marked, but that covers the basics. Now I am sure you are wanting to know what you can do to get back up and running without being recognized as a virus. You have to send in a report to the offending AV company alerting them to the false positive they have made. It never hurts to send in your source code along with a compiled exe, to help them realize their mistake. You may have to wait up to 24 hours for them to release an update. The time it takes really depends on the offending AV company. Anti-Virus Links AntiVir Website Contact Avast! Website Contact McAfee Website Contact (email address) Symantec (Norton) Website Contact AVG Website Contact (It says sales or other ?'s I assume this will work) ClamWin Website Contact ClamAV Website Contact (I would only contact the ones with "virusdb maintainer or virus submission management") BitDefender Website Contact ZoneLabs Website Contact Norman Website Contact (email address) eSafe Website Contact (login required) A2 (A-Squared) Website Contact (email address) Edit: Added Website links and Contact links. I hope this helps you understand why your AutoIt executables are marked as virii. JS
    1 point
  3. Outshynd

    Using AutoItX3 in C#

    I wrote this for another forum but I figured I'd post it here as well. Hopefully it'll help some poor, lost soul. C# is a much faster and more complete language than AutoIt. That said, it's also far more difficult to do simple tasks that AutoIt does quite well. You have to write your own MouseMove functions, your own WinActivate functions, your own everything functions (nearly). This is because AutoIt is a Windows automation tool and C# is an actual programming language. Well, can we have the best of both worlds? Sure. This describes how to add AutoItX (the AutoIt COM Library DLL) to your C# (or other .NET) project and then execute a few simple instructions. http://www.nomorepasting.com/paste.php?pasteID=72980 using System; using System.Threading; namespace AutoItXTest { class Program { static AutoItX3Lib.AutoItX3Class au3; //our au3 class that gives us au3 functionality static Thread thread; //our thread static bool threadshouldexecute = true; //only execute thread 2 while this equals true static int i = 0; //our incrementer /// <summary> /// The entry point, or main thread / main loop, of our program /// </summary> static void Main(string[] args) { au3 = new AutoItX3Lib.AutoItX3Class(); //initialize our au3 class library au3.AutoItSetOption("WinTitleMatchMode", 4); //advanced window matching thread = new Thread(new ThreadStart(threadtest)); //initialize and start our thread thread.Start(); if (au3.WinExists("Untitled - Notepad", "") == 0) //if an Untitled - Notepad document doesn't exist au3.Run(@"C:\WINDOWS\SYSTEM32\notepad.exe", "", au3.SW_SHOW); //run notepad else au3.WinActivate("Untitled - Notepad", ""); //otherwise activate the window string hWnd = ""; //let's use a window handle while (hWnd.Length == 0) //try to get a handle to notepad until it succeeds hWnd = au3.WinGetHandle("Untitled - Notepad", ""); while (au3.WinActive("handle=" + hWnd, "") == 0) //loop while it's not active { au3.WinActivate("handle=" + hWnd, ""); //and activate it Thread.Sleep(100); } while (au3.WinExists("handle=" + hWnd, "") != 0) //while the window exists, loop { //send our incrementing variable, i, to notepad, with a trailing | au3.ControlSend("handle=" + hWnd, "", "Edit1", i.ToString() + "|", 0); i++; //increment i Thread.Sleep(100); //short sleep so we don't burn CPU } //if the while loop exited--because there's no Untitled - Notepad--make the other thread stop executing threadshouldexecute = false; Console.Write("Press [ENTER] to continue..."); //tell the user to press ENTER to quit Console.ReadLine(); //pause until enter is pressed } /// <summary> /// our void function to execute thread #2 /// </summary> static void threadtest() { while (threadshouldexecute) //loop while this thread should execute { au3.ToolTip("Thread 2\ni: " + i.ToString(), 0, 0); //display a tooltip with the incrementing variable i in it Thread.Sleep(50); //sleep to free up CPU } au3.ToolTip("", 0, 0); //clear the tooltip after loop is done } } }
    1 point
  4. 1 point
  5. guinness

    Dim deprecated ?

    I was slow because I wrote an example this time!
    1 point
  6. guinness

    Dim deprecated ?

    It still has its uses, like the following... Local $aArray = 0 Example($aArray) $aArray = 0 ExampleWithoutDim($aArray) Func Example(ByRef $aArray) If Not UBound($aArray) Then Dim $aArray[10] ; ReDim doesn't work on non-array datatypes, so then to re-use the same variable as an array then Dim can be used. EndFunc Func ExampleWithoutDim(ByRef $aArray) If Not UBound($aArray) Then Local $aTemp[10] ; Create a temporary array. $aArray = $aTemp ; Re-assign. $aTemp = 0 ; Destory the temp array. EndIf EndFunc
    1 point
  7. Luigi

    TCP Server

    I like "Valeu"!
    1 point
  8. FaridAgl

    AutoIt v3.3.13.4 Beta

    I guess some modification in Au3Check is required: Global Const $tblPerson[] $tblPerson.FirstName = "Farid" Also here is a snippet which I guess it will give you some idea about how useful this new feature could be: Global $tblApple[] $tblApple.Name = "Apple" $tblApple.Color = "Blue" $tblApple.Price = 10 Global $tblOrange[] $tblOrange.Name = "Orange" $tblOrange.Color = "Green" $tblOrange.Price = 7 Global $tblBanana[] $tblBanana.Name = "Banana" $tblBanana.Color = "Red" $tblBanana.Price = 13 Global $tblFruits[] $tblFruits.Apple = $tblApple $tblFruits.Orange = $tblOrange $tblFruits.Banana = $tblBanana For $tblFruit In $tblFruits For $vProperty In $tblFruit ConsoleWrite($vProperty & @CRLF) Next ConsoleWrite(@CRLF) Next Edit: Seems like With...EndWith would also be modified a bit:
    1 point
  9. ct253704, You are only reading the checkbox states once immediately after the GUI is created - you need to read them as the install process begins: Case $Install $EchoValue = GUICtrlRead($ECHO) $BarracudaValue = GUICtrlRead($Barracuda) Switch $EchoValue ; [...] M23
    1 point
  10. careca

    Beats Player

    Version 2.0 on the way! Added ability to change background color! Changed code + minor tweaks Removed rarely used features (EDIT: Bug testing)
    1 point
  11. water

    help autoit beginner

    Would you please be so kind to give meaningful titles to your threads? Everyone on this forum is looking for help
    1 point
  12. Open Windows Explorer to any folder, set it up exactly how you'd like it to look, click the Tools menu, Folder Options, View tab, click the Apply to Folders button.
    1 point
  13. Jon

    AutoIt v3.3.13.3 Beta

    File Name: AutoIt v3.3.13.3 Beta File Submitter: Jon File Submitted: 15 Jul 2014 File Category: Beta 3.3.13.3 (15th July, 2014) (Beta) AutoIt: - Fixed #2626: ControlGetText(), WinGetText(), WinGetTitle() wrong encoding for some words. - Fixed: FileCopy() regression from last beta on UNC paths. UDFs: - Added: $SS_ENHMETAFILE, $SS_REALSIZECONTROL, $STM_SETICON, $STM_GETICON, $STM_SETIMAGE, $STM_GETIMAGE to StaticConstants.au3. Click here to download this file
    1 point
  14. uhm my s key doesnt work anymore? i thi cuz of the cript?
    1 point
  15. Jon

    AutoIt v3.3.13.3 Beta

    Also enabled an updated version of the experimental datatype from way back. An idea of the syntax is below Dim $var[] $var["hello1"] = "1111" $var["HELLO1"] = "1111 - CAPS" $var.hello2 = "2222" $var[3] = "3333" $var.Append("4444") MsgBox(0, "", $var["hello1"]) MsgBox(0, "", $var["HELLO1"]) MsgBox(0, "", $var.hello2) MsgBox(0, "", $var[3]) MsgBox(0, "", $var[4]) MsgBox(0, "Exists - hello1", $var.Exists("hello1")) MsgBox(0, "Exists - hello9", $var.Exists("hello9")) For $key In $var.keys() MsgBox(0, "Keys", "Key: " & $key & @CRLF & "Key type: " & VarGetType($key)) Next For $item In $var MsgBox(0, "Items", "Item: " & $item) Next $var.Remove("hello2") For $key In $var.keys() MsgBox(0, "Keys", "Key: " & $key & @CRLF & "Key type: " & VarGetType($key)) Next Experimental, may be removed, yadda yadda yadda. It's like a php map/lua table combo. Keys are string or integer and order is maintained based on the order they are added. String keys are case sensitive (for now). Keys can be enumerated with Keys() in a For In loop. Key type can be checked with VarGetType/IsString. Items can be enumerated with For In loop. Check if a key exists using Exists() Remove items using Remove() Unnamed items can be added using Append(). These are given the largest integer key so far (php influence). Maybe remove Append() and overload the += operator - not sure. Edit: Oh and I had to rewrite half of the COM parser to make this work how I wanted. I may have broken all of COM.
    1 point
  16. #include <File.au3> #include <GDIPlus.au3> #include <MsgBoxConstants.au3> Global Const $sInFolder = "In\" ; The folder where all your original .pngs are Global Const $sOutFolder = "Out\" ; The folder where the new .pngs will be stored ; Generate a list of all the png files in $sInFolder Global $asList = _FileListToArray($sInFolder, "*.png", 1, False) If @error Then Switch @error Case 1 _ErrMsgExit("Folder not found or invalid, " & $sInFolder, -11) Case 2 _ErrMsgExit("Invalid _FileListToArray() filter supplied", -12) Case 3 _ErrMsgExit("Invalid _FileListToArray() Flag", -13) Case 4 _ErrMsgExit("No files found in " & $sInFolder, -14) EndSwitch EndIf ; Crop the images _GDIPlus_Startup() ; I'm assuming that all the input files are different sizes and that the top left (0, 0) ; needs to be cropped into a 500 x 400 frame (NOTE: if the file is too small (under 500 x 400) then a blank space will occur) Global $hImage, $hNewImage, $hCtxt, $sErrorList = "" For $i = 1 To $asList[0] ; Loop through all files $hImage = _GDIPlus_ImageLoadFromFile($asList[$i]) ; Attempt to load file If @error Then _StringAppend($sErrorList, "Error loading file: """ & $asList[$i] & """ @extended = " & @extended) ContinueLoop ; Start the loop again since we can't use this image EndIf $hNewImage = _GDIPlus_BitmapCreateFromScan0(500, 400) ; Creata a blank 500 x 400 bitmap $hCtxt = _GDIPlus_ImageGetGraphicsContext($hNewImage) ; Get the GraphicsContext of an image (so we can write to it) ; _GDIPlus_GraphicsClear($hCtxt, 0xFF000000) ; Uncomment if you want the background to be a solid colour _GDIPlus_GraphicsDrawImageRectRect( _ $hCtxt, $hImage, _ 0, 0, 500, 400, _ ; Source image ($hImage) (X, Y, Width, Height) (ie. Take data from $hImage at XY 0, 0 with a width of 500 and height of 400) 0, 0, 500, 400, _ ; Destination image ($hCtxt -> $hNewImage) (ie. Write to $hNewImage at XY 0, 0 with a width of 500 and height of 400) ) ; Note: Keep the source image and destination image Width / Height the same to prevent resizing ; At this point $hNewImage contains the new data _GDIPlus_GraphicsDispose($hCtxt) ; We no longer need to write to it, so get rid of it _GDIPlus_ImageDispose($hImage) ; We no longer need to read from it, so get rid of it _GDIPlus_ImageSaveToFile($hNewImage, $sOutFolder & $asList[$i]) ; Write $hNewImage to the folder If @error Then _StringAppend($sErrorList, "Error saving file: """ & $sOutFolder & $asList[$i] & """ @extended = " & @extended) EndIf _GDIPlus_ImageDispose($hNewImage) ; Don't need it anymore Next If $sErrorList <> "" Then MsgBox($MB_OK + $MB_ICONWARNING, "Warning", "The following errors have occured:" & @CRLF & @CRLF & $sErrorList) EndIf _GDIPlus_Shutdown() Func _ErrMsgExit($sMsg, $iCode, $iLine = @ScriptLineNumber) If Not @Compiled Then $sMsg = "An error occured on line " & $iLine & ":" & @CRLF & @CRLF & $sMsg MsgBox($MB_OK + $MB_ICONERROR, "Critical error", $sMsg) Exit $iCode EndFunc ;==>_ErrMsgExit Func _StringAppend(ByRef $sString, $sAppend, $sDelim = @CRLF) #cs If $sString = "" Then $sString &= $sAppend Else $sString &= $sDelim & $sAppend EndIf #ce ; Same as above, but with the Ternary operator $sString &= (($sString = "") ? ("") : ($sDelim)) & $sAppend Return 1 EndFunc ;==>_StringAppend
    1 point
  17. mLipok

    _ArrayAdd problem

    If I can do this I would like to add my own thoughts. I am a former student (oh gosh it's almost 10 years ago), I would prefer if it was explained to me by way of a code abstraction and conceptual framework. If the documentation says: Can be a combination of the following: $FO_READ (0) = Read mode (default) $FO_APPEND (1) = Write mode (append to end of file) $FO_OVERWRITE (2) = Write mode (erase previous contents) $FO_CREATEPATH (8) = Create directory structure if it doesn't exist (See Remarks). $FO_BINARY (16) = Force binary mode (See Remarks). $FO_UNICODE or $FO_UTF16_LE (32) = Use Unicode UTF16 Little Endian reading and writing mode. Reading does not override existing BOM. $FO_UTF16_BE (64) = Use Unicode UTF16 Big Endian reading and writing mode. Reading does not override existing BOM. $FO_UTF8 (128) = Use Unicode UTF8 (with BOM) reading and writing mode. Reading does not override existing BOM. $FO_UTF8_NOBOM (256) = Use Unicode UTF8 (without BOM) reading and writing mode. $FO_UTF8_FULL (16384) = When opening for reading and no BOM is present, use full file UTF8 detection. If this is not used then only the initial part of the file is checked for UTF8. The folder path must already exist (except using $FO_CREATEPATH mode - See Remarks). Constants are defined in FileConstants.au3 it is enough to say once at the beginning of the lecture, the importance and value of the constant, and then use it as an abstract notion. And after that it is easier to read and analyze this: Local $hFileOpen = FileOpen($sFilePath, $FO_READ + $FO_OVERWRITE) then: Local $hFileOpen = FileOpen($sFilePath, 0 + 2) In this way, faster and better develops the mind of the student. After some time getting used to, reading the code, it reads contextually, and do not need to focus on the meaning of the numbers. btw. With one to agree, everyone should at least once to know the value of constants, which is why every time I see the documentation that deficiencies in this area, I try to immediately react by TrackTickets. ps. I have a didactical training, but I practice just as much as I lead trainings and presentations with my clients.
    1 point
  18. 1 point
  19. It's not a plugin - I have a page of mods that I have to make to the core IP files to make it work - it's very painful. In the end it uses the geshi "autoit.php" file (in the Extras folder in the AutoIt installation).  If you can get a generic geshi plugin working then this autoit.php might be what you need.
    1 point
  20. Hi , I want to use Autoit in C# so after adding reference and using below code ,I am able to invoke my application in C# using Visual Studio2010 using System; using System.Text; using AutoItX3Lib; using System.Runtime.InteropServices; namespace useAutoItCode { class Program { public static void Main(string[] args) { AutoItX3Lib.AutoItX3 autoit = new AutoItX3Lib.AutoItX3(); autoit.Run(@"C:\ApplicationPath.EXE","",autoit.SW_SHOW); } I want to access Menu, tree view option of my application hence by referring to below code it is working in AUTOIT editor. I am new to Autoit and programming and want to know how to use directives #include <GuiTreeView.au3> and access menu,tree view objects in C#. Could you please advice? Thank you #include <GUIConstantsEx.au3> #include <GuiTreeView.au3> #include <WindowsConstants.au3> Example() Func Example() Local $aidItem[10], $iRand, $idTreeView Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS) GUICreate("TreeView Select Item", 400, 300) $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE) GUISetState(@SW_SHOW) _GUICtrlTreeView_BeginUpdate($idTreeView) For $x = 0 To 9 $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $idTreeView) For $y = 1 To 3 GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Child", $y), $aidItem[$x]) Next Next _GUICtrlTreeView_EndUpdate($idTreeView) $iRand = Random(0, 9, 1) _GUICtrlTreeView_SelectItem($idTreeView, $aidItem[$iRand]) ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example
    1 point
  21. It's me, who should say thanks. Sorry if it took a while to update the translation.
    1 point
  22. water

    Excel Save

    In the latest version the command syntax has changed a bit: _Excel_BookOpen _Excel_BookSave _Excel_BookClose
    1 point
  23. '?do=embed' frameborder='0' data-embedContent>>
    1 point
  24. Hi, I was wondering why there is no panel control in autoit, this can be useful for moving/hidding more than one control at time. I have made some searches and I found nothing on it so I decided to create an UDF on it. In order to do that, It creates child GUIs and you can manage it as real controls (coord mode based on the parent GUI and not on the screen), so I have made it to be really easy in use like any other ctrl. Preview : Example : #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include "GUIPanel_UDF.au3" Opt("GUIOnEventMode", 1) Global $sLogo4imgPath = @ProgramFilesDir & "\AutoIt3\Examples\GUI\logo4.gif" Global $iPanel1step = 0, $iPanel3step = 0 #region GUI $GUI = GUICreate("GUIPanel UDF - Example", 400, 350) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") GUICtrlCreateLabel("Label on the GUI", 300, 320) #region Panel1 $hPanel1 = _GUICtrlPanel_Create($GUI, "Coords", 10, 40, 200, 50) _GUICtrlPanel_SetBackground($hPanel1, 0xFF0000) GUICtrlCreateLabel("Label on the Panel1", 5, 5, 95, 13) $btnPanel1 = GUICtrlCreateButton("Swap with Panel4", 10, 20, 100, 22) GUICtrlSetOnEvent($btnPanel1, "_Panel1_BtnEvent") #endregion Panel1 #region Panel2 $hPanel2 = _GUICtrlPanel_Create($GUI, "BottomLeft", 0, 0, 200, 100, $WS_BORDER, @SW_SHOWNA, 0x00FF00) GUICtrlCreateLabel("Label on the Panel2", 5, 5, 95, 13) #region Panel2Sub $hPanel2Sub = _GUICtrlPanel_Create($hPanel2, "CenterRight", 0, 0, 120, 30, $WS_BORDER, @SW_SHOWNA) Global $aGUIPanelExample_Panel2SubPos = _GUICtrlPanel_GetPos($hPanel2Sub) GUICtrlCreateLabel("Pos (X, Y) : " & $aGUIPanelExample_Panel2SubPos[0] & ", " & $aGUIPanelExample_Panel2SubPos[1], 5, 8, 100, 13) #endregion #endregion Panel2 #region Panel3 $hPanel3 = _GUICtrlPanel_Create($GUI, "Centered", 0, 0, 169, 68, $WS_BORDER, @SW_SHOWNA, $sLogo4imgPath) $btnPanel3 = GUICtrlCreateButton("Move me", 10, 10, 70, 22) GUICtrlSetOnEvent($btnPanel3, "_Panel3_BtnEvent") GUICtrlCreateCheckbox("no event", 70, 55, 68, 13) GUICtrlSetBkColor(-1, 0xFFFFFF) #endregion Panel3 #region Panel4 $hPanel4 = _GUICtrlPanel_Create($GUI, "TopRight", 0, 0, 100, 50, $WS_BORDER) GUICtrlCreateCombo("Panel4", 10, 10, 80) #endregion Panel4 GUISetState(@SW_SHOW, $GUI) #endregion GUI While 1 Sleep(1000) WEnd Func _Panel3_BtnEvent() Switch $iPanel3step Case 0 _GUICtrlPanel_SetPos($hPanel3, "CenterRight") GUICtrlSetData($btnPanel3, "Hide me") Case 1 _GUICtrlPanel_SetState($hPanel3, @SW_HIDE) EndSwitch $iPanel3step += 1 EndFunc ;==>_Panel3_BtnEvent Func _Panel1_BtnEvent() Switch $iPanel1step Case 0 _GUICtrlPanel_SetPos($hPanel1, "TopRight") _GUICtrlPanel_SetPos($hPanel4, "Coords", 10, 40) GUICtrlSetData($btnPanel1, "Disable me") Case 1 _GUICtrlPanel_SetState($hPanel1, @SW_DISABLE) GUICtrlSetData($btnPanel1, "Disabled") EndSwitch $iPanel1step += 1 EndFunc ;==>_Panel1_BtnEvent Func _Exit() Exit EndFunc ;==>_Exit Attachments : GUIPanel_UDF.au3 (Previous: 279 downloads) GUIPanel_Example.au3 Enjoy !
    1 point
  25. This a Text Editor I Made to Be Like Notepad and it Turned out better than i thought it would. (Updated (7-7-12) +Added HotKeys +Added Misc. Options (All Caps, All Lowercase, Readonly +Moved Default and Custom Options to there own Menus Under Edit +Cleaned up Code a little Bit +Added Cut, Copy, And Paste to Edit Menu -There is still a small Bug with word wrap. When you turn it off it appears to be off but its not. (Adds Horizontal Scroll bar at bottom) +Im Currently working on a 'Run Script' Option and have added it under an 'Action' Menu but it is disabled. (Updated 7-3-12) +Added Word Wrap Option +Fixed Save Bug (Updated 6-29-12) +Fixed a compilation bug It Would be best to download the Archive and Extract the Script because some stuff is wierd when you copy the code and paste it into a Script. Like Hotkeys Being displayed in the Menus. #NoTrayIcon #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=Icon.ico #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GUIEdit.au3> #include <Misc.au3> #include <GUIStatusBar.au3> #include <GUIMenu.au3> #include <SendMessage.au3> ;Created by ReaperX FileCheck() Main() SetFileAttr() Func FileCheck() If FileExists(@ScriptDir & "/config.ini") Then $CE = IniReadSectionNames(@ScriptDir & "/config.ini") If $CE[0] > 0 Then For $i = 2 To $CE[0] If Not FileExists($CE[$i]) Then IniDelete(@ScriptDir & "/config.ini", $CE[$i]) Next EndIf Main() Else IniWrite(@ScriptDir & "/config.ini", "CONFIG", "fontname", "Arial") IniWrite(@ScriptDir & "/config.ini", "CONFIG", "fontsize", "11") IniWrite(@ScriptDir & "/config.ini", "CONFIG", "fontcolor", "0x000000") IniWrite(@ScriptDir & "/config.ini", "CONFIG", "fontweight", "400") IniWrite(@ScriptDir & "/config.ini", "CONFIG", "bgcolor", "0xFFFFFF") IniWrite(@ScriptDir & "/config.ini", "CONFIG", "attributes", "0") IniWrite(@ScriptDir & "/config.ini", "CONFIG", "wordwrap", "1") IniWrite(@ScriptDir & "/config.ini", "CONFIG", "file", "") EndIf Sleep(100) EndFunc ;==>FileCheck Func Main() Global Const $GUI_TITLE = "Text Editor v2.8" Global Const $GUI_STYLE = BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS) Local $Ext = ".au3 ,.bat ,.vbs ,.htm ,.html" ; Script Types Allowed to Be Executed (Only Extensions) If IniRead(@ScriptDir & "/config.ini", "CONFIG", "wordwrap", "1") = 1 Then Global $EDIT_STYLE = BitOR($ES_WANTRETURN, $WS_VSCROLL) Else Global $EDIT_STYLE = $GUI_SS_DEFAULT_EDIT EndIf $Main = GUICreate($GUI_TITLE, 650, 280, -1, -1, $GUI_STYLE) GUISetIcon("Icon.ico") ;File Menu ======================================================================== $FileMenu = GUICtrlCreateMenu("File") $New = GUICtrlCreateMenuItem("New Ctrl+N", $FileMenu) HotKeySet("^n", "_New") $Open = GUICtrlCreateMenuItem("Open Ctrl+O", $FileMenu) HotKeySet("^o", "_Open") $Save = GUICtrlCreateMenuItem("Save Ctrl+S", $FileMenu) HotKeySet("^s", "_Save") $SaveAs = GUICtrlCreateMenuItem("Save As...", $FileMenu) GUICtrlCreateMenuItem("", $FileMenu) $Exit = GUICtrlCreateMenuItem("Exit", $FileMenu) ;================================================================================= ;View Menu ======================================================================= $ViewMenu = GUICtrlCreateMenu("View") $DocInfo = GUICtrlCreateMenuItem("Document Info", $ViewMenu) ;================================================================================= ;Action Menu ===================================================================== $ActionMenu = GUICtrlCreateMenu("Action") $Run = GUICtrlCreateMenuItem("Run Script", $ActionMenu) GUICtrlSetState($Run, $GUI_DISABLE) ;================================================================================= ;Edit Menu ======================================================================= $EditMenu = GUICtrlCreateMenu("Edit") $Undo = GUICtrlCreateMenuItem("Undo Ctrl+Z", $EditMenu, 0) HotKeySet("^z", "_Undo") GUICtrlCreateMenuItem("", $EditMenu, 1) $Cut = GUICtrlCreateMenuItem("Cut Ctrl+X", $EditMenu, 2) $Copy = GUICtrlCreateMenuItem("Copy Ctrl+C", $EditMenu, 3) $Paste = GUICtrlCreateMenuItem("Paste Ctrl+P", $EditMenu, 4) GUICtrlCreateMenuItem("", $EditMenu, 5) $Find = GUICtrlCreateMenuItem("Find... Ctrl+F", $EditMenu, 6) HotKeySet("^f", "_Find") GUICtrlCreateMenuItem("", $EditMenu, 7) ;Edit -> Default Settings Menu =================================================== Local $DefaultSett = GUICtrlCreateMenu("Default Settings", $EditMenu, 8) $DefaultFont = GUICtrlCreateMenuItem("Edit Default Font", $DefaultSett) $DefaultBGColor = GUICtrlCreateMenuItem("Edit Default BG Color", $DefaultSett) $ResetDefaults = GUICtrlCreateMenuItem("Reset Default Settings", $DefaultSett) ;================================================================================= GUICtrlCreateMenuItem("", $EditMenu, 9) ;Edit -> Custom Settings Menu ==================================================== Local $CustomSett = GUICtrlCreateMenu("Custom Settings", $EditMenu, 10) $CustomFont = GUICtrlCreateMenuItem("Set Custom Font", $CustomSett) GUICtrlSetState(-1, $GUI_DISABLE) $CustomBGColor = GUICtrlCreateMenuItem("Set Custom BG Color", $CustomSett) GUICtrlSetState(-1, $GUI_DISABLE) $EraseCustomOpt = GUICtrlCreateMenuItem("Erase Custom Settings", $CustomSett) GUICtrlSetState(-1, $GUI_DISABLE) ;================================================================================= GUICtrlCreateMenuItem("", $EditMenu, 11) $SetFileAttr = GUICtrlCreateMenuItem("Set File Attributes", $EditMenu, 12) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlCreateMenuItem("", $EditMenu, 13) ;Edit -> Misc Options Menu ======================================================= $MiscOptions = GUICtrlCreateMenu("Misc. Options", $EditMenu, 14) Local $Readonly = GUICtrlCreateMenuItem("Readonly", $MiscOptions) GUICtrlSetState(-1, $GUI_UNCHECKED) $CAPS = GUICtrlCreateMenuItem("All Caps (Not CAPS Lock)", $MiscOptions) GUICtrlSetState(-1, $GUI_UNCHECKED) $LOWERCASE = GUICtrlCreateMenuItem("All Lowercase", $MiscOptions) GUICtrlSetState(-1, $GUI_UNCHECKED) ;================================================================================= $SelectAll = GUICtrlCreateMenuItem("Select All Ctrl+A", $EditMenu, 15) HotKeySet("^a", "_SelectAll") $TimeAndDate = GUICtrlCreateMenuItem("Insert Time/Date F7", $EditMenu, 16) HotKeySet("{F7}", "_TimeAndDate") $SpeakText = GUICtrlCreateMenuItem("Speak Highlighted Text", $EditMenu, 17) $WordWrap = GUICtrlCreateMenuItem("Word Wrap", $EditMenu, 18) If IniRead(@ScriptDir & "/config.ini", "CONFIG", "wordwrap", "1") = 1 Then GUICtrlSetState(-1, $GUI_CHECKED) Else GUICtrlSetState(-1, $GUI_UNCHECKED) EndIf ;================================================================================= ;Help Menu ======================================================================= $HelpMenu = GUICtrlCreateMenu("Help") $About = GUICtrlCreateMenuItem("About", $HelpMenu, 1) $AboutCustomSett = GUICtrlCreateMenuItem("Custom Settings", $HelpMenu, 2) ;================================================================================= ;Create Edit Control =================================================================================== Global $Edit = GUICtrlCreateEdit("", 0, 0, 650, 238, $EDIT_STYLE) ;======================================================================================================= ;Create Status bar ============================================================ Local $Parts[1] = [70] Global $StatusBar = _GUICtrlStatusBar_Create($Main, $Parts, $SB_SIMPLEID) _GUICtrlStatusBar_SetParts($StatusBar, $Parts) _GUICtrlStatusBar_SetText($StatusBar, "New Document") ;============================================================================== If FileExists("temp") Then GUICtrlSetData(-1, FileRead("temp")) ;For When and If Main() Has to be Called again. It Restores the Text in $Edit. FileDelete("temp") EndIf GUICtrlSetFont(-1, IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontsize", "10"), IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontweight", "400"), IniRead(@ScriptDir & "/config.ini", "CONFIG", "attributes", "0"), IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontname", "Arial")) GUICtrlSetColor(-1, IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontcolor", "0x000000")) GUICtrlSetBkColor(-1, IniRead(@ScriptDir & "/config.ini", "CONFIG", "bgcolor", "0xFFFFFF")) GUISetState() GUIRegisterMsg($WM_SIZE, "WM_SIZE") While 1 $Msg = GUIGetMsg() Switch $Msg Case -3 If FileRead(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound")) = GUICtrlRead($Edit) Then IniDelete(@ScriptDir & "/config.ini", "CONFIG", "file") Exit Else $Confirm = MsgBox(35, "Confirm", "Do You Want To Save Before Exiting?") If $Confirm = 6 Then If FileExists(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound")) Then FileDelete(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound")) FileWrite(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound"), GUICtrlRead($Edit)) IniDelete(@ScriptDir & "/config.ini", "CONFIG", "file") Exit EndIf $SaveDir = FileSaveDialog("Save File", @ScriptDir, "Text Files (*.txt)|Config Files (*.ini)|HTML Files (*.html)|XML Files (*.xml)|Batch Files (*.bat)|All Files (*.*)") If Not @error Then IniWrite(@ScriptDir & "/config.ini", "CONFIG", "file", $SaveDir) FileDelete(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound")) FileWrite($SaveDir, GUICtrlRead($Edit)) IniDelete(@ScriptDir & "/config.ini", "CONFIG", "file") Exit EndIf EndIf EndIf If $Confirm = 7 Then IniDelete(@ScriptDir & "/config.ini", "CONFIG", "file") Exit EndIf Case $New _New() Case $Open _Open() Case $DefaultBGColor $NewBG = _ChooseColor(2) If Not @error Then IniWrite(@ScriptDir & "/config.ini", "CONFIG", "bgcolor", $NewBG) GUICtrlSetBkColor($Edit, IniRead(@ScriptDir & "/config.ini", "CONFIG", "bgcolor", "0xFFFFFF")) EndIf Case $DefaultFont $NewFont = _ChooseFont(IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontname", "Arial"), IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontsize", "10"), 0, 400, False, False, False, $Main) If Not @error Then IniWrite(@ScriptDir & "/config.ini", "CONFIG", "fontsize", $NewFont[3]) IniWrite(@ScriptDir & "/config.ini", "CONFIG", "attributes", $NewFont[1]) IniWrite(@ScriptDir & "/config.ini", "CONFIG", "fontweight", $NewFont[4]) IniWrite(@ScriptDir & "/config.ini", "CONFIG", "fontcolor", $NewFont[7]) IniWrite(@ScriptDir & "/config.ini", "CONFIG", "fontname", $NewFont[2]) GUICtrlSetFont($Edit, IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontsize", "10"), IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontweight", "400"), IniRead(@ScriptDir & "/config.ini", "CONFIG", "attributes", "0"), IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontname", "Arial")) GUICtrlSetColor($Edit, IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontcolor", "0x000000")) EndIf Case $ResetDefaults IniWrite(@ScriptDir & "/config.ini", "CONFIG", "fontname", "Arial") IniWrite(@ScriptDir & "/config.ini", "CONFIG", "fontsize", "11") IniWrite(@ScriptDir & "/config.ini", "CONFIG", "fontcolor", "0x000000") IniWrite(@ScriptDir & "/config.ini", "CONFIG", "fontweight", "400") IniWrite(@ScriptDir & "/config.ini", "CONFIG", "bgcolor", "0xFFFFFF") IniWrite(@ScriptDir & "/config.ini", "CONFIG", "attributes", "0") IniWrite(@ScriptDir & "/config.ini", "CONFIG", "file", "") MsgBox(64, "Ok", "Default Settings Reset. Your Custom Options Were not Changed.") Case $SaveAs $SaveDir = FileSaveDialog("Save File", @ScriptDir, "Text Files (*.txt)|Config Files (*.ini)|HTML Files (*.html)|XML Files (*.xml)|Batch Files (*.bat)|All Files (*.*)") If Not @error Then GUICtrlSetState($SetFileAttr, $GUI_ENABLE) GUICtrlSetState($CustomFont, $GUI_ENABLE) GUICtrlSetState($CustomBGColor, $GUI_ENABLE) IniWrite(@ScriptDir & "/config.ini", "CONFIG", "file", $SaveDir) $INI = IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "") $GetExt = StringTrimLeft($INI, StringLen($INI) - 3) ; Get the Extension of the Currently Opened File If StringInStr($Ext, $GetExt) Then GUICtrlSetState($Run, $GUI_ENABLE) FileDelete(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound")) FileWrite(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound"), GUICtrlRead($Edit)) GUICtrlSetState($Save, $GUI_ENABLE) _GUICtrlStatusBar_SetText($StatusBar, "Saving...") Sleep(500) _GUICtrlStatusBar_SetText($StatusBar, "File Saved!") EndIf Case $Save _Save() Case $TimeAndDate _TimeAndDate() Case $SpeakText $SelText = _GUICtrlEdit_GetSel($Edit) If $SelText[1] = 0 Then MsgBox(16, "Error!", "Select Text First!") Else Global $Voice = ObjCreate("Sapi.SpVoice") SpeakSelectedText(0.5, 100) EndIf Case $About MsgBox(64, "About", "Text Editor" & @LF & @LF & "Version: 2.8" & @LF & @LF & "Created By ReaperX (C) 2011 - 2012") Case $Find _Find() Case $SelectAll _SelectAll() Case $DocInfo MsgBox(0, "Information", "Characters: " & _GUICtrlEdit_GetTextLen($Edit) & @LF & "Lines: " & _GUICtrlEdit_GetLineCount($Edit)) Case $Cut Send("^x") Case $Copy Send("^c") Case $Paste GUICtrlSetData($Edit, GUICtrlRead($Edit) & ClipGet()) Case $Exit If GUICtrlRead($Edit) = FileRead(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound")) Then IniDelete(@ScriptDir & "/config.ini", "CONFIG", "file") Exit Else $Confirm = MsgBox(35, "Confirm", "Do You Want To Save Before Exiting?") If $Confirm = 6 Then If FileExists(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound")) Then FileDelete(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound")) FileWrite(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound"), GUICtrlRead($Edit)) Exit EndIf $SaveDir = FileSaveDialog("Save File", @ScriptDir, "Text Files (*.txt)|Config Files (*.ini)|HTML Files (*.html)|XML Files (*.xml)|Batch Files (*.bat)|All Files (*.*)") If Not @error Then IniWrite(@ScriptDir & "/config.ini", "CONFIG", "file", $SaveDir) FileDelete(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound")) FileWrite($SaveDir, GUICtrlRead($Edit)) IniDelete(@ScriptDir & "/config.ini", "CONFIG", "file") Exit Else IniDelete(@ScriptDir & "/config.ini", "CONFIG", "file") Exit EndIf EndIf EndIf If $Confirm = 7 Then IniDelete(@ScriptDir & "/config.ini", "CONFIG", "file") Exit EndIf Case $Undo _Undo() Case $CustomBGColor $iFile = IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "Error!") $NewBG = _ChooseColor(2) If Not @error Then GUICtrlSetState($EraseCustomOpt, $GUI_ENABLE) IniWrite(@ScriptDir & "/config.ini", $iFile, "bgcolor", $NewBG) GUICtrlSetBkColor($Edit, IniRead(@ScriptDir & "/config.ini", $iFile, "bgcolor", "0xFFFFFF")) _GUICtrlStatusBar_SetText($StatusBar, "Custom Background Color Options Saved!") Sleep(1000) _GUICtrlStatusBar_SetText($StatusBar, "Current File: " & IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "Error!")) EndIf Case $CustomFont $iFile = IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "Error!") $NewFont = _ChooseFont(IniRead(@ScriptDir & "/config.ini", $iFile, "fontname", "Arial"), IniRead(@ScriptDir & "/config.ini", $iFile, "fontsize", "11"), IniRead(@ScriptDir & "/config.ini", $iFile, "fontcolor", "0x000000"), IniRead(@ScriptDir & "/config.ini", $iFile, "fontweight", "400")) If Not @error Then GUICtrlSetState($EraseCustomOpt, $GUI_ENABLE) IniWrite(@ScriptDir & "/config.ini", $iFile, "fontname", $NewFont[2]) IniWrite(@ScriptDir & "/config.ini", $iFile, "fontsize", $NewFont[3]) IniWrite(@ScriptDir & "/config.ini", $iFile, "attributes", $NewFont[1]) IniWrite(@ScriptDir & "/config.ini", $iFile, "fontweight", $NewFont[4]) IniWrite(@ScriptDir & "/config.ini", $iFile, "fontcolor", $NewFont[7]) GUICtrlSetFont($Edit, IniRead(@ScriptDir & "/config.ini", $iFile, "fontsize", "10"), IniRead(@ScriptDir & "/config.ini", $iFile, "fontweight", "400"), IniRead(@ScriptDir & "/config.ini", $iFile, "attributes", "0"), IniRead(@ScriptDir & "/config.ini", $iFile, "fontname", "Arial")) GUICtrlSetColor($Edit, IniRead(@ScriptDir & "/config.ini", $iFile, "fontcolor", "0x000000")) _GUICtrlStatusBar_SetText($StatusBar, "Custom Font Options Saved!") Sleep(1000) _GUICtrlStatusBar_SetText($StatusBar, "Current File: " & IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "Error!")) EndIf Case $EraseCustomOpt $iFile = IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "Error!") IniDelete(@ScriptDir & "/config.ini", $iFile) GUICtrlSetFont(-1, IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontsize", "10"), IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontweight", "400"), IniRead(@ScriptDir & "/config.ini", "CONFIG", "attributes", "0"), IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontname", "Arial")) GUICtrlSetColor(-1, IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontcolor", "0x000000")) GUICtrlSetBkColor(-1, IniRead(@ScriptDir & "/config.ini", "CONFIG", "bgcolor", "0xFFFFFF")) GUICtrlSetState($EraseCustomOpt, $GUI_DISABLE) _GUICtrlStatusBar_SetText($StatusBar, "Custom File Options Erased!") Sleep(1000) _GUICtrlStatusBar_SetText($StatusBar, "Current File: " & IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "Error!")) Case $SetFileAttr $Attr = FileGetAttrib(IniRead("config.ini", "CONFIG", "file", "Error!")) If Not @error Then SetFileAttr() Else MsgBox(16, "Error!", "The File Attributes Could Not be Retrieved!") EndIf Case $AboutCustomSett MsgBox(0, "About Custom Settings", "Custom BG and Font Settings are for Specific Files. You can open a file and have a Specific Background and Font color set for that file and No other file. This Doesnt mess with Default Settings. Default Settings Load When the Application first Opens and When no Custom Settings are Set For Any Open File.") Case $WordWrap If BitAND(GUICtrlRead($WordWrap), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState($WordWrap, $GUI_UNCHECKED) GUICtrlSetStyle($Edit, $GUI_SS_DEFAULT_EDIT) IniWrite(@ScriptDir & "/config.ini", "CONFIG", "wordwrap", "0") Else GUICtrlSetState($WordWrap, $GUI_CHECKED) GUICtrlSetStyle($Edit, BitOR($ES_WANTRETURN, $WS_VSCROLL)) IniWrite(@ScriptDir & "/config.ini", "CONFIG", "wordwrap", "1") EndIf Case $CAPS If BitAND(GUICtrlRead($CAPS), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState($CAPS, $GUI_UNCHECKED) If BitAND(GUICtrlRead($WordWrap), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetStyle($Edit, BitOR($ES_WANTRETURN, $WS_VSCROLL)) Else GUICtrlSetStyle($Edit, $GUI_SS_DEFAULT_EDIT) EndIf Else GUICtrlSetState($CAPS, $GUI_CHECKED) If BitAND(GUICtrlRead($LOWERCASE), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState($LOWERCASE, $GUI_UNCHECKED) If BitAND(GUICtrlRead($WordWrap), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetStyle($Edit, BitOR($ES_WANTRETURN, $WS_VSCROLL, $ES_UPPERCASE)) Else GUICtrlSetStyle($Edit, $ES_UPPERCASE) EndIf EndIf Case $Readonly If BitAND(GUICtrlRead($Readonly), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState($Readonly, $GUI_UNCHECKED) If BitAND(GUICtrlRead($WordWrap), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetStyle($Edit, BitOR($ES_WANTRETURN, $WS_VSCROLL)) Else GUICtrlSetStyle($Edit, $GUI_SS_DEFAULT_EDIT) EndIf Else GUICtrlSetState($Readonly, $GUI_CHECKED) If BitAND(GUICtrlRead($WordWrap), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetStyle($Edit, BitOR($ES_WANTRETURN, $WS_VSCROLL, $ES_READONLY)) Else GUICtrlSetStyle($Edit, BitOR($GUI_SS_DEFAULT_EDIT, $ES_READONLY)) EndIf EndIf Case $LOWERCASE If BitAND(GUICtrlRead($LOWERCASE), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState($LOWERCASE, $GUI_UNCHECKED) If BitAND(GUICtrlRead($WordWrap), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetStyle($Edit, BitOR($ES_WANTRETURN, $WS_VSCROLL)) Else GUICtrlSetStyle($Edit, $GUI_SS_DEFAULT_EDIT) EndIf Else GUICtrlSetState($LOWERCASE, $GUI_CHECKED) If BitAND(GUICtrlRead($CAPS), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState($CAPS, $GUI_UNCHECKED) If BitAND(GUICtrlRead($WordWrap), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetStyle($Edit, BitOR($ES_WANTRETURN, $WS_VSCROLL, $ES_LOWERCASE)) Else GUICtrlSetStyle($Edit, BitOR($GUI_SS_DEFAULT_EDIT, $ES_READONLY)) EndIf EndIf Case $Run $INI = IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "") $GetExt = StringTrimLeft($INI, StringLen($INI) - 4) ; Get the Extension of the Currently Opened File If Not $INI = "" Then If StringInStr($Ext, $GetExt) Then ShellExecute($INI) If @Error Then MsgBox(16, "Run Script", "An Error Occurred!") EndIf EndIf EndIf EndSwitch WEnd EndFunc ;==>Main Func _Open() Global $Edit, $StatusBar, $SetFileAttr, $CustomBGColor, $CustomFont, $EraseCustomOpt, $Main, $Run Local $Ext = ".au3 ,.bat ,.vbs ,.htm ,.html" ; Script Types Allowed to Be Executed (Only Extensions) If WinActive($GUI_TITLE) Then If GUICtrlRead($Edit) = FileRead(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound")) Then $File = FileOpenDialog("Choose a Readable File", @ScriptDir, "All Files (*.*)|Text Files (*.txt)|Config Files (*.ini)|HTML Files (*.html)|XML Files (*.xml)|Batch Files (*.bat)") If Not @error Then GUICtrlSetState($SetFileAttr, $GUI_ENABLE) GUICtrlSetState($CustomFont, $GUI_ENABLE) GUICtrlSetState($CustomBGColor, $GUI_ENABLE) IniWrite(@ScriptDir & "/config.ini", "CONFIG", "file", $File) ;$INI = IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "") ;$GetExt = StringTrimLeft($INI, StringLen($INI) - 4) ; Get the Extension of the Currently Opened File ;If StringInStr($Ext, $GetExt) Then ;GUICtrlSetState($Run, $GUI_ENABLE) ;EndIf GUICtrlSetData($Edit, FileRead($File)) $A = IniReadSection(@ScriptDir & "/config.ini", $File) If Not @error Then GUICtrlSetFont($Edit, IniRead(@ScriptDir & "/config.ini", $File, "fontsize", "10"), IniRead(@ScriptDir & "/config.ini", $File, "fontweight", "400"), IniRead(@ScriptDir & "/config.ini", $File, "attributes", "0"), IniRead(@ScriptDir & "/config.ini", $File, "fontname", "Arial")) GUICtrlSetColor($Edit, IniRead(@ScriptDir & "/config.ini", $File, "fontcolor", "0x000000")) GUICtrlSetBkColor($Edit, IniRead(@ScriptDir & "/config.ini", $File, "bgcolor", "0xFFFFFF")) GUICtrlSetState($EraseCustomOpt, $GUI_ENABLE) EndIf _GUICtrlStatusBar_SetText($StatusBar, "Current File: " & $File) If StringInStr(FileGetAttrib($File), "R") Then GUICtrlSetStyle($Edit, BitOR($GUI_SS_DEFAULT_EDIT, $ES_READONLY)) MsgBox(48, "Text Editor", "This File is set to Readonly and cannot be edited.") EndIf EndIf Else $Confirm = MsgBox(36, "Confirm", "Do You Want To Save Before Opening a New File?") If $Confirm = 6 Then If FileExists(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound")) Then FileDelete(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound")) FileWrite(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound"), GUICtrlRead($Edit)) IniDelete(@ScriptDir & "/config.ini", "CONFIG", "file") _GUICtrlStatusBar_SetText($StatusBar, "Saving...") Sleep(1000) _GUICtrlStatusBar_SetText($StatusBar, "File Saved!") $File = FileOpenDialog("Choose a Readable File", @ScriptDir, "All Files (*.*)|Text Files (*.txt)|Config Files (*.ini)|HTML Files (*.html)|XML Files (*.xml)|Batch Files (*.bat)") If Not @error Then GUICtrlSetState($SetFileAttr, $GUI_ENABLE) GUICtrlSetState($CustomFont, $GUI_ENABLE) GUICtrlSetState($CustomBGColor, $GUI_ENABLE) IniWrite(@ScriptDir & "/config.ini", "CONFIG", "file", $File) GUICtrlSetData($Edit, FileRead($File)) _GUICtrlStatusBar_SetText($StatusBar, "Current File: " & $File) EndIf Else $SaveDir = FileSaveDialog("Save File", @ScriptDir, "Text Files (*.txt)|Config Files (*.ini)|HTML Files (*.html)|XML Files (*.xml)|Batch Files (*.bat)|All Files (*.*)") If Not @error Then IniWrite(@ScriptDir & "/config.ini", "CONFIG", "file", $SaveDir) FileDelete(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound")) FileWrite($SaveDir, GUICtrlRead($Edit)) IniDelete(@ScriptDir & "/config.ini", "CONFIG", "file") _GUICtrlStatusBar_SetText($StatusBar, "Saving...") Sleep(500) _GUICtrlStatusBar_SetText($StatusBar, "File Saved!") Sleep(500) _GUICtrlStatusBar_SetText($StatusBar, "Current File: " & $File) EndIf EndIf Else $File = FileOpenDialog("Choose a Readable File", @ScriptDir, "Text Files (*.txt)|Config Files (*.ini)|HTML Files (*.html)|XML Files (*.xml)|Batch Files (*.bat)|All Files (*.*)") If Not @error Then GUICtrlSetState($SetFileAttr, $GUI_ENABLE) IniWrite(@ScriptDir & "/config.ini", "CONFIG", "file", $File) GUICtrlSetData($Edit, FileRead($File)) _GUICtrlStatusBar_SetText($StatusBar, "Current File: " & $File) EndIf EndIf EndIf EndIf EndFunc ;==>_Open Func _New() Global $Edit, $StatusBar If WinActive($GUI_TITLE) Then If GUICtrlRead($Edit) = FileRead(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound")) Then GUICtrlSetData($Edit, "") IniDelete(@ScriptDir & "/config.ini", "CONFIG", "file") GUICtrlSetFont(-1, IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontsize", "10"), IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontweight", "400"), IniRead(@ScriptDir & "/config.ini", "CONFIG", "attributes", "0"), IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontname", "Arial")) GUICtrlSetColor(-1, IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontcolor", "0x000000")) GUICtrlSetBkColor(-1, IniRead(@ScriptDir & "/config.ini", "CONFIG", "bgcolor", "0xFFFFFF")) _GUICtrlStatusBar_SetText($StatusBar, "New Document") Else $Confirm = MsgBox(36, "Confirm", "Do You Want To Save Before Starting a New File?") If $Confirm = 6 Then If FileExists(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound")) Then FileDelete(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound")) FileWrite(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound"), GUICtrlRead($Edit)) IniDelete(@ScriptDir & "/config.ini", "CONFIG", "file") _GUICtrlStatusBar_SetText($StatusBar, "Saving...") Sleep(500) _GUICtrlStatusBar_SetText($StatusBar, "File Saved!") GUICtrlSetData($Edit, "") GUICtrlSetFont(-1, IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontsize", "10"), IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontweight", "400"), IniRead(@ScriptDir & "/config.ini", "CONFIG", "attributes", "0"), IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontname", "Arial")) GUICtrlSetColor(-1, IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontcolor", "0x000000")) GUICtrlSetBkColor(-1, IniRead(@ScriptDir & "/config.ini", "CONFIG", "bgcolor", "0xFFFFFF")) EndIf $SaveDir = FileSaveDialog("Save File", @ScriptDir, "Text Files (*.txt)|Config Files (*.ini)|HTML Files (*.html)|XML Files (*.xml)|Batch Files (*.bat)|All Files (*.*)") If Not @error Then IniWrite(@ScriptDir & "/config.ini", "CONFIG", "file", $SaveDir) FileDelete(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound")) FileWrite($SaveDir, GUICtrlRead($Edit)) IniDelete(@ScriptDir & "/config.ini", "CONFIG", "file") _GUICtrlStatusBar_SetText($StatusBar, "Saving...") Sleep(500) _GUICtrlStatusBar_SetText($StatusBar, "File Saved!") GUICtrlSetData($Edit, "") GUICtrlSetFont(-1, IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontsize", "10"), IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontweight", "400"), IniRead(@ScriptDir & "/config.ini", "CONFIG", "attributes", "0"), IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontname", "Arial")) GUICtrlSetColor(-1, IniRead(@ScriptDir & "/config.ini", "CONFIG", "fontcolor", "0x000000")) GUICtrlSetBkColor(-1, IniRead(@ScriptDir & "/config.ini", "CONFIG", "bgcolor", "0xFFFFFF")) _GUICtrlStatusBar_SetText($StatusBar, "New Document") EndIf Else GUICtrlSetData($Edit, "") IniDelete(@ScriptDir & "/config.ini", "CONFIG", "file") _GUICtrlStatusBar_SetText($StatusBar, "New Document") EndIf EndIf EndIf EndFunc ;==>_New Func _Save() Global $StatusBar, $SetFileAttr, $CustomBGColor, $CustomFont If WinActive($GUI_TITLE) Then If FileExists(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound")) Then FileDelete(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound")) FileWrite(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound"), GUICtrlRead($Edit)) _GUICtrlStatusBar_SetText($StatusBar, "File Saved!") Sleep(500) _GUICtrlStatusBar_SetText($StatusBar, "Current File: " & IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "Error!")) Else $SaveDir = FileSaveDialog("Save File", @ScriptDir, "Text Files (*.txt)|Config Files (*.ini)|HTML Files (*.html)|XML Files (*.xml)|Batch Files (*.bat)|All Files (*.*)") If Not @error Then GUICtrlSetState($SetFileAttr, $GUI_ENABLE) GUICtrlSetState($CustomFont, $GUI_ENABLE) GUICtrlSetState($CustomBGColor, $GUI_ENABLE) IniWrite(@ScriptDir & "/config.ini", "CONFIG", "file", $SaveDir) FileDelete(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound")) FileWrite(IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "NotFound"), GUICtrlRead($Edit)) _GUICtrlStatusBar_SetText($StatusBar, "Saving...") Sleep(500) _GUICtrlStatusBar_SetText($StatusBar, "File Saved!") Sleep(500) _GUICtrlStatusBar_SetText($StatusBar, "Current File: " & IniRead(@ScriptDir & "/config.ini", "CONFIG", "file", "Error!")) EndIf EndIf EndIf EndFunc ;==>_Save Func _SelectAll() Global $Edit If WinActive($GUI_TITLE) Then _GUICtrlEdit_SetSel($Edit, 0, _GUICtrlEdit_GetTextLen($Edit)) EndIf EndFunc ;==>_SelectAll Func _Undo() Global $Edit If WinActive($GUI_TITLE) Then _GUICtrlEdit_Undo($Edit) EndIf EndFunc ;==>_Undo Func _Find() Global $Edit If WinActive($GUI_TITLE) Then _GUICtrlEdit_Find($Edit) EndIf EndFunc ;==>_Find Func _TimeAndDate() Global $Edit If WinActive($GUI_TITLE) Then If @WDAY = 1 Then $Day = "Sunday" If @WDAY = 2 Then $Day = "Monday" If @WDAY = 3 Then $Day = "Tuesday" If @WDAY = 4 Then $Day = "Wednesday" If @WDAY = 5 Then $Day = "Thursday" If @WDAY = 6 Then $Day = "Friday" If @WDAY = 7 Then $Day = "Saturday" If @HOUR < 12 Then $i = "AM" If @HOUR > 12 Then $i = "PM" GUICtrlSetData($Edit, GUICtrlRead($Edit) & $Day & " - " & @MON & "/" & @MDAY & "/" & @YEAR & " - " & @HOUR & ":" & @MIN & " " & $i) EndIf EndFunc ;==>_TimeAndDate Func SetFileAttr() GUICreate("Set File Attributes", 200, 140) Local $Attr = FileGetAttrib(IniRead("config.ini", "CONFIG", "file", "Error!")) Local $Readonly = GUICtrlCreateCheckbox("Readonly", 20, 20) If StringInStr($Attr, "R") Then GUICtrlSetState(-1, $GUI_CHECKED) Local $Archive = GUICtrlCreateCheckbox("Archive", 100, 20) If StringInStr($Attr, "A") Then GUICtrlSetState(-1, $GUI_CHECKED) Local $Hidden = GUICtrlCreateCheckbox("Hidden", 20, 40) If StringInStr($Attr, "H") Then GUICtrlSetState(-1, $GUI_CHECKED) Local $Compress = GUICtrlCreateCheckbox("Compress", 100, 40) If StringInStr($Attr, "C") Then GUICtrlSetState(-1, $GUI_CHECKED) Local $Apply = GUICtrlCreateButton("Apply", 40, 80, 50, 30) Local $Cancel = GUICtrlCreateButton("Cancel", 100, 80, 50, 30) GUISetState() While 1 $iMsg = GUIGetMsg() Switch $iMsg Case -3 GUIDelete() ExitLoop Case $Apply ;Readonly ================================================================== If BitOR(GUICtrlRead($Readonly), $GUI_CHECKED) = $GUI_CHECKED Then FileSetAttrib(IniRead("config.ini", "CONFIG", "file", "Error!"), "+R") Else FileSetAttrib(IniRead("config.ini", "CONFIG", "file", "Error!"), "-R") EndIf ;Archive ==================================================================== If BitOR(GUICtrlRead($Archive), $GUI_CHECKED) = $GUI_CHECKED Then FileSetAttrib(IniRead("config.ini", "CONFIG", "file", "Error!"), "+A") Else FileSetAttrib(IniRead("config.ini", "CONFIG", "file", "Error!"), "-A") EndIf ;Hidden ===================================================================== If BitOR(GUICtrlRead($Hidden), $GUI_CHECKED) = $GUI_CHECKED Then FileSetAttrib(IniRead("config.ini", "CONFIG", "file", "Error!"), "+H") Else FileSetAttrib(IniRead("config.ini", "CONFIG", "file", "Error!"), "-H") EndIf ;Compress ================================================================= If BitOR(GUICtrlRead($Compress), $GUI_CHECKED) = $GUI_CHECKED Then FileSetAttrib(IniRead("config.ini", "CONFIG", "file", "Error!"), "+C") Else FileSetAttrib(IniRead("config.ini", "CONFIG", "file", "Error!"), "-C") EndIf MsgBox(64, "Ok", "File Attributes Set and Saved.") GUIDelete() ExitLoop Case $Cancel GUIDelete() ExitLoop EndSwitch WEnd EndFunc ;==>SetFileAttr Func SpeakSelectedText($iRate, $iVolume) Global $Voice Send("^C") Local $iText = ClipGet() $Voice.Rate = $iRate $Voice.Volume = $iVolume $Voice.Speak($iText) Local $iText = ClipPut("") EndFunc ;==>SpeakSelectedText Func WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam) Global $StatusBar _GUICtrlStatusBar_Resize($StatusBar) Return $GUI_RUNDEFMSG EndFunc ;==>WM_SIZE Heres an Archive with the Updated Script (Also Compiled Version) and the Icon. Text Editor.rar
    1 point
  26. _Crypt_DeriveKey, returns a handle to the key, not the key itself, and then that handle is only valid if you use the $CALG_USERKEY flag in the _Crypt_EncryptData function. You can do it much simpler by just specifying the password without using the key handle in that function call. You're referencing the handle by one instance of it, and it probably changes everytime you use derivekey, so no wonder it doesn't work.
    1 point
×
×
  • Create New...