AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Restoring recently deleted text

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
keyboardfreak



Joined: 09 Oct 2004
Posts: 143
Location: Budapest, Hungary

PostPosted: Tue Jul 15, 2008 10:04 am    Post subject: Restoring recently deleted text Reply with quote

Sometimes I delete chunks of text which I regret later and I want to restore them. Undo is useful for that, but the problem is often I've already written more text since the deletion, so undo reverts those in-between changes too which I would like to keep.

The script below monitors if a selected part of the text is deleted and if so then it stores the selection first before sending the delete key.

With ctrl+delete one can restore a few recent deletions.

Note the script is only a proof of concept. It's very unpolished. For example, it shows only several stored items even if there are more available, because I used an inputbox due to lazyness.

I put it here only as an example. Someone may get interested and develop the idea properly:

Code:
max_items := 10
items := 0
current := 0

$delete::
  oldclip := clipboard
  sendinput ^c
 
  if (clipboard <> oldclip)
  {
    items%current% := clipboard
   
    items += 1
    if (items > max_items)
      items := max_items

    current += 1
    if (current = max_items)
      current = 0
  }
 
  clipboard := oldclip
 
  sendinput {delete}
 
  return
 
 
^delete::
  if (items = 0)
  {
    msgbox no items
    return
  }
 
  start := current
  msg = Choose an item:`n`n

  loop % items
  {
    start -= 1     
    if (start = -1)
      start := max_items - 1
   
    msg := msg . start . " - " . items%start% . "`n"
  }
 
  InputBox, input, Restore deletion, %msg%
  if not ErrorLevel
  {
    oldclip := clipboard
    clipboard := items%input%
    sendinput ^v
    clipboard := oldclip
  }

  return
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group