AutoHotkey: Inplace rename facilities: Difference between revisions

From TotalcmdWiki
Jump to navigation Jump to search
No edit summary
(Added category AutoHotkey scripts)
 
(13 intermediate revisions by 4 users not shown)
Line 1: Line 1:
Set of small AHK scripts allowing to perform different tasks in Inplace rename field (or any other place).  
Set of small AHK scripts allowing to perform different tasks (uppercase, lowercase, add or remove underscore ... from the highlighted file in Inplace rename field). It can also be used anywhere else just highlight the text you want to modify and press WinKey+1 or WinKey+2 ...


;UPPERCASE LOWERCASE UNDERSCORE FACILITIES###
;All lowercase  
 
;#1 -> Win Key + 1
;All lowercase
; #1 = Win Key + 1
  #1::
  #1::
ControlGetFocus, ActiveControl, A
  saved_clipboard := ClipboardAll
Send, ^c
  ControlGetFocus, ActiveControl, A
StringLower, lowercase_string, clipboard
  Send, ^c
Send, %lowercase_string%
  ClipWait
Return  
  StringLower, lowercase_string, clipboard
  SendRaw, %lowercase_string%
  Clipboard := saved_clipboard
  saved_clipboard = ; Free the memory in case the clipboard was very large.
Return  


;First letter uppercase
;First letter uppercase
  #2::
  #2::
ControlGetFocus, ActiveControl, A
  saved_clipboard := ClipboardAll
Send, ^c
  ControlGetFocus, ActiveControl, A
StringLower, lowercase_string, clipboard
  Send, ^c
StringLeft, first_letter_of_string, lowercase_string, 1
  ClipWait
StringUpper, first_letter_of_string_uppercase, first_letter_of_string
  StringLower, lowercase_string, clipboard
StringTrimLeft, rest_of_string, lowercase_string, 1
  StringLeft, first_letter_of_string, lowercase_string, 1
Send, %first_letter_of_string_uppercase%%rest_of_string%
  StringUpper, first_letter_of_string_uppercase, first_letter_of_string
Return  
  StringTrimLeft, rest_of_string, lowercase_string, 1
  SendRaw, %first_letter_of_string_uppercase%%rest_of_string%
  Clipboard := saved_clipboard
  saved_clipboard = ; Free the memory in case the clipboard was very large.
Return


;First Of Each Word Uppercase
;First Of Each Word Uppercase
  #3::
  #3::
ControlGetFocus, ActiveControl, A
  saved_clipboard := ClipboardAll
Send, ^c
  ControlGetFocus, ActiveControl, A
;StringUpper, OutputVar, InputVar [, T]  
  Send, ^c
;StringLower, OutputVar, InputVar [, T]  
  ClipWait
;[, T] = If the parameter is the letter T, the string will be converted to title case.
  ;StringUpper, OutputVar, InputVar [, T]  
StringLower, first_each_word_uppercase_string, clipboard, T
  ;StringLower, OutputVar, InputVar [, T]  
Send, %first_each_word_uppercase_string%
  ;[, T] = If the parameter is the letter T, the string will be converted to title case.
Return  
  StringLower, first_each_word_uppercase_string, clipboard, T
  SendRaw, %first_each_word_uppercase_string%
  Clipboard := saved_clipboard
  saved_clipboard = ; Free the memory in case the clipboard was very large.
Return  


;ALL UPPERCASE
;ALL UPPERCASE
  #4::
  #4::
ControlGetFocus, ActiveControl, A
  saved_clipboard := ClipboardAll
Send, ^c
  ControlGetFocus, ActiveControl, A
StringUpper, uppercase_string, clipboard
  Send, ^c
Send, %uppercase_string%
  ClipWait
Return  
  StringUpper, uppercase_string, clipboard
  SendRaw, %uppercase_string%
  Clipboard := saved_clipboard
  saved_clipboard = ; Free the memory in case the clipboard was very large.
Return  


;Replace Space by Underscore
;Replace Space by Underscore
#5::
#5::
  saved_clipboard := ClipboardAll
   ControlGetFocus, ActiveControl, A
   ControlGetFocus, ActiveControl, A
   Send, ^c
   Send, ^c
  ClipWait
   ;StringReplace, OutputVar, InputVar, SearchText [, ReplaceText, ReplaceAll?]   
   ;StringReplace, OutputVar, InputVar, SearchText [, ReplaceText, ReplaceAll?]   
   StringReplace, string_space2underscore, clipboard, %A_SPACE%, _, All
   StringReplace, string_space2underscore, clipboard, %A_SPACE%, _, All
   Send, %string_space2underscore%
   SendRaw, %string_space2underscore%
Return  
  Clipboard := saved_clipboard
  saved_clipboard = ; Free the memory in case the clipboard was very large.
Return  


;Replace Underscore by Space (Remove Underscore)
;Replace Underscore by Space (Remove Underscore)
#6::
#6::
  saved_clipboard := ClipboardAll
   ControlGetFocus, ActiveControl, A
   ControlGetFocus, ActiveControl, A
   Send, ^c
   Send, ^c
  ClipWait
   ;StringReplace, OutputVar, InputVar, SearchText [, ReplaceText, ReplaceAll?]   
   ;StringReplace, OutputVar, InputVar, SearchText [, ReplaceText, ReplaceAll?]   
   StringReplace, string_underscore2space, clipboard, _, %A_SPACE%, All
   StringReplace, string_underscore2space, clipboard, _, %A_SPACE%, All
   Send, %string_underscore2space%
   SendRaw, %string_underscore2space%
Return
  Clipboard := saved_clipboard
  saved_clipboard = ; Free the memory in case the clipboard was very large.
Return


;Replace Dot by Space (Remove Underscore)
;Replace Dot by Space (Remove Underscore)
#7::
#7::
  saved_clipboard := ClipboardAll
   ControlGetFocus, ActiveControl, A
   ControlGetFocus, ActiveControl, A
   Send, ^c
   Send, ^c
  ClipWait
   ;StringReplace, OutputVar, InputVar, SearchText [, ReplaceText, ReplaceAll?]   
   ;StringReplace, OutputVar, InputVar, SearchText [, ReplaceText, ReplaceAll?]   
   StringReplace, string_underscore2space, clipboard, ., %A_SPACE%, All
   StringReplace, string_underscore2space, clipboard, ., %A_SPACE%, All
   Send, %string_underscore2space%
   SendRaw, %string_underscore2space%
Return
  Clipboard := saved_clipboard
  saved_clipboard = ; Free the memory in case the clipboard was very large.
Return


;Replace \ by /  
;Replace \ by /  
#8::   
#8::   
  saved_clipboard := ClipboardAll
   ControlGetFocus, ActiveControl, A
   ControlGetFocus, ActiveControl, A
   Send, ^c
   Send, ^c
  ClipWait
   ;StringReplace, OutputVar, InputVar, SearchText [, ReplaceText, ReplaceAll?]   
   ;StringReplace, OutputVar, InputVar, SearchText [, ReplaceText, ReplaceAll?]   
   StringReplace, string_underscore2space, clipboard, \, /, All
   StringReplace, string_underscore2space, clipboard, \, /, All
   Send, %string_underscore2space%
   SendRaw, %string_underscore2space%
Return
  Clipboard := saved_clipboard
  saved_clipboard = ; Free the memory in case the clipboard was very large.
Return
 
;Add date at end of a filename
#d::
  FormatTime, TimeString,,_(dd_MMM_yyyy_hhmm)
  Send %TimeString%
return
 
;Add date at start of filename
;  to use this script you have to define Strg+Alt+Shift+F2 as "cm_CopyNamestoClip"
;  in TotalCommander's Configuration-Options-Misc-Redefine Hotkeys-Clipboard
#d:: 
IfWinActive, ahk_class TTOTAL_CMD
{
  FormatTime, TimeString,,yyyy_MM_dd__
  send ^!+{F2} 
  send {F6}%TimeString%^v{Enter}
  return
}


Back to [[AutoHotkey]]
{{translated|AutoHotkey: Umbenennbox: verschiedene Spezialfunktionen|AutoHotkey}}
[[Category:AutoHotkey scripts|Inplace rename facilities]]

Latest revision as of 18:43, 6 June 2008

Set of small AHK scripts allowing to perform different tasks (uppercase, lowercase, add or remove underscore ... from the highlighted file in Inplace rename field). It can also be used anywhere else just highlight the text you want to modify and press WinKey+1 or WinKey+2 ...

All lowercase
;#1 -> Win Key + 1
#1::
  saved_clipboard := ClipboardAll
  ControlGetFocus, ActiveControl, A
  Send, ^c
  ClipWait
  StringLower, lowercase_string, clipboard
  SendRaw, %lowercase_string%
  Clipboard := saved_clipboard
  saved_clipboard = ; Free the memory in case the clipboard was very large.
Return 
First letter uppercase
#2::
  saved_clipboard := ClipboardAll
  ControlGetFocus, ActiveControl, A
  Send, ^c
  ClipWait
  StringLower, lowercase_string, clipboard
  StringLeft, first_letter_of_string, lowercase_string, 1
  StringUpper, first_letter_of_string_uppercase, first_letter_of_string
  StringTrimLeft, rest_of_string, lowercase_string, 1
  SendRaw, %first_letter_of_string_uppercase%%rest_of_string%
  Clipboard := saved_clipboard
  saved_clipboard = ; Free the memory in case the clipboard was very large.
Return
First Of Each Word Uppercase
#3::
  saved_clipboard := ClipboardAll
  ControlGetFocus, ActiveControl, A
  Send, ^c
  ClipWait
  ;StringUpper, OutputVar, InputVar [, T] 
  ;StringLower, OutputVar, InputVar [, T] 
  ;[, T] = If the parameter is the letter T, the string will be converted to title case.
  StringLower, first_each_word_uppercase_string, clipboard, T
  SendRaw, %first_each_word_uppercase_string%
  Clipboard := saved_clipboard
  saved_clipboard = ; Free the memory in case the clipboard was very large.
Return 
ALL UPPERCASE
#4::
  saved_clipboard := ClipboardAll
  ControlGetFocus, ActiveControl, A
  Send, ^c
  ClipWait
  StringUpper, uppercase_string, clipboard
  SendRaw, %uppercase_string%
  Clipboard := saved_clipboard
  saved_clipboard = ; Free the memory in case the clipboard was very large.
Return 
Replace Space by Underscore
#5::
  saved_clipboard := ClipboardAll
  ControlGetFocus, ActiveControl, A
  Send, ^c
  ClipWait
  ;StringReplace, OutputVar, InputVar, SearchText [, ReplaceText, ReplaceAll?]  
  StringReplace, string_space2underscore, clipboard, %A_SPACE%, _, All
  SendRaw, %string_space2underscore%
  Clipboard := saved_clipboard
  saved_clipboard = ; Free the memory in case the clipboard was very large.
Return 
Replace Underscore by Space (Remove Underscore)
#6::
  saved_clipboard := ClipboardAll
  ControlGetFocus, ActiveControl, A
  Send, ^c
  ClipWait
  ;StringReplace, OutputVar, InputVar, SearchText [, ReplaceText, ReplaceAll?]  
  StringReplace, string_underscore2space, clipboard, _, %A_SPACE%, All
  SendRaw, %string_underscore2space%
  Clipboard := saved_clipboard
  saved_clipboard = ; Free the memory in case the clipboard was very large.
Return
Replace Dot by Space (Remove Underscore)
#7::
  saved_clipboard := ClipboardAll
  ControlGetFocus, ActiveControl, A
  Send, ^c
  ClipWait
  ;StringReplace, OutputVar, InputVar, SearchText [, ReplaceText, ReplaceAll?]  
  StringReplace, string_underscore2space, clipboard, ., %A_SPACE%, All
  SendRaw, %string_underscore2space%
  Clipboard := saved_clipboard
  saved_clipboard = ; Free the memory in case the clipboard was very large.
Return
Replace \ by /
#8::  
  saved_clipboard := ClipboardAll
  ControlGetFocus, ActiveControl, A
  Send, ^c
  ClipWait
  ;StringReplace, OutputVar, InputVar, SearchText [, ReplaceText, ReplaceAll?]  
  StringReplace, string_underscore2space, clipboard, \, /, All
  SendRaw, %string_underscore2space%
  Clipboard := saved_clipboard
  saved_clipboard = ; Free the memory in case the clipboard was very large.
Return
Add date at end of a filename
#d::
  FormatTime, TimeString,,_(dd_MMM_yyyy_hhmm)
  Send %TimeString% 
return
Add date at start of filename
;  to use this script you have to define Strg+Alt+Shift+F2 as "cm_CopyNamestoClip" 
;  in TotalCommander's Configuration-Options-Misc-Redefine Hotkeys-Clipboard
#d::  
IfWinActive, ahk_class TTOTAL_CMD			
{
  FormatTime, TimeString,,yyyy_MM_dd__ 
  send ^!+{F2}  							
  send {F6}%TimeString%^v{Enter}								
  return
}

Back to AutoHotkey