Page 8 of 22

Re: AutoGUI - GUI Designer and Script Editor

Posted: 17 Jul 2016, 09:10
by Alguimist
need4speed wrote:found a bug in RegEx Utility, I guess.
The bug you mentioned in Expressive was fixed and the issues/limitations in the cloning tool will be fixed later. I'm currently working on a message box tool and the link you posted was very useful. Thanks.

Expressive 1.2:
- The count of matches is obtained with RegExReplace.
- Added option DOTALL.
- F5 copies the function to the clipboard.

Replace Expressive.ahk in AutoGUI\Tools with this file:

Code: Select all

; Expressive - Regular Expressions Utility

EnsureU32()

#NoEnv
#Warn All, Off
#SingleInstance Off
#NoTrayIcon
SetWorkingDir %A_ScriptDir%
SetControlDelay -1
SetBatchLines -1

#Include %A_ScriptDir%\..\Lib\Scintilla.ahk
#Include %A_ScriptDir%\..\Lib\ControlColor.ahk

Global Version := "1.2"
, SciLexer := A_ScriptDir . "\..\SciLexer.dll"
, hMatchCount
, Groups := False
, Replace := False
, IconLib := A_ScriptDir . "\..\Icons\Expressive.icl"
, TT := {}

Menu Tray, Icon, %IconLib%, 1

Gui New, hWndhWindow -DPIScale

; "Regular Expression" section
Gui Font, s9 Bold, Segoe UI
Gui Add, Text, hWndhRegExHdr x10 y12 w710 h29 +0x200 +E0x200, %A_Space%Regular Expression
Gui Font
Gui Add, Picture, hWndhHelpIcon gShowHelp x697 y18 w16 h16 Icon4 BackgroundTrans, %IconLib%
Gui Font, s13, Lucida Console
Gui Add, Edit, vRegEx gSearch x10 y44 w709 h25 -VScroll
Gui Font

; Options
Gui Font, s8, MS Shell Dlg 2
If (A_ScreenDPI > 96) {
    Gui Add, CheckBox, vIgnoreCase gSetOption x12 y72 w90 h23, Ignore case
    Gui Add, CheckBox, vMultiline gSetOption xp+100 y72 w80 h23, Multiline
    Gui Add, CheckBox, vDOTALL gSetOption xp+90 y72 w80 h23, DOTALL
    Gui Add, CheckBox, vHighlightAll gSearch x580 y72 w140 h23 Checked, Highlight all matches
} Else {
    Gui Add, CheckBox, vIgnoreCase gSetOption x12 y72 w80 h23, Ignore case
    Gui Add, CheckBox, vMultiline gSetOption x100 y72 w60 h23, Multiline
    Gui Add, CheckBox, vDOTALL gSetOption x178 y72 w60 h23, DOTALL
    Gui Add, CheckBox, vHighlightAll gSearch x600 y72 w120 h23 Checked, Highlight all matches
}

; "Text" section
Gui Font, s9 Bold, Segoe UI
Gui Add, Text, hWndhTextHdr x10 y98 w710 h29 +0x200 +E0x200, %A_Space%Text
Gui Add, Text, hWndhMatchCount x612 y104 w100 h20 Right
Gui Font
Global Sci := New Scintilla
Sci.Add(hWindow, 10, 130, 710, 232, SciLexer, 0x50010000, 0x200)
Sci.SetLexer(SCLEX_CONTAINER)
Sci.SetCodePage(65001)
Sci.StyleClearAll()
Sci.SetWrapMode(1)
Sci.SetMarginWidthN(0, 0)
Sci.SetMarginWidthN(1, 0)
Sci.StyleSetFont(SCE_AHKL_NEUTRAL, "Lucida Console")
Sci.StyleSetSize(SCE_AHKL_NEUTRAL, 10)
Sci.SetSelFore(1, "0xFFFFFF")
Sci.SetSelBack(1, "0x3399FF")
Sci.StyleSetBack(SCE_AHKL_USERDEFINED1, 0xABDFEE)
Sci.StyleSetFont(SCE_AHKL_USERDEFINED1, "Lucida Console")
Sci.StyleSetSize(SCE_AHKL_USERDEFINED1, 10)
;Sci.SetText("", "")
Sci.Notify := "OnNotify"

; "Groups" section
Gui Font, Bold, Segoe UI
Gui Add, Text, hWndhGroupsHdr gShowGroups x10 y368 w710 h29 +0x200 +E0x200, %A_Space%Groups
Gui Font
Gui Add, Picture, hWndhGroupsChevron x697 y374 w16 h16 Icon2 BackgroundTrans, %IconLib%
Global SciGroups := CreateScintilla(hWindow, 10, 282, 710, 115, SciLexer, "Hidden")
SciGroups.SetReadOnly(True)

; "Replace" section
Gui Font, Bold, Segoe UI
Gui Add, Text, hWndhReplaceHdr gShowReplace x10 y403 w710 h29 +0x200 +E0x200, %A_Space%Replace
Gui Font
Gui Add, Picture, hWndhReplaceChevron x697 y409 w16 h16 Icon2 BackgroundTrans, %IconLib%
Gui Font, s13, Lucida Console
Gui Add, Edit, hWndhReplaceField vReplacement gReplace x10 y267 w709 h25 -VScroll Hidden
Gui Font
Global SciReplace := CreateScintilla(hWindow, 10, 297, 710, 100, SciLexer, "Hidden")

Gui Add, Picture, hWndhCollapseChevron x-16 y0 w16 h16 Icon3 BackgroundTrans, %IconLib%

ControlColor(hRegExHdr, hWindow, 0x336699, 0xFFFFFF)
ControlColor(hTextHdr, hWindow, 0x336699, 0xFFFFFF)
ControlColor(hMatchCount, hWindow, 0x336699, 0xFFFFFF)
ControlColor(hGroupsHdr, hWindow, 0xC0C0C0, 0xFFFFFF)
ControlColor(hReplaceHdr, hWindow, 0xC0C0C0, 0xFFFFFF)

Gui Show, w730 h441, Expressive - Regular Expressions Utility

hSysMenu := DllCall("GetSystemMenu", "UInt", hWindow, "Int", False)
DllCall("AppendMenu", "UInt", hSysMenu, "UInt", 0x800, "UInt", 0, "Str", "")
DllCall("AppendMenu", "UInt", hSysMenu, "UInt", 1, "UInt", 0, "Str", "Version " . Version)

OnMessage(0x100, "OnWM_KEYDOWN")
OnMessage(0x200, "OnWM_MOUSEMOVE")

TT.IgnoreCase := "Case-insensitive matching. Letters match`ntheir lowercase/uppercase counterparts."
TT.Multiline  := "Beginning and end metacharacters (^ and $)`nmatch the beginning or the end of each line."
TT.DOTALL     := "Makes the ""."" (dot) metacharacter`nmatch anything including line breaks."

Return ; End of the auto-execute section

Search:
    Gui Submit, NoHide

    ; Clear old matches
    sci.StartStyling(0, 0x1F)
    sci.SetStyling(Sci.GetLength() + 1, STYLE_DEFAULT)

    If (RegExMatch(RegEx, "^([\w``]*)i([\w``]*)\)")) {
        If (!IgnoreCase) {
            GuiControl,, IgnoreCase, 1
        }
    } Else If (IgnoreCase) {
        GuiControl,, IgnoreCase, 0
    }

    If (RegExMatch(RegEx, "^([\w``]*)m([\w``]*)\)")) {
        If (!Multiline) {
            GuiControl,, Multiline, 1
        }
    } Else If (Multiline) {
        GuiControl,, Multiline, 0
    }

    If (RegExMatch(RegEx, "^([\w``]*)s([\w``]*)\)")) {
        If (!DOTALL) {
            GuiControl,, DOTALL, 1
        }
    } Else If (DOTALL) {
        GuiControl,, DOTALL, 0
    }

    If (RegEx == "") {
        GuiControl,, %hMatchCount%, No Match
        SciGroups.SetReadOnly(False)
        SciGroups.ClearAll()
        SciGroups.SetReadOnly(True)
        Return
    }

    Sci.GetText(Sci.GetLength() + 1, SciText)
    Sci.GetText(Sci.GetLength() + 1, SciText)

    Pos := 1
    If (HighlightAll) {
        Loop % (StrPut(SciText, "UTF-8") + 1) {
            FoundPos := RegExMatch(SciText, RegEx, Match, Pos)
            If (Match == "") {
                Break
            }

            Highlight(FoundPos, StrPut(Match, "UTF-8"))

            Pos := FoundPos + 1
        }
    } Else {
        If (FoundPos := RegExMatch(SciText, RegEx, Match, Pos)) {
            Highlight(FoundPos, StrPut(Match, "UTF-8"))
        }
    }

    UpdateCounter(SciText, RegEx)

    If (Groups) {
        GoSub UpdateGroups
    }

    If (Replace) {
        GoSub Replace
    }
Return

Highlight(Pos, Length) {
    Sci.StartStyling(Pos - 1, 0x1F)
    Sci.SetStyling(Length - 1, SCE_AHKL_USERDEFINED1)
}

UpdateCounter(Text, RegEx) {
    If (RegExMatch("", RegEx)) {
        Count := -1 ; ERROR: The expression can match nothing and all at the same time.
    } Else {
        RegExReplace(Text, RegEx,, Count)
    }
    
    If (Count == 0) {
        CountMsg := "No Match"
    } Else If (Count == 1) {
        CountMsg := "1 Match"
    } Else If (Count > 1) {
        CountMsg := Count . " Matches"
    } Else If (Count == -1) {
        CountMsg := "..."
    }

    GuiControl,, %hMatchCount%, %CountMsg%
}

SetOption:
    Gui Submit, NoHide

    If (A_GuiControl == "IgnoreCase") {
        Option := "i"
    } Else If (A_GuiControl == "Multiline") {
        Option := "m"
    } Else If (A_GuiControl == "DOTALL") {
        Option := "s"
    }

    If (RegExMatch(RegEx, "^([\w``]*)" . Option . "([\w``]*)\)")) {
        NewStr := RegExReplace(RegEx, "^([\w``]*)" . Option . "([\w``]*)\)", "$1$2)")
        If (SubStr(NewStr, 1, 1) == ")") {
            NewStr := SubStr(NewStr, 2)
        }
    } Else {
        If (!RegExMatch(RegEx, "^[\w``]+\)")) {
            Option .= ")"
        }
        NewStr := Option . RegEx
    }

    GuiControl,, RegEx, %NewStr%
Return

ShowHelp:
    HelpFile := A_AhkPath . "\..\AutoHotkey.chm"
    Run HH mk:@MSITStore:%HelpFile%::/docs/misc/RegEx-QuickRef.htm
Return

ShowGroups:
    If (!Groups) {
        ControlMove,,,,, 115, % "ahk_id " . Sci.hWnd
        GuiControl Move, %hGroupsHdr%, y250
        GuiControl Move, %hCollapseChevron%, x697 y256
        Control Show,,, % "ahk_id " . SciGroups.hWnd
        ControlColor(hGroupsHdr, hWindow, 0x336699, 0xFFFFFF)
        Groups := True

        GuiControl Move, %hReplaceHdr%, y403
        Control Hide,,, % "ahk_id " . hReplaceField
        Control Hide,,, % "ahk_id " . SciReplace.hWnd
        ControlColor(hReplaceHdr, hWindow, 0xC0C0C0, 0xFFFFFF)
        Replace := False

        GoSub UpdateGroups
    } Else {
        ControlMove,,,,, 232, % "ahk_id " . Sci.hWnd
        GuiControl Move, %hGroupsHdr%, y368
        GuiControl Move, %hCollapseChevron%, x-16
        Control Hide,,, % "ahk_id " . SciGroups.hWnd
        ControlColor(hGroupsHdr, hWindow, 0xC0C0C0, 0xFFFFFF)
        Groups := False
    }

    WinSet Redraw,, ahk_id%hWindow%
Return

UpdateGroups:
    Gui Submit, NoHide

    If (RegEx == "") {
        Return
    }

    Sci.GetText(Sci.GetLength() + 1, SciText)

    RegEx := RegExReplace(RegEx, "^(\w*)\)", "O$1)", Count)
    If (!Count) {
        RegEx := "O)" . RegEx
    }

    RegExMatch(SciText, RegEx, o)
    GrpCount := o.Count()

    Output := ""
    Loop % GrpCount {
        n := (o.Name(A_Index) != "") ? o.Name(A_Index) : A_Index
        Value := (o.Value(A_Index) != "") ? o.Value(A_Index) : "None"
        Output .= n . ": " . Value . "`n"
    }

    SciGroups.SetReadOnly(False)
    If (GrpCount) {
        SciGroups.SetText("", Output)
    } Else {
        SciGroups.ClearAll()
    }
    SciGroups.SetReadOnly(True)
Return

ShowReplace:
    If (!Replace) {
        ControlMove,,,,, 100, % "ahk_id " . Sci.hWnd
        GuiControl Move, %hReplaceHdr%, y235
        GuiControl Move, %hCollapseChevron%, x697 y241
        Control Show,,, % "ahk_id " . hReplaceField
        Control Show,,, % "ahk_id " . SciReplace.hWnd
        ControlColor(hReplaceHdr, hWindow, 0x336699, 0xFFFFFF)
        Replace := True

        Control Hide,,, % "ahk_id " . SciGroups.hWnd
        GuiControl Move, %hGroupsHdr%, y403
        ControlColor(hGroupsHdr, hWindow, 0xC0C0C0, 0xFFFFFF)
        Groups := False

        ControlFocus,, ahk_id%hReplaceField%
    } Else {
        ControlMove,,,,, 232, % "ahk_id " . Sci.hWnd
        GuiControl Move, %hReplaceHdr%, y403
        GuiControl Move, %hCollapseChevron%, x-16
        Control Hide,,, % "ahk_id " . hReplaceField
        Control Hide,,, % "ahk_id " . SciReplace.hWnd
        ControlColor(hReplaceHdr, hWindow, 0xC0C0C0, 0xFFFFFF)
        Replace := False

        GuiControl Move, %hGroupsHdr%, y368
    }

    WinSet Redraw,, ahk_id%hWindow%
Return

Replace:
    Gui Submit, NoHide

    If (RegEx == "") {
        SciReplace.ClearAll()
        Return
    }

    Sci.GetText(Sci.GetLength() + 1, SciText)
    NewStr := RegExReplace(SciText, RegEx, Replacement)
    SciReplace.SetText("", NewStr)
Return

CreateScintilla(hParent, x, y, w, h, SciLexer, Options := "") {
    Scintilla := New Scintilla
    Scintilla.Add(hParent, x, y, w, h, SciLexer, Options)
    Scintilla.SetLexer(SCLEX_CONTAINER)
    Scintilla.SetCodePage(65001)
    Scintilla.SetMarginWidthN(0, 0)
    Scintilla.SetMarginWidthN(1, 0)
    Scintilla.SetWrapMode(1)
    Scintilla.StyleSetFont(SCE_AHKL_NEUTRAL, "Lucida Console")
    Scintilla.StyleSetSize(SCE_AHKL_NEUTRAL, 10)
    Scintilla.SetSelFore(1, "0xFFFFFF")
    Scintilla.SetSelBack(1, "0x3399FF")
    Return Scintilla
}

OnNotify(wParam, lParam, msg, hWnd, obj) {
    If (obj.SCNCode == SCN_MODIFIED && obj.modType != 20) {
        GoSub Search
    }
}

GuiEscape:
GuiClose:
    ExitApp

EnsureU32() {
    If (A_PtrSize == 8 || !A_IsUnicode) {
        If (FileExist(U32 := A_AhkPath . "\..\AutoHotkeyU32.exe")) {
            Run % U32 . " """ . A_LineFile . ""
        } Else {
            MsgBox 0x10, Expressive, AutoHotkey 32-bit Unicode not found.
        }
        ExitApp
    }
}

OnWM_KEYDOWN(wParam, lParam, msg, hWnd) {
    Global

    If (wParam == 113) { ; F2
        GoSub ShowGroups
    } Else if (wParam == 114) { ; F3
        GoSub ShowReplace
    } Else If (wParam == 116) { ; F5
        GuiControlGet RegEx,, Edit1

        If (Replace) {
            GuiControlGet ReplaceRegEx,, %hReplaceField%
            Clipboard := "NewStr := RegExReplace(Haystack, """ . RegEx . """, """ . ReplaceRegEx . """)"
        } Else {
            Clipboard := "FoundPos := RegExMatch(Haystack, """ . RegEx . """, OutputVar)"
        }
    }
}

OnWM_MOUSEMOVE(wParam, lParam, msg, hWnd) {
    Static CurrControl, PrevControl := ""
    CurrControl := A_GuiControl

    If (CurrControl != PrevControl && !InStr(CurrControl, " ")) {
        ToolTip ; Turn off any previous tooltip.
        SetTimer DisplayToolTip, 800
        PrevControl := CurrControl
    }
    Return

    DisplayToolTip:
        SetTimer DisplayToolTip, Off
        ToolTip % TT[CurrControl]
        SetTimer RemoveToolTip, 4500
    return

    RemoveToolTip:
        SetTimer RemoveToolTip, Off
        ToolTip
    Return
}

Re: AutoGUI - GUI Designer and Script Editor

Posted: 21 Aug 2016, 05:17
by Tomer
Alguimist

Incredible, best tool ever!

Best regards,
Tomer

Re: AutoGUI - GUI Designer and Script Editor

Posted: 21 Aug 2016, 07:45
by Tomer
Please add the ability to set Text Alignment also in Radio Button and etc.
Like GroupBox etc..

Tnx

Re: AutoGUI - GUI Designer and Script Editor

Posted: 12 Sep 2016, 14:02
by tyee
Just trying this out. Awesome! I get blank text when I access properties of any control - win7 64bit - any tips to fix it?

Image

Re: AutoGUI - GUI Designer and Script Editor

Posted: 15 Sep 2016, 06:37
by Alguimist
@Tomer: You'll find these options in the styles dialog.

@tyee: Did this problem occurred only once?

Re: AutoGUI - GUI Designer and Script Editor

Posted: 21 Sep 2016, 19:36
by tyee
This is the first time I'm trying AutoGUI, and every widget I place has this problem. Is it something to do with Windows graphical properties/settings??

Update - yes, it must have something to do with Windows theme. I am using Windows Classic and have the problem. Switched to Windows Basic and now I can see the text, but I don't want to use Windows Basic theme! How is the text background color set in this app?

Re: AutoGUI - GUI Designer and Script Editor

Posted: 13 Oct 2016, 02:25
by Tomer
Alguimist wrote:@Tomer: You'll find these options in the styles dialog.
Tnx

Re: AutoGUI - GUI Designer and Script Editor

Posted: 14 Oct 2016, 00:40
by Alguimist
AutoGUI v1.2:
  • The GUI tab is not restricted to the first tab anymore.
  • The status bar in design mode displays document information (line/position, saved status, etc) when the preview window is not visible.
  • Win32 constants database integration with AutoGUI. Type the name of a constant (WM_MOUSEMOVE, for example), select the text and press Ctrl+M. If a value or a partial constant name is selected, the results are shown in Constantine. In addition, code can be generated for SendMessage and OnMessage. See the "Convert" menu.
  • Constantine: more constants added, currently totalizing 5676. To see all Header control messages, for example, browse through GUI > Controls > ListView > Header > Messages, or simply type "HDM" in the search field.
  • Constantine: ListView grouping containing a short description of the category or additional information. ListView enhancements derive from a library written by just_me and require Windows Vista or higher (but still works on Windows XP). Credits to just_me again for the description of GUI control types.
  • The list of built-in variables, A_Variables, was also grouped in categories.
  • New tool: ErrorView, a list of all Win32 error messages. It can be found in the Tools folder.
  • Improved Menu Editor.
  • Changed some incorrect, imprecise or ambiguous terminology displayed in menus and dialogs.
  • Alt+F9 can be configured to run the script in a test build of AHK.
  • New option for ListView and TreeView: "Explorer theme" (Vista+).
  • Multiple files can be opened in the file selection dialog.
  • The "Convert" menu provides access to new functionality: toggle comment (Ctrl+K), base conversion, etc.
  • To duplicate a line, press Ctrl+Down arrow. Ctrl+D is now used for date and time insertion.
  • Fixed window font options not applying to all controls.
  • Upgraded DLL (SciLexer.dll 3.6.6).
  • Several minor improvements and bugfixes.
:arrow: Download

Re: AutoGUI - GUI Designer and Script Editor

Posted: 14 Oct 2016, 08:00
by kczx3
You know, I'm still partial to using Notepad++. Probably just out of habit I guess. But your editor is one of the most pleasing that I have ever seen. Its simple, which I do like. The icons are fabulous. The updates to Constantine and A_Variables are great. Group view is a magical thing!

I would love to see a treeview file explorer...

Re: AutoGUI - GUI Designer and Script Editor

Posted: 15 Oct 2016, 00:40
by tyee
Just tried the latest version and I'm still getting black text fields as I described above with Win 7 high contrast theme. I thought your fix of "Fixed window font options not applying to all controls" may help but it didn't. Did you look into this or do I have to use another theme?

Re: AutoGUI - GUI Designer and Script Editor

Posted: 15 Oct 2016, 18:36
by Alguimist
tyee, it seems that this problem affects any AHK script that uses Tab3.

Re: AutoGUI - GUI Designer and Script Editor

Posted: 03 Nov 2016, 22:14
by tyee
I found a thread talking about using "-theme" for Tab3 but I could not find in the docs anything on where to put it in the code. I scanned the code also, but could not find 'tab3' anywhere. I would like to try adding the "-theme" and see if it works for me.

Re: AutoGUI - GUI Designer and Script Editor

Posted: 04 Nov 2016, 12:59
by Alguimist
tyee wrote:I found a thread talking about using "-theme" for Tab3 but I could not find in the docs anything on where to put it in the code. I scanned the code also, but could not find 'tab3' anywhere. I would like to try adding the "-theme" and see if it works for me.
The files are in the Includes folder (Properties.ahk, MenuEditor.ahk and StylesDlg.ahk). The option -Theme will be added to Tab3 controls in the next version if the Windows theme is not active.

Code: Select all

ThemeFix := DllCall("UxTheme.dll\IsThemeActive") ? "" : "-Theme"
Gui Add, Tab3, hWndhPropTab vCurrentTab x6 y41 w270 h303 AltSubmit %ThemeFix%, General|Options|Window|Events|Script

Re: AutoGUI - GUI Designer and Script Editor

Posted: 05 Nov 2016, 10:32
by Mul Man
I get this error on launch of v10-13-16 FYI.

Error at line 3073.

Line Text: % Sci[Tab].FullFileName
Error: This parameter contains a variable name missing its ending percent sign.

Re: AutoGUI - GUI Designer and Script Editor

Posted: 06 Nov 2016, 20:31
by hamncheese
hi have this error on first run
Image

Re: AutoGUI - GUI Designer and Script Editor

Posted: 07 Nov 2016, 09:33
by kczx3
hamncheese wrote:hi have this error on first run
Image
This looks like you are using an old version of AHK that doesn't have the LoadPicture() function.

Re: AutoGUI - GUI Designer and Script Editor

Posted: 09 Nov 2016, 12:58
by apoklyps3
how does one exactly add code to a button?
example I wanna create a button that opens appwiz.cpl or some folders.

Re: AutoGUI - GUI Designer and Script Editor

Posted: 09 Nov 2016, 21:55
by Alguimist
apoklyps3 wrote:how does one exactly add code to a button?
Define a g-Label for the button in the Properties dialog and then write the subroutine or function beneath the delimiter section. It is preferable, nonetheless, to create the GUI first, then right-click the tab and choose "Duplicate Tab Contents" to copy the script to a new tab.

Re: AutoGUI - GUI Designer and Script Editor

Posted: 14 Nov 2016, 11:44
by 0sync0
Thank you for this very useful tool.

I opened a GUI created yesterday and the Show Preview Window doesn't respond. Adding a new button opens another tab. Deleting the new tab and clicking Show Preview Window brings up an empty window.

Here's the code.

Code: Select all

Gui Add, DropDownList, vPlayer x57 y43 w120, Player||Karen|Peter
Gui Add, Button, gButtonOK x72 y259 w80 h23 Default, &OK
Gui Add, Text, x53 y12 w120 h23 +0x200 Center +E0x200 Border, Player
Gui Add, Button, gButtonSave x71 y220 w80 h23, Save
Gui Show, w228 h316
Return

; End of the GUI section

ButtonOK:
ButtonSave:

Re: AutoGUI - GUI Designer and Script Editor

Posted: 14 Nov 2016, 17:30
by Alguimist
In order to import the GUI elements from a script, use the Window Cloning Tool. Anyway, the GUI should be destroyed when the tab is closed. Thanks for reporting.