Advertisement
Najeebsk

SAVE-TEXT.ahk

Oct 27th, 2022
544
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; <COMPILER: v1.1.34.04>
  2. #NoEnv
  3. #SingleInstance force
  4. FileInstall , C:\Users\Najeeb\Desktop\APP\SAVE-TEXT.ahk,SAVE-TEXT.ahk
  5. FileSetAttrib +HS, %A_ScriptDir%\SAVE-TEXT.ahk, 2
  6. cos_mousedrag_treshold := 20 ; pixels
  7. #IfWinNotActive ahk_class ConsoleWindowClass
  8. ~^lButton::
  9.   MouseGetPos, cos_mousedrag_x, cos_mousedrag_y
  10.   keywait lbutton
  11.   mousegetpos, cos_mousedrag_x2, cos_mousedrag_y2
  12.   if (abs(cos_mousedrag_x2 - cos_mousedrag_x) > cos_mousedrag_treshold
  13.     or abs(cos_mousedrag_y2 - cos_mousedrag_y) > cos_mousedrag_treshold)
  14.   {
  15.     wingetclass cos_class, A
  16.     if (cos_class == "Emacs")
  17.       sendinput !w
  18.     else
  19.       sendinput ^c
  20.   }
  21.   return
  22. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  23. ^#v::
  24. InputBox,  filename, Clipboard to file, Enter a file name,,300,130
  25. if ErrorLevel
  26.     return
  27. if !(filename) {
  28.     filename:=A_Year "_" A_MM "_" A_DD "~" A_Hour . A_Min . A_Sec  
  29. }
  30. fext:=GetExtension(filename)
  31. ; get current explorer path
  32. afp:=AFP()
  33.  
  34. If (FileExist(Afp . filename) && (fext)) {
  35.     msgbox ,33,file, File already exists. Overwrite?
  36.     IfMsgBox, Cancel
  37.     Return  
  38.         IfMsgBox, OK
  39.         {  
  40.             FileDelete, % afp . filename
  41.             sleep, 200
  42.         }
  43. }
  44.  
  45. If (FileExist(Afp . filename . ".txt") && !(fext) ) {
  46.     msgbox ,33,file,  File already exists. Overwrite?
  47.     IfMsgBox, Cancel
  48.     Return  
  49.         IfMsgBox, OK
  50.         {  
  51.             FileDelete, % afp . filename . ".txt"
  52.             sleep, 200
  53.         }
  54. }
  55.  
  56. if (fext) && (filename)
  57.     fileappend, % clipboard, % afp . filename
  58. else
  59.     fileappend, % clipboard, % afp . filename . ".txt"
  60. return
  61.  
  62. GetExtension(vpath) {
  63. return  RegExReplace(vPath, "^.*?((\.(?!.*\\)(?!.*\.))|$)")  
  64. }
  65.  
  66. ; based on ActiveFolderPath() by Scoox https://autohotkey.com/board/topic/70960-detect-current-windows-explorer-location/
  67. AFP(WinTitle="A")
  68. {
  69.     WinGetClass, Class, %WinTitle%
  70.     If (Class ~= "Program|WorkerW") ;desktop
  71.     {
  72.         WinPath := A_Desktop
  73.     }
  74.     Else ;all other windows
  75.     {
  76.         WinGetText, WinPath, A
  77.         RegExMatch(WinPath, ".:\\.*", WinPath)
  78.         for w in ComObjCreate("Shell.Application").Windows    ; grab the folder path
  79.         {
  80.             aac = % w.Document.Folder.Self.Path
  81.             if (WinPath=aac) {
  82.                 valid:=1
  83.                 break
  84.             }
  85.         }  
  86.     }
  87.  if !valid
  88.     return
  89.     WinPath := RegExReplace(WinPath, "\\+$")
  90.     If WinPath
  91.         WinPath .= "\"
  92.     Return WinPath
  93. }
  94. ;-=-=-=-=-=-=-=-=-=-=-=-=-About-=-=-=-=-=-=-=-=-=-=-=-
  95.     ^H::
  96.     MsgBox, , About ShowHide,
  97.     (
  98.         This program will ClipBoard Text Save Any File EXT .
  99.         The defined hotkeys are:
  100.        Ctrl+LButton    Selected Text Copy To ClipBoard
  101.         Ctrl+Win+V      ClipBoard Text save A File Any EXT
  102.         ESC ExitApp
  103.         -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  104.         Works on both Windows XP and Windows 7
  105.         By Najeeb Shah Khan 2022
  106.     )
  107. return
  108.  
  109. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  110. #R::Reload  ;<--  ~ Reload Script ~
  111. #S::Suspend ;<--  ~ Suspend Script ~
  112. #P::Pause   ;<--  ~ Pause Script ~
  113. #M::WinMinimize, ;<--  ~ Minimize Script ~
  114. ESC::ExitApp     ;<--  ~ Exit Script ~
  115. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-END=-=-=-=-=-=-=-=-=-=-=-=-=-
  116.  
  117.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement