Skip to content

Instantly share code, notes, and snippets.

@graywolfcorp
Last active February 1, 2024 20:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save graywolfcorp/08cafafda5d51ccdac25a8b45afd3d77 to your computer and use it in GitHub Desktop.
Save graywolfcorp/08cafafda5d51ccdac25a8b45afd3d77 to your computer and use it in GitHub Desktop.
AutoIt macro to save easylanguage code locally
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <StringConstants.au3>
HotKeySet("{F1}", "openTabs")
HotKeySet("{F7}", "copyELD")
HotKeySet("{F6}", "terminate")
Func copyELD()
$window_title = WinGetTitle("[active]")
WinActivate($window_title)
Send("{CTRLDOWN}a{CTRLUP}{CTRLDOWN}c{CTRLUP}")
$variable_fromclipboard = ClipGet()
Send("{ESC}")
Local $firstPosition = StringInStr($window_title, "-")
Local $lastPosition = StringInStr($window_title, ":")
Local $sFilename = StringMid($window_title, $firstPosition+2, $lastPosition - $firstPosition-3)
$sFilename &= ".txt"
Local $sPath = ""
Local $firstPathPosition = StringInStr($variable_fromclipboard, "// PATH")
if $firstPathPosition > 0 Then
Local $lastPathPosition = StringInStr($variable_fromclipboard, @CRLF,0,1,$firstPathPosition)
$sPath = StringMid($variable_fromclipboard, $firstPathPosition + 8, $lastPathPosition - $firstPathPosition - 8)
EndIf
Local $sFileSaveDialog = "PUT YOUR LOCAL DIRECTORY HERE"
$sFileSaveDialog &= $sPath
$sFileSaveDialog &= $sFilename
;MsgBox(0, "The text was pasted ok", $sFileSaveDialog)
Local $iFileExists = FileExists($sFileSaveDialog)
If $iFileExists Then
FileDelete($sFileSaveDialog)
EndIf
FileWrite($sFileSaveDialog, $variable_fromclipboard)
if @error Then
MsgBox(0, "Error writing file", @error)
EndIf
endFunc
Func openTabs()
Local $sAnswer = InputBox("Question", "How many tabs are open?", "0", "")
For $i = 1 To Number($sAnswer) Step 1
copyELD()
Send("{CTRLDOWN}{TAB}{CTRLUP}{down}")
Send("{CTRLDOWN}a{CTRLUP}{CTRLDOWN}c{CTRLUP}{down}")
next
EndFunc
Func terminate()
Exit
endFunc
While 1
Sleep(10)
Wend
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment