How to keep only the lines with inputdata. Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
hancre
Posts: 248
Joined: 02 Jul 2021, 20:51

How to keep only the lines with inputdata.

Post by hancre » 26 Mar 2023, 06:46

I want to keep only the lines with inputdata and remove other lines.
When I tried this following script, nothing happened after adding the keyword to inputbox.

Code: Select all

Capslock & f:: ;https://onlinetexttools.com/remove-duplicate-text-lines
   Clipboard := ""
   Send ^c
   ClipWait 
    InputBox Search, Remove a specfic word            ;  Get it here
   Clipboard := RegExReplace(Clipboard, "(?mUO)`a(?!.*<Search>).*\R*", "")
    Send ^v
  Sleep 100
Return
Raw data )
Gui +LastFound
Gui, Add, Text,, Enter first keyword to make bold:
Gui, Add, Edit, vKeyword1 w200,
Gui, Add, Text,, Enter second keyword to make bold:
Gui, Add, Edit, vKeyword2 w200,
Gui, Add, Text,, Enter third keyword to make bold:
Gui, Add, Edit, vKeyword3 w200,
Gui, Add, Button, gBoldText, Bold
Gui, Show, Center

What I want ) When I put 'edit' in the inputbox, this following lines shows and other lines disappears.
Gui, Add, Edit, vKeyword1 w200,
Gui, Add, Edit, vKeyword2 w200,
Gui, Add, Edit, vKeyword3 w200,


Thanks for any help in advance.

User avatar
mikeyww
Posts: 26891
Joined: 09 Sep 2014, 18:38

Re: How to keep only the lines with inputdata.  Topic is solved

Post by mikeyww » 26 Mar 2023, 07:46

Code: Select all

; This script filters text from the Clipboard, and pastes the remainder
#Requires AutoHotkey v1.1.33

CapsLock::CapsLock
CapsLock & f::
Clipboard := ""
Send ^c
ClipWait 0
If !ErrorLevel {
 InputBox, keep, Filter text, Enter the text to keep.,, 300, 125
 If !ErrorLevel && keep != "" {
  Clipboard := keepText(Clipboard, keep)
  Send ^v
 }
} Else MsgBox 48, Error, An error occurred while waiting for the clipboard.
Return

keepText(str, keep) {
 Loop Parse, str, `n, `r
  InStr(A_LoopField, keep) && out .= A_LoopField "`n"
 Return Trim(out, "`n")
}

hancre
Posts: 248
Joined: 02 Jul 2021, 20:51

Re: How to keep only the lines with inputdata.

Post by hancre » 29 Mar 2023, 22:06

mikeyww wrote:
26 Mar 2023, 07:46
Thank you for your help. I can get the result thanks to your code. ^^;;

Post Reply

Return to “Ask for Help (v1)”