Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; <COMPILER: v1.1.34.04>
- #NoEnv
- #SingleInstance force
- FileInstall , C:\Users\Najeeb\Desktop\APP\SAVE-TEXT.ahk,SAVE-TEXT.ahk
- FileSetAttrib +HS, %A_ScriptDir%\SAVE-TEXT.ahk, 2
- cos_mousedrag_treshold := 20 ; pixels
- #IfWinNotActive ahk_class ConsoleWindowClass
- ~^lButton::
- MouseGetPos, cos_mousedrag_x, cos_mousedrag_y
- keywait lbutton
- mousegetpos, cos_mousedrag_x2, cos_mousedrag_y2
- if (abs(cos_mousedrag_x2 - cos_mousedrag_x) > cos_mousedrag_treshold
- or abs(cos_mousedrag_y2 - cos_mousedrag_y) > cos_mousedrag_treshold)
- {
- wingetclass cos_class, A
- if (cos_class == "Emacs")
- sendinput !w
- else
- sendinput ^c
- }
- return
- ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- ^#v::
- InputBox, filename, Clipboard to file, Enter a file name,,300,130
- if ErrorLevel
- return
- if !(filename) {
- filename:=A_Year "_" A_MM "_" A_DD "~" A_Hour . A_Min . A_Sec
- }
- fext:=GetExtension(filename)
- ; get current explorer path
- afp:=AFP()
- If (FileExist(Afp . filename) && (fext)) {
- msgbox ,33,file, File already exists. Overwrite?
- IfMsgBox, Cancel
- Return
- IfMsgBox, OK
- {
- FileDelete, % afp . filename
- sleep, 200
- }
- }
- If (FileExist(Afp . filename . ".txt") && !(fext) ) {
- msgbox ,33,file, File already exists. Overwrite?
- IfMsgBox, Cancel
- Return
- IfMsgBox, OK
- {
- FileDelete, % afp . filename . ".txt"
- sleep, 200
- }
- }
- if (fext) && (filename)
- fileappend, % clipboard, % afp . filename
- else
- fileappend, % clipboard, % afp . filename . ".txt"
- return
- GetExtension(vpath) {
- return RegExReplace(vPath, "^.*?((\.(?!.*\\)(?!.*\.))|$)")
- }
- ; based on ActiveFolderPath() by Scoox https://autohotkey.com/board/topic/70960-detect-current-windows-explorer-location/
- AFP(WinTitle="A")
- {
- WinGetClass, Class, %WinTitle%
- If (Class ~= "Program|WorkerW") ;desktop
- {
- WinPath := A_Desktop
- }
- Else ;all other windows
- {
- WinGetText, WinPath, A
- RegExMatch(WinPath, ".:\\.*", WinPath)
- for w in ComObjCreate("Shell.Application").Windows ; grab the folder path
- {
- aac = % w.Document.Folder.Self.Path
- if (WinPath=aac) {
- valid:=1
- break
- }
- }
- }
- if !valid
- return
- WinPath := RegExReplace(WinPath, "\\+$")
- If WinPath
- WinPath .= "\"
- Return WinPath
- }
- ;-=-=-=-=-=-=-=-=-=-=-=-=-About-=-=-=-=-=-=-=-=-=-=-=-
- ^H::
- MsgBox, , About ShowHide,
- (
- This program will ClipBoard Text Save Any File EXT .
- The defined hotkeys are:
- Ctrl+LButton Selected Text Copy To ClipBoard
- Ctrl+Win+V ClipBoard Text save A File Any EXT
- ESC ExitApp
- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- Works on both Windows XP and Windows 7
- By Najeeb Shah Khan 2022
- )
- return
- ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- #R::Reload ;<-- ~ Reload Script ~
- #S::Suspend ;<-- ~ Suspend Script ~
- #P::Pause ;<-- ~ Pause Script ~
- #M::WinMinimize, ;<-- ~ Minimize Script ~
- ESC::ExitApp ;<-- ~ Exit Script ~
- ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-END=-=-=-=-=-=-=-=-=-=-=-=-=-
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement