Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

[Library] Edit v1.3 - Update/Control any Edit control


  • Please log in to reply
35 replies to this topic
tov
  • Guests
  • Last active:
  • Joined: --
This is where I'm at..

Pressing F1 returns the number of lines ( used for a quick check )
Pressing F2 deletes the first line..

Once the first line has been deleted, I need the cursor on a new line after the very last line... ( does that make sense )

How do I do that ? thanks :)

#include Edit.ahk
#include Edit_DeleteLine.ahk
#include Edit_SelectLine.ahk
Menu, FileMenu, Add, Exit, Exit
Menu, HelpMenu, Add, Help, Help

Menu, MyMenuBar, Add, &File, :FileMenu
Menu, MyMenuBar, Add, &Help, :HelpMenu

Gui, Menu, MyMenuBar
Gui, Add, Edit, w175 h175 hwndLogHwnd, ABABABABABABABAB`r`123451234512345`r`n999999999999999`r`nZZZZZZZZZZZZZZZZZZZZ
Gui, Show,w200 H200,
return

Exit:
Help:
exitapp
return

F1::
len:=Edit_GetLineCount(LogHwnd)
msgbox %len%
return

F2::
Edit_DeleteLine(LogHwnd,p_LineIdx=0)
return


jballi
  • Members
  • 1029 posts
  • Last active:
  • Joined: 01 Oct 2005
You're on the right track tov. Just use the Edit_SetSel function to move the cursor to the bottom. I've modified your example to fit the bill but you get the idea.

#include Edit.ahk
#include Edit_DeleteLine.ahk
#include Edit_SelectLine.ahk
Menu, FileMenu, Add, Exit, Exit
Menu, HelpMenu, Add, Help, Help

Menu, MyMenuBar, Add, &File, :FileMenu
Menu, MyMenuBar, Add, &Help, :HelpMenu

Gui, Menu, MyMenuBar
Gui, Add, Edit, w175 h175 hwndLogHwnd, ABABABABABABABAB`r`n123451234512345`r`n999999999999999`r`nZZZZZZZZZZZZZZZZZZZZ`r`n
Gui, Show,w200 H200,
return

Exit:
Help:
GUIEscape:
GUIClose:
exitapp
return

F1::
len:=Edit_GetLineCount(LogHwnd)
msgbox %len%
return

F2::
Edit_DeleteLine(LogHwnd,p_LineIdx=0)
TL:=Edit_GetTextLength(LogHwnd)
Edit_SetSel(LogHwnd,TL,TL)
Edit_ScrollCaret(LogHwnd)   ;-- This makes sure the last line can be seen
return
Good luck!

tov
  • Guests
  • Last active:
  • Joined: --
Cheers
I'll try this in the morning..

Should this work OK with a GUI Edit that is constantly being updated from a live stream (using editpaste)

My aim is to try an limit the 'edit' to approx 5000 lines and then as new lines are added, old ones are deleted... obviously the edit needs to have scrolled to the bottom so it's acting as an effective 'tail' for a live tcp stream.

Thanks :)

shajul
  • Members
  • 571 posts
  • Last active: Aug 01 2015 03:45 PM
  • Joined: 15 Sep 2006
This is a wonderful library!! Thanks for your hard work :)
If i've seen further it is by standing on the shoulders of giants

my site | ~shajul | WYSIWYG BBCode Editor

jballi
  • Members
  • 1029 posts
  • Last active:
  • Joined: 01 Oct 2005
No Dialog Find, Find Previous, Find Next, and Replace

I download therefore I rename.

I'm forever making minor name changes to the files that I download from the interwebs. Usually, I need to replace several "_" or "." characters. Many times the title is all upper/lower case and I want to capitalize the title.

A rename program for one file is overkill so I was looking for something else to help me quickly make minor changes to a single file name. I noticed that when making changes to a file in Windows Explorer, an Edit control is shown so I thought, "The Edit Library would be perfect for this!"

When making changes to a file name in Windows Explorer, the Edit control shown is a self-contained dialog. If any other windows or dialogs are shown, the Edit control is hidden/closed. Adding a dialog to enter Find and Replace information is out of the question. A "No Dialog" Find/Replace command is what is needed.

This script provide the following no-dialog commands:
  • Find (Ctrl+Win+Alt+F). To use:
    • Press hotkey.
    • Enter search text. Press Enter to start the search.
  • A few notes:
    • The search text is not displayed (echoed) as you are typing so enter carefully. The Backspace key can be used to erase incorrect characters.
    • The search text is not case sensitive.
    • Use the Escape key to abort at any time.
  • Find Next (Ctrl+Win+Alt+F3) and Find Previous (Ctrl+Win+Alt+F2). These commands use the last search string entered by the Find command.
  • Replace (Ctrl+Win+Alt+H). To use:
    • Select working text. This step will limit the Replace command to only the text that is selected.
    • Press hotkey.
    • Enter the search and replace text. The Enter key indicates the end of input. Press Enter at the end of the search text and at the end the replace text.
    A few notes:
    • The search/replace text is not displayed (echoed) as you are typing so enter carefully. The Backspace key can be used to erase incorrect characters.
    • The search text is not case sensitive but the replace text is used as typed.
    • Use the Escape key to abort at any time.
    • If needed, use Undo (Ctrl+Z) to reverse the change.
    • By design, this is a "Replace All" command. If you only want to replace a specific number of occurrences of the search string, be sure to only select the desired target text. For example, to replace all "." characters in a file name, select all but the last node of the file (Ex: Select everything except the ".pdf" at the end).
    For example, to replace "red" with "blue" (sans quotes), do the following:
    • Select the text that includes the "red" string.
    • Press the Replace hotkey: Ctrl+Win+Alt+H
    • Type the following: red{Enter}blue{Enter}
    • If needed, use Undo (Ctrl+Z) to reverse the change.
  • Convert Case. The following commands are available (select the desired text before using):
    • Lowercase (Ctrl+Win+Alt+L).
    • Uppercase (Ctrl+Win+Alt+U).
    • Capitalize (Ctrl+Win+Alt+C). I use this one a lot.
    • Toggle case (Ctrl+Win+Alt+T).
  • Here's the code (needs the Edit Library of course):

    A couple of final thoughts...
    • Although the Find and Replace commands were originally designed for a single-line Edit control, they will work on any edit control.
    • This script is just an example. Please feel free to make any changes you want.


jballi
  • Members
  • 1029 posts
  • Last active:
  • Joined: 01 Oct 2005
Validate As You Type

The idea for this example was gleaned from an script published by jsherk. Thanks! The original post can be found here.

Real-Time Validation/Auto-Correct probably shouldn't be used on most Edit control objects but I'm sure there a few places where this little gem can provide real value. The concept is fairly simple: Stop the user from entering invalid characters as they are typing.

Here's the example script (needs the Edit Library of course):


A few final thoughts...
  • For most applications, these examples represent a non-standard method of data validation. Use with discretion.
  • Although this method of validation will work on any edit control, it works best on short, single-line edit controls.
  • I hope that someone finds this useful.


abeonis
  • Members
  • 41 posts
  • Last active: Jul 25 2013 05:35 PM
  • Joined: 31 May 2012
This is exactly the library I was looking for. I am using AHK_L but unfortunately, part of this library doesn´t work for me. I am mainly interested in the Example - Find and replace.ahk. Any idea why? Is there a workaround? Thank you.

jballi
  • Members
  • 1029 posts
  • Last active:
  • Joined: 01 Oct 2005

This is exactly the library I was looking for. I am using AHK_L but unfortunately, part of this library doesn´t work for me. I am mainly interested in the Example - Find and replace.ahk. Any idea why? Is there a workaround? Thank you.

Thank you for your interest.

I've been working on a new version of the Edit library off and on for while. The new version supports Unicode (aka AutoHotkey_L Unicode) and includes a few new functions. I haven't gotten around to releasing it because 1) other priorities, 2) I'm rewriting most of the examples, and 3) some of the add-ons doesn't work with L Unicode (yet).

If you are interested, PM me and I will send you a copy of the latest version of the main library (no add-ons). It should work fine with AutoHotkey_L Unicode.

abeonis
  • Members
  • 41 posts
  • Last active: Jul 25 2013 05:35 PM
  • Joined: 31 May 2012
It worked jballi. Many thanks.

jballi
  • Members
  • 1029 posts
  • Last active:
  • Joined: 01 Oct 2005
v1.2
New stuff plus changes to support Unicode. See the Release Notes and the Issues/Considerations sections of the first post for more information.

jballi
  • Members
  • 1029 posts
  • Last active:
  • Joined: 01 Oct 2005
v1.3
New functions plus a few new examples. See the Release Notes section of the first post for more information.

Learning one
  • Members
  • 1483 posts
  • Last active: Jan 02 2016 02:30 PM
  • Joined: 04 Apr 2009
Great library, great documentation, great examples. Thanks! :D

My Website • Recommended: AutoHotkey Unicode 32-bit • Join DropBox, Copy


  • Guests
  • Last active:
  • Joined: --
Brilliant library!I tried QuickBBCode,like it.Thank you for this great lib. :lol:

jballi
  • Members
  • 1029 posts
  • Last active:
  • Joined: 01 Oct 2005
Controlling a ListView's Edit control
 
If the "-ReadOnly" option is included when creating a ListView control, the user can edit the contents of the first column of a row by selecting the row then pressing the F2 key.  The ListView control creates an Edit control immediately over the first column and the user is allowed to add and/or update the column text.  The bad news is that by default, there are no restrictions as to what the user can change while in "Edit" mode.  The Edit library can be used to "enhance" this feature.  The following example includes a few ideas of stuff that can be done to the ListView's Edit control after it has been created but before the user has made any changes.
 

I hope that someone finds this useful.

jballi
  • Members
  • 1029 posts
  • Last active:
  • Joined: 01 Oct 2005
Increase the power of the standard InputBox dialog

The idea for this example was gleaned from an script published by just me. Thanks! The original post can be found here.

The standard InputBox dialog is very limited. It will prompt the user for a string/value but there is no restriction as to what the user can enter. The Edit Library can be used to add restrictions to the input field and if needed, change the value of the default string before the user can make any changes.

The following is just an example of some of the stuff you can do.