Make .AHK Files With One Hotkey

Post your working scripts, libraries and tools
godofOOF
Posts: 24
Joined: 22 Dec 2018, 06:03

Make .AHK Files With One Hotkey

28 Dec 2018, 17:32

THE LATEST UPDATE: https://www.autohotkey.com/boards/viewt ... 36#p256636







Spoiler
Last edited by godofOOF on 06 Jan 2019, 13:20, edited 3 times in total.
User avatar
Delta Pythagorean
Posts: 483
Joined: 13 Feb 2017, 13:44
GitHub: DelPyth
Location: Somewhere in the US

Re: Make .AHK Files With One Hotkey

28 Dec 2018, 20:55

This really isn't that useful, sorry to be honest.

If you'd like to use this, fine by me, but I will say, this would be more useful:

Code: Select all

; Saves the clipboard to a new script file on the desktop.
F10::
	FormatTime, TimeStamp,, dd - MM - yyyy hh|mm tt
	FileAppend, % Clipboard, % A_Desktop "\" timestamp ".ahk"
	Return
godofOOF
Posts: 24
Joined: 22 Dec 2018, 06:03

Re: Make .AHK Files With One Hotkey

29 Dec 2018, 05:46

UPDATE 12.29.2018

FIXES:
  • you can now make endless amounts of files without a limit
  • you can now automatically open the file as soon as its made the msg box function will ask if you want to open it or not
note:: Change C:\Program Files\AutoHotkey\SciTE\SciTE.exe to your default program editor you use for ahk

Code: Select all

;Random, var, 1, 6 <- alternative way to renaming files 
F9::
formattime, timestamp, a_now , yyyyMMdd_HHmmss
ClipSaved := Clipboard
Send ^l^c
formattime, timestamp, a_now , yyyyMMdd_HHmmss
FileAppend This is a script BOI, %Clipboard%\%timestamp%.ahk ;file%var%.ahk <- alternative way to renaming files 
Clipboard := ClipSaved
return



F10::
filename= %A_Desktop%\%timestamp%.ahk 
;%A_Desktop%\filename%var%.ahk ;another way to approach autonaming the files 
;text= gey ;dosent really need any text in the file 
FileAppend, %text%, %filename% ;WORKS BUT ONLY ONCE
formattime, timestamp, a_now , yyyyMMdd_HHmmss
MsgBox, 262148, Open AHK File, Do you want to open this file?, 2
IfMsgBox, No 
	return
IfMsgBox, Timeout
    Return
IfMsgBox, Yes 
	formattime, timestamp, a_now , yyyyMMdd_HHmmss
Run, C:\Program Files\AutoHotkey\SciTE\SciTE.exe "%A_Desktop%\%timestamp%.ahk"
return
godofOOF
Posts: 24
Joined: 22 Dec 2018, 06:03

Re: Make .AHK Files With One Hotkey

06 Jan 2019, 13:17

UPDATED 2019-06-JAN


SCREENSHOT
Spoiler



FIXES:
  • You Can Now Make ahk A File AnyWhere Using The F9 Key!
  • You Know Can Be in any Windows Explorer window(including desktop) and create a file!
  • Fixed Making Files On Desktop And Directory On Clipboard at the same time
  • Fixed Bad Logic
  • Added more message boxes to make it more intuitive

HOW TO USE :terms:
(Optional) Make Sure you have Scite installed

1. If C:\A_Programs\AutoHotkey\SciTE\SciTE.exe dosent open the file via msg box use your specific directory

2. The Only Things you need to modify to run this script fully is the program that you you use to edit autohotkey files

For Example:

instead of C:\A_ProgramFiles\AutoHotkey\SciTE\SciTE.exe "%A_Desktop%\%timestamp%.ahk"

(if your editor is notepad do) C:\WINDOWS\system32\notepad.exe"%A_Desktop%\%timestamp%.ahk"


F10:
This key Looks at if your desktop or windows explorer is active and Makes the file based off that

If your on the desktop (it makes files on the desktop)

if your on file explorer it makes the file on the current open directory

F9::
This key is the newest feature allows you to send your file anywhere on your system

it uses an inputbox to do that, And prompting you with msg boxes asking whether you want to open the file




Hope you enjoy it! :bravo:

Advice and feedback is appreciated :D





Code: Select all

;Created by godofOOF
; Source: https://www.autohotkey.com/boards/viewtopic.php?f=6&t=60419
; UPDATED 2018-06-JAN
;This script allows you to send ahk files to diffrent folders
;and it allows you to easily create AHK files in any dir
;RunAsTask Is not Required But i use it to ensure that the script WORKS properly
; The Libary For RunAsTask Is Here https://www.autohotkey.com/boards/viewtopic.php?f=6&t=4334&hilit=RunAsTask


~F10::
;RunAsTask()
IfWinActive, ahk_class CabinetWClass
	SendInput,^l
Sleep,100
SendInput,^c
Sleep,100
formattime, timestamp, a_now , yyyyMMdd_HHmmss
filename= %Clipboard%\%timestamp%.ahk
FileAppend, %text%, %filename%
MouseClick
IfWinActive, ahk_class CabinetWClass
	MsgBox, 262148, Open AHK File, Do you want to open this file?, 2
IfMsgBox, Yes
	Run, C:\A_Programs\AutoHotkey\SciTE\SciTE.exe "%Clipboard%\%timestamp%.ahk"
IfWinNotActive, ahk_class WorkerW
	#If
return
IfWinActive, ahk_class WorkerW
	FileDelete,%Clipboard%\%timestamp%.ahk
formattime, timestamp, a_now , yyyyMMdd_HHmmss
filename= %A_Desktop%\%timestamp%.ahk
FileAppend, %text%, %filename%
IfWinActive,  ahk_class WorkerW
	MsgBox, 262148, Open AHK File, Do you want to open this file?, 2
IfMsgBox, No
	return
IfMsgBox, Timeout
	Return
IfMsgBox, Yes
	Run, C:\A_Programs\AutoHotkey\SciTE\SciTE.exe "%A_Desktop%\%timestamp%.ahk"
return

#IfWinActive, ahk_exe explorer.exe
~F9::
MsgBox, 262147, AHK Creator, Did You Already Copy The Directory?
IfMsgBox, Yes
{
	MsgBox, 262180, AHK Creator, Sending.., .25
	formattime, timestamp, a_now , yyyyMMdd_HHmmss
	filename= %Clipboard%\%timestamp%.ahk
	FileAppend, %text%, %filename%
	Run,%Clipboard%
	return
}
IfMsgBox, Cancel
	return
else
	IfMsgBox, No
		InputBox, Dir, Send AHK File to Directory, Where do you want to send the file?
WinActivateBottom, Send AHK File to Directory
if ErrorLevel
	return
else
	formattime, timestamp, a_now , yyyyMMdd_HHmmss
FileAppend %timestamp%, %Dir%\%timestamp%.ahk
MsgBox, 262180, AHK Creator, Do you want to open the file?
IfMsgBox, Yes
	Run, C:\A_ProgramFiles\AutoHotkey\SciTE\SciTE.exe "%Dir%\%timestamp%.ahk"
IfMsgBox, No
	return
return
Last edited by godofOOF on 09 Jan 2019, 03:26, edited 1 time in total.
User avatar
tidbit
Posts: 1147
Joined: 29 Sep 2013, 17:15
Location: USA

Re: Make .AHK Files With One Hotkey

06 Jan 2019, 19:42

I'd recommend FileSelectFile or FileSelectFolderinstead of an input box.
https://autohotkey.com/docs/commands/FileSelectFile.htm
https://autohotkey.com/docs/commands/Fi ... Folder.htm
rawr. fear me.
*poke*
Is it December 21, 2012 yet?
godofOOF
Posts: 24
Joined: 22 Dec 2018, 06:03

Re: Make .AHK Files With One Hotkey

09 Jan 2019, 03:21

tidbit wrote:
06 Jan 2019, 19:42
I'd recommend FileSelectFile or FileSelectFolderinstead of an input box.
https://autohotkey.com/docs/commands/FileSelectFile.htm
https://autohotkey.com/docs/commands/Fi ... Folder.htm
yeah i agree defiantly a better approach ill work on it when i get the chance thanks for the feedback :D

Return to “Scripts and Functions”

Who is online

Users browsing this forum: No registered users and 39 guests