Skip to content

Instantly share code, notes, and snippets.

@lundeen-bryan
Last active September 13, 2023 05:41
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 lundeen-bryan/7a5546ce6e80ed90785ebe27cf4db130 to your computer and use it in GitHub Desktop.
Save lundeen-bryan/7a5546ce6e80ed90785ebe27cf4db130 to your computer and use it in GitHub Desktop.
autoit snippets
#include "C:\Users\blundeen\Documents\Admin\AutoIT\Include\Date.au3"
#include "C:\Users\blundeen\Documents\Admin\AutoIT\Include\DateTimeConstants.au3"
Func _SubtractDaysSkipWeekends(byRef $dStartDate, byRef $iSubtractDays)
;Adds days to date returns the julian date after adding and only if within Mon-Fri
Local $Y, $M, $D
Local $dNewDate = _DayValueToDate($dStartDate, $Y, $M, $D)
Local $sJulDate = _DateToDayValue(@YEAR, @MON, @MDAY) ;todays date
While $iSubtractDays > 0
If _DateToDayOfWeek($Y,$M,$D) > 1 OR _DateToDayOfWeek($Y,$M,$D) < 7 Then
$iSubtractDays = $iSubtractDays - 1
Endif
$D = $D - 1
Wend
Return(_DateToDayValue($Y,$M,$D))
EndFunc
Func _AddDaysSkipWeekends(byRef $dStartDate, byRef $iSubtractDays)
;Adds days to date returns the julian date after adding and only if within Mon-Fri
Local $Y, $M, $D
Local $dNewDate = _DayValueToDate($dStartDate, $Y, $M, $D)
Local $sJulDate = _DateToDayValue(@YEAR, @MON, @MDAY) ;todays date
While $iSubtractDays > 0
If _DateToDayOfWeek($Y,$M,$D) > 1 OR _DateToDayOfWeek($Y,$M,$D) < 7 Then
$iSubtractDays = $iSubtractDays - 1
Endif
$D = $D + 1
Wend
Return(_DateToDayValue($Y,$M,$D))
EndFunc
;Baisically this function will rename a file
HotKeySet("+!d", "Newname") ; Shift-Alt-d
While 1
Sleep(100)
Wend
Func Newname()
;#### Example ####
$File = @ScriptDir & '\filetorename.txt'
FileWrite($File, 'Test')
_FileRename($File, 'newname.txt')
If @error Then MsgBox(0, "Error", @error)
EndFunc
Func _FileRename($sFile, $sRename, $iOverWrite = 0)
Local Const $FILENOTEXIST = 2
If Not FileExists($sFile) Then Return SetError($FILENOTEXIST, 0, 0)
Local $_StringLen = StringLen($sFile)
Local $_StringInStr = StringInStr($sFile, "\", 0, -1, $_StringLen)
Local $_Count = $_StringLen - $_StringInStr
Local $_Dir = StringLeft($sFile, $_StringInStr)
Local $_NewFile = $_Dir & $sRename
Local $_NewFileExists = FileExists($_NewFile)
Local $_FileMove = FileMove($sFile, $_NewFile, $iOverWrite)
Return SetError(Not $_FileMove, $_NewFileExists, $_FileMove)
EndFunc ;==>_FileRename
#Region --------------------------------------------------Notes about the script---
#cs
### Rename a file ###
$sFile = Full path to file
$sRename = New Filename
$iOverWrite = 0 or 1
Success returns 1
failure, returns 0 and sets @error
1 if FileMove fails,
2 if $sFile does not exist
@extended
0 if the new file does not already exist / existed
1 if the new file already exists / existed
#ce
#EndRegion-------------------------------------------------------------------------
; #INDEX# =======================================================================================================================
; Title .........: Screen Timeout Countermeasure
; AutoIt Version : 3.3.6.1
; Language ......: English
; Description ...: Designed to keep computer awake against a 15 minute lock screen setting
; Author(s) .....: Dufran3 kind of, Melba23 helped me revise my initial sloppyness!
; (1) _Timer_GetIdleTime checks how long the user has not moved the mouse or entered a key
; if the idle time is less than x then it will continue the function else it goes back
; to the while/wend
; Change 870000(14.5 min. value if need longer or shorter)
; (2) $fToggle is short for False Toggle bcuz it will toggle the bool to True = 1 integer
; and False = 0 integer so if you take (2 * 0) - 1 = -1 integer + the current position
; so it moves it to the left
; ===============================================================================================================================
#include "C:\Users\blundeen\AppData\Local\Apps\Bryans Autoit Files\Include\Timers.au3"
HotKeySet("{ESC}", "On_Exit")
AdlibRegister("_MoveMouse", 20000)
Global $fToggle = True
While 1
Sleep(10)
WEnd
; 870000 = 14.5 minutes but 300000 should be 5 minutes i believe this is measured in miliseconds 1 min = 60,000 ms
Func _MoveMouse()
If _Timer_GetIdleTime() > 10000 Then ;(1) move if idle x miliseconds
Send("{END}")
;$fToggle = Not $fToggle
;$aMPos = MouseGetPos()
;MouseMove($aMPos[0] + (2 * $fToggle - 1), $aMpos[1]) ;(2) move mouse
;ConsoleWrite("Mouse Moved" & @CRLF)
Local $hFile = "C:\Users\blundeen\Documents\LOGS\KeepAwake.txt"
FileWrite($hFile,"Mouse Moved" & @HOUR & ":" & @MIN & @CRLF) ; append to File
EndIf
EndFunc
Func On_Exit()
Exit
EndFunc
{
"vscode-icons-team.vscode-icons": {
"uuid": "9ccc1dd7-7ec4-4a46-bd4f-7d7b8b9d322a",
"label": "vscode-icons",
"description": "Icons for Visual Studio Code"
},
"aokabi.snippet-add-easy": {
"uuid": "fef1380a-29c9-4132-94ba-b365635abe22",
"label": "snippet-add-easy",
"description": "snippet is easy"
},
"vscodevim.vim": {
"uuid": "d96e79c6-8b25-4be3-8545-0e0ecefcae03",
"label": "Vim",
"description": "Vim emulation for Visual Studio Code"
},
"tyriar.vscode-terminal-here": {
"uuid": "55066e9b-6d65-4803-97e2-33316bef79e8",
"label": "Terminal Here",
"description": "Creates an intergrated terminal session at the current file's directory"
},
"randomfractalsinc.snippets-viewer": {
"uuid": "b3b9b999-60b3-4dfd-a086-fe4f7c9d136e",
"label": "Snippets Viewer",
"description": "VSCode Snippets Viewer"
},
"fiore57.snippet-generator": {
"uuid": "4c84260f-0771-439b-bce3-3da46e305b28",
"label": "Snippet Generator",
"description": "Simple snippet generator for VSCode"
},
"cyberbiont.vscode-sidenotes": {
"uuid": "19c15cb2-3383-48e3-be3c-b47ea62ee333",
"label": "Sidenotes",
"description": "Better than comments! Clean up your code, view your notes as tooltips or in a side editor"
},
"alefragnani.separators": {
"uuid": "9ffc33f1-cf2a-41a1-91f1-72f0df7b2754",
"label": "Separators",
"description": "Improve the readability of your source code with lines on top of each method"
},
"stkb.rewrap": {
"uuid": "b24a13f5-4e50-4d9a-ab0a-87f47d9fdfcb",
"label": "Rewrap",
"description": "Hard word wrapping for comments and other text at a given column."
},
"medo64.render-crlf": {
"uuid": "a5d8b25c-27b8-421d-a8b0-1681827909b9",
"label": "Render Line Endings",
"description": "Displays the line ending symbol and optionally extra whitespace when 'Render whitespace' is turned on."
},
"2gua.rainbow-brackets": {
"uuid": "797a79de-a0fd-4349-9034-bec47be9a941",
"label": "Rainbow Brackets",
"description": "A rainbow brackets extension for VS Code."
},
"richardpiel.project-shortcuts-vscode": {
"uuid": "eac5d5d6-fecf-446d-980b-20bf287a7ade",
"label": "Project Shortcuts",
"description": "Easily store shortcuts related to your project and access them directly from VSCode."
},
"alefragnani.project-manager": {
"uuid": "1b747f06-3789-4ebd-ac99-f1fe430c3347",
"label": "Project Manager",
"description": "Easily switch between projects"
},
"johnw42.pathslasher": {
"uuid": "667e1016-0252-4ab7-8aa9-9a1d6dba575a",
"label": "Path Slasher",
"description": "Convert easily between Windows and Unix file paths"
},
"ionutvmi.path-autocomplete": {
"uuid": "0d1241e3-fa60-4f24-8f2a-6d7085677c48",
"label": "Path Autocomplete",
"description": "Provides path completion for visual studio code and VS Code for Web."
},
"cweijan.vscode-office": {
"uuid": "936b1be7-8595-4f76-b102-aa6bb915da73",
"label": "Office Viewer(Markdown Editor)",
"description": "View word,excel files and using WYSIWYG editor for markdown."
},
"llam4u.nerdtree": {
"uuid": "2a247e46-f01a-468a-84bc-93c6184d2b76",
"label": "NERDTree",
"description": "⌨️ NERDTree for Visual Studio Code"
},
"codicelq.mytime": {
"uuid": "c7413844-502d-483a-9c1a-96db75e077af",
"label": "My Time",
"description": "Time Track on a Markdown document"
},
"mlewand.vscode-markdown-to-clipboard": {
"uuid": "c8d4f555-93af-4cd6-9102-ab91e1aae881",
"label": "Markdown to clipboard",
"description": "An extension that renders your markdown file to clipboard as rich text, so that you can paste it to any ord processor."
},
"shd101wyy.markdown-preview-enhanced": {
"uuid": "3b1db1fc-c7f7-4bd6-9fa4-b499dfa99a8a",
"label": "Markdown Preview Enhanced",
"description": "Markdown Preview Enhanced ported to vscode"
},
"tsutsu3.markdown-named-codeblocks": {
"uuid": "50b78491-428d-4367-89c7-e103b52fdc8d",
"label": "Markdown Named CodeBlocks",
"description": "Adds named code blocks support to the build-in markdown preview"
},
"lamartire.line-to-column": {
"uuid": "ce04ce54-f04e-458c-ae78-aec39edf4740",
"label": "Line > Column",
"description": "Split lines to column"
},
"rlnt.keep-a-changelog": {
"uuid": "6e1e0c1b-5df0-4770-8dbe-20cd7c0d5d50",
"label": "Keep a Changelog",
"description": "An extension that provides snippets for markdown files to create a changelog with the ruleset of Keep a Changelog."
},
"guodongsun.vscode-git-cruise": {
"uuid": "55cc8ddf-63e1-4b19-bc28-00e9352d04be",
"label": "Git History",
"description": "Git history panel in your VS Code"
},
"pomber.git-file-history": {
"uuid": "7632e3e0-7d47-4be3-a5e3-a5873293f815",
"label": "Git File History",
"description": "Modern, fast and intuitive tool for browsing the history and files in any git repository"
},
"vsls-contrib.gistfs": {
"uuid": "0cfb9d1d-3e59-4c36-a597-157b54e4442b",
"label": "GistPad",
"description": "Manage your code snippets and developer notes using GitHub Gists and repositories."
},
"evald24.vscode-extension-profiles": {
"uuid": "53b2c651-4404-420f-b62b-b9f8fc915c5a",
"label": "Extension profiles",
"description": "Lets you create profiles to include the selected extensions in the desired project."
},
"adam-bender.commit-message-editor": {
"uuid": "b9883563-e6ba-4f6c-b03c-193c80e79c75",
"label": "Commit Message Editor",
"description": "Edit commit messages in a convenient way."
},
"naumovs.color-highlight": {
"uuid": "121396ad-85a1-45ec-9fd1-d95028a847f5",
"label": "Color Highlight",
"description": "Highlight web colors in your editor"
},
"wesbos.theme-cobalt2": {
"uuid": "fb374ce1-5343-46c8-a425-900fdad15523",
"label": "Cobalt2 Theme Official",
"description": "🔥 Official theme by Wes Bos."
},
"sven-seyfert.autoit-snippets": {
"uuid": "8338307b-eeee-4e0f-8a02-061f420ccc93",
"label": "AutoIt Snippets",
"description": "AutoIt Snippets is a Visual Studio Code extension that provides helpful functions which are commonly used for all kind of programming or automation tasks within AutoIt. For example for the work with strings, dates, arrays, for getting information (system and more) or to record mouse actions or even for the work with GUIs."
},
"damien.autoit": {
"uuid": "a085e19b-5d1d-4528-96a8-4cd8b4f22fb2",
"label": "AutoIt",
"description": "AutoIt language extension for Visual Studio Code"
}
}
HotKeySet("+!d", "ConvDate") ; Shift-Alt-d
While 1
Sleep(100)
Wend
Func ConvDate()
sleep(200)
Send("^c")
Local $clip = clipget()
$clip = StringSplit($clip,"_")
Local $year = StringLeft($clip[2], 4)
Local $month = StringMid($clip[2], 5, 2)
Local $day = StringMid($clip[2], 7, 2)
Local $hour = StringMid($clip[3], 1, 2)
Local $min = StringMid($clip[3], 3, 2)
Send($year & "-" & $month & "-" & $day & " @" & $hour & ":" & $min)
EndFunc
Opt("WinTitleMatchMode", 4) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
#include "C:\Users\blundeen\AppData\Local\Apps\Bryans Autoit Files\Include\Clipboard.au3"
HotKeySet("+!d", "Main") ; Shift-Alt-d
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
While 1
Sleep(100)
WEnd
Func TogglePause()
Local $g_bPaused
$g_bPaused = Not $g_bPaused
While $g_bPaused
Sleep(100)
ToolTip('Script is "Paused"', 0, 0)
WEnd
ToolTip("")
EndFunc ;==>TogglePause
Func Terminate()
Exit
EndFunc ;==>Terminate
Func activate_window($win_class)
Do
If Not WinActive($win_class) Then
WinActivate($win_class)
; WinWaitActive($win_class)
EndIf
Until WinActive($win_class)
EndFunc
Func Main()
Sleep(1000)
$handle1 = WinGetHandle("[ACTIVE]")
; Next column 1 DocID
activate_window("[CLASS:XLMAIN]")
Send("^{LEFT}")
Send("{DOWN}")
Send("^c")
Sleep(500)
activate_window($handle1)
;Send("!{TAB}") ; switch to chrome browser
Sleep(500)
Send("^v") ; paste to browser
Sleep(500)
Send("{TAB}") ; tab to next field
Sleep(500)
activate_window("[CLASS:XLMAIN]")
;Send("!{TAB}") ; switch to XL again and loop
Sleep(500)
Send("{TAB}") ; next column in XL
; Next column 2 Provider
Send("^c")
Sleep(500)
activate_window($handle1)
Sleep(500)
Send("^v") ; paste to browser
Sleep(500)
Send("{TAB}") ; tab to next field
Sleep(500)
activate_window("[CLASS:XLMAIN]")
Sleep(500)
Send("{TAB 2}") ; next column in XL
; Next column 3 Visit Date
Send("^c")
Sleep(500)
activate_window($handle1)
Sleep(500)
Send("^v") ; paste to browser
Sleep(500)
Send("{TAB 2}") ; tab to next field
Sleep(500)
activate_window("[CLASS:XLMAIN]")
Sleep(500)
Send("{TAB}") ; next column in XL
; Next column 4 Filename
Send("^c")
Sleep(500)
activate_window($handle1)
Sleep(500)
Send("^v") ; paste to browser
Sleep(500)
Send("{TAB}") ; tab to next field
Sleep(500)
activate_window("[CLASS:XLMAIN]")
Sleep(500)
Send("{TAB 2}") ; next column in XL
; Next column 5 OdsName
Send("^c")
Sleep(500)
activate_window($handle1)
Sleep(500)
Send("^v") ; paste to browser
Sleep(500)
Send("{TAB}") ; tab to next field
Sleep(500)
activate_window("[CLASS:XLMAIN]")
Send("{TAB}") ; next column in XL
; Next column 6 PtNumber
Send("^c")
Sleep(500)
activate_window($handle1)
Sleep(500)
Send("^v") ; paste to browser
Sleep(500)
Send("{TAB}") ; tab to next field
Sleep(500)
activate_window("[CLASS:XLMAIN]")
Sleep(500)
Send("{TAB}") ; next column in XL
; Next column 7 Prog
Send("^c")
Sleep(500)
activate_window($handle1)
Sleep(500)
Send("^v") ; paste to browser
Sleep(500)
Send("{TAB}") ; tab to next field
Sleep(500)
activate_window("[CLASS:XLMAIN]")
Sleep(500)
Send("{TAB}") ; next column in XL
; Next column 8 Unit
Send("^c")
Sleep(500)
activate_window($handle1)
Sleep(500)
Send("^v") ; paste to browser
Sleep(500)
Send("{TAB}") ; tab to next field
Sleep(500)
activate_window("[CLASS:XLMAIN]")
Sleep(500)
Send("{TAB}") ; next column in XL
; Next column 9 Class
Send("^c")
Sleep(500)
activate_window($handle1)
Sleep(500)
Send("^v") ; paste to browser
Sleep(500)
Send("{TAB}") ; tab to next field
Sleep(500)
$today = @MON & "/" & @MDAY & "/" & @YEAR
Send($today) ; todays date
$tool_tip_done = ToolTip("Finished this entry", 100, 100, "Finished")
Sleep(3000)
ToolTip("")
EndFunc
;~ 🕮 <Bryan.Lundeen> 27691c5f-5089-4421-9d59-93579dd11a48.md
#include <Timers.au3>
Global $isMouseMoved = False
HotKeySet("{ESC}", "On_Exit")
While True
_MoveMouse() ; Call the _MoveMouse function to move the mouse
Sleep(60000 * 5) ; Wait for 5 minutes (60000 milliseconds * 5)
WEnd
Func _MoveMouse()
$mousePosition = MouseGetPos() ; Get the current mouse position
MouseMove($mousePosition[0] + 1, $mousePosition[1], 1) ; Move the mouse slightly to trigger activity
ConsoleWrite("Mouse Moved" & @CRLF) ; Write a message to the console indicating that the mouse was moved
$isMouseMoved = True
EndFunc
Func On_Exit()
Exit ; Exit the script
EndFunc
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.10.2
Author: myName
Script Function:
Template AutoIt script.
#ce ----------------------------------------------------------------------------
; Script added 2014-05-19 from a website
; http://www.ownedcore.com/forums/diablo-3/diablo-3-bots-programs/364825-1337pyros-auto-shutdown-adjustable-timer-status.html
;-----------Auto Shutdown-----------
;-Written by 1337pyro for Ownedcore-
#RequireAdmin
$sleeptime = InputBox("Auto Shutdown", "How many minutes until reboot?")
Do
if $sleeptime > 1 Then
ToolTip("Waiting " &$sleeptime& " minutes until Reboot!", 0, 0)
Sleep(60000)
$sleeptime = $sleeptime - 1
Else
ToolTip("Last minute before Reboot!", 0, 0)
Sleep(60000)
Shutdown(3)
EndIf
Until @error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment