Last active
February 1, 2024 20:35
-
-
Save graywolfcorp/08cafafda5d51ccdac25a8b45afd3d77 to your computer and use it in GitHub Desktop.
AutoIt macro to save easylanguage code locally
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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