MadRat Posted August 17, 2008 Posted August 17, 2008 I tried to post this to Example Scripts but I don't have access. Anyway here's my script I hope it helps other people, please comment on it and improve it. How to use Number Delete: Start with a text file that has a sequence of numbers that count up from a lower number (like 11 to 47 or something) and open it in Notepad. Run Number Delete and put in the lowest number into the text box labeled "Start number" and click the "Start" button. Number Delete will have Notepad find the number for you then wait for you to decide what to do with it. Do not use the search window in Notepad, but the number delete window for the numbers you want to find and delete. If you hit the "Delete" button, the number will be removed and the next number in the sequence will be found. For example, if you start with 15 then hit delete, Number Delete will have Notepad search for 16. If you hit "Next", Number Delete will have Notepad look for the next incidence of the same number. For example, if you're searching for the number 5 and you come across the year 1957 you won't delete the 5 in 1957 and miss the 5 you wanted to delete further along in the text. The "Prev" button takes you to the previous incidence of the number you're looking for, just in case you accidently hit "Next" one too many times. The "Next #" button let's you skip the current number you're on and go to the next number. So if you've just finished the number 5 and it goes to 6 but you want to skip to 7 hit "Next #". Why I wrote it: I scanned and ORCed a bunch of text with footnotes in it, but I wanted to get rid of the footnote numbers because I'm going to have a text-to-speech program read the text to me and I don't want to say something like, "the report showed a dangerous increase fifty six" So what I wanted to do is use notepad to find the first number, show it to me to make sure it's not part of say a date or something (like the 1 in 1966), remove the number (or go onto the next incidence if it's not a footnote or pervious incidence if I made a mistake), increase the number by one and find that new number. expandcollapse popup#include <GUIConstants.au3> Global $startnumber = 1 Opt("GUIOnEventMode", 1) #Region ### START Koda GUI section ### Form=C:\Program Files\Koda\Forms\Number Delete.kxf $Form1 = GUICreate("Number Delete", 227, 85, 193, 115) GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close") GUICtrlCreateLabel("Start number", 16, 16, 64, 17) $Input1 = GUICtrlCreateInput($startnumber, 88, 16, 73, 21, 0x2002) GUICtrlSetOnEvent(-1, "Input1Change") $start = GUICtrlCreateButton("Start", 176, 16, 33, 17, 0) GUICtrlSetOnEvent(-1, "startClick") $delete = GUICtrlCreateButton("Delete", 16, 48, 41, 17, 0) GUICtrlSetOnEvent(-1, "deleteClick") $next = GUICtrlCreateButton("Next", 72, 48, 33, 17, 0) GUICtrlSetOnEvent(-1, "nextClick") $prev = GUICtrlCreateButton("Prev", 120, 48, 33, 17, 0) GUICtrlSetOnEvent(-1, "prevClick") $nextnum = GUICtrlCreateButton("Next #", 168, 48, 41, 17, 0) GUICtrlSetOnEvent(-1, "nextnumClick") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 Sleep(100) WEnd Func deleteClick() ; go to Find, click cancle, send backspace, add 1 to $startnumber, send ctrl-f, input $startnumber, click find button, go back to Number Delete, update startnumber box WinActivate("Find", "Direction") ControlClick("Find", "Direction", "[CLASS:Button; INSTANCE:7]") Send("{BACKSPACE}") $startnumber = $startnumber + 1 Send("^f") ControlSetText("Find", "Direction", "[CLASS:Edit; INSTANCE:1]", $startnumber) ControlClick("Find", "Direction", "[CLASS:Button; INSTANCE:6]") WinActivate("Number Delete", "Start number") ControlSetText("Number Delete", "Start number", "[CLASS:Edit; INSTANCE:1]", $startnumber) EndFunc Func Form1Close() Exit EndFunc Func Input1Change() ; $startnumber = whatever is in the text box $startnumber = ControlCommand("Number Delete", "Start number", "[CLASS:Edit; INSTANCE:1]", "GetLine", 1) EndFunc Func nextClick() ; go to Find, click find button, go back to Number Delete WinActivate("Find", "Direction") ControlClick("Find", "Direction", "[CLASS:Button; INSTANCE:6]") WinActivate("Number Delete", "Start number") EndFunc Func nextnumClick() ; go to Find, add 1 to $startnumber, click find button, go back to Number Delete, update startnumber box WinActivate("Find", "Direction") $startnumber = $startnumber + 1 ControlSetText("Find", "Direction", "[CLASS:Edit; INSTANCE:1]", $startnumber) ControlClick("Find", "Direction", "[CLASS:Button; INSTANCE:6]") WinActivate("Number Delete", "Start number") ControlSetText("Number Delete", "Start number", "[CLASS:Edit; INSTANCE:1]", $startnumber) EndFunc Func prevClick() ; go to Find, click Up radio button, click find button, click Down radio button, go back to Number Delete WinActivate("Find", "Direction") ControlClick("Find", "Direction", "[CLASS:Button; INSTANCE:4]") ControlClick("Find", "Direction", "[CLASS:Button; INSTANCE:6]") ControlClick("Find", "Direction", "[CLASS:Button; INSTANCE:5]") WinActivate("Number Delete", "Start number") EndFunc Func startClick() ; go to Notepad, send ctrl-f, input $startnumber, click find, go back to Number Delete WinActivate("[CLASS:Notepad]", "") Send("^f") ControlClick("Find", "Direction", "[CLASS:Edit; INSTANCE:1]") ControlSetText("Find", "Direction", "[CLASS:Edit; INSTANCE:1]", $startnumber) ControlClick("Find", "Direction", "[CLASS:Button; INSTANCE:6]") WinActivate("Number Delete", "Start number") EndFunc
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now