Skip to content

Instantly share code, notes, and snippets.

View TheDcoder's full-sized avatar

TheDcoder TheDcoder

View GitHub Profile
@TheDcoder
TheDcoder / Country Code Directory.au3
Created August 27, 2016 16:47
Country Codes in AutoIt
; NOTE: Use the latest BETA version of AutoIt
#include <MsgBoxConstants.au3>
#include "Country Codes.au3"
Global $sInput ; This will store the input
While True ; Infinite Loop!
$sInput = InputBox("Country Code Directory", "Enter the country code and I will tell you the country :)")
If @error Then Exit ; If the user closes the InputBox...
If MapExists($mCountryCodes, $sInput) Then ; Check if the country code exists in the database
MsgBox($MB_ICONINFORMATION, "Country of the code", $sInput & " is used to call " & $mCountryCodes[$sInput])
@TheDcoder
TheDcoder / IsMgcNumPresent.au3
Last active October 22, 2016 16:51
Is Magic Number Present?
; #FUNCTION# ====================================================================================================================
; Name ..........: IsMgcNumPresent
; Description ...: Checks if a number is a present in a number (Magic numbers aka Powers of 2)
; Syntax ........: IsMgcNumPresent($iNumber, $iMagicNumber)
; Parameters ....: $iNumber - Number to check if it exists in $iMagicNumber.
; $iMagicNumber - The number which might contain $iNumber.
; Return values .: Success: True
; Failure: False
; Author ........: Damon Harris (TheDcoder)
; Modified ......:
@TheDcoder
TheDcoder / keybase.md
Created January 1, 2017 07:11
Keybase Identity Proof

Keybase proof

I hereby claim:

  • I am TheDcoder on github.
  • I am thedcoder (https://keybase.io/thedcoder) on keybase.
  • I have a public key whose fingerprint is 2D32 0619 4C71 DFA8 AD1C 0C5E 1E1B 2C6F 24E8 B800

To claim this, I am signing this object:

@TheDcoder
TheDcoder / IniReadWrite.au3
Last active January 15, 2017 05:15
IniReadWrite
; #FUNCTION# ====================================================================================================================
; Name ..........: IniReadWrite
; Description ...: Write the default value to Ini if it does not exist
; Syntax ........: IniReadWrite($sFile, $sSection, $sKey, $sDefault)
; Parameters ....: $sFile - The path for the .ini file.
; $sSection - The section name in the .ini file.
; $sKey - The key name in the .ini file.
; $sDefault - The default value.
; Return values .: The value of the $sKey in the Ini file or $sDefault if the $sKey does not exists
; Author ........: Damon Harris (TheDcoder)
@TheDcoder
TheDcoder / _IEWaitForTagText.au3
Last active October 9, 2017 04:49
AutoIt Snippet - _IEWaitForTagText
; #FUNCTION# ====================================================================================================================
; Name ..........: _IEWaitForTagText
; Description ...: Waits for a HTML tag to appear with the specified text
; Syntax ........: _IEWaitForTagText($oObject, $sTagName, $sTagText[, $iTimeout = 0[, $bNoError = True]])
; Parameters ....: $oObject - Object related to IE (Any Window, Frame, IFrame or any DOM object).
; $sTagName - Name of the HTML tag (p, img, tr, etc).
; $sTagText - The (inner) text of the tag to wait for.
; $iTimeout - [optional] Timeout for the wait in milliseconds. Default is 0 (No timeout).
; $bNoError - [optional] Temporarily disable IE errors messages in the console. Default is True.
; Return values .: Success: The DOM element's object
@TheDcoder
TheDcoder / Simple SQLite Example.au3
Created August 6, 2017 12:21
Simple SQLite Example in AutoIt
#include <Array.au3>
#include <SQLite.au3>
_SQLite_Startup() ; Load the DLL
If @error Then Exit MsgBox(0, "Error", "Unable to start SQLite, Please verify your DLL")
Local $sDatabase = @ScriptDir & '\SQLiteTestDatabase.db'
Local $hDatabase = _SQLite_Open($sDatabase) ; Create the database file and get the handle for the database
_SQLite_Exec($hDatabase, 'CREATE TABLE People (first_name, last_name);') ; CREATE a TABLE with the name "People"
@TheDcoder
TheDcoder / ConvertTime12To24.au3
Last active October 3, 2017 11:47
12 hour to 24 hour format in AutoIt
; #FUNCTION# ====================================================================================================================
; Name ..........: ConvertTime12To24
; Description ...: Converts 12 hour time to 24 hour time, made while keeping _DateDiff's format in mind :)
; Syntax ........: ConvertTime12To24($sTime, $sPeriod[, $sDelimiter = ':'])
; Parameters ....: $sTime - Timestamp. (Can be a single digit or a pattern like H:M:S)
; $sPeriod - AM or PM.
; $sDelimiter - [optional] Separator between units of time. Default is ':'.
; Return values .: $sTime in 24 hour format with 0 padding
; Author ........: Damon Harris (TheDcoder)
; Remarks .......: Ensures that the first 3 parts have 0 padding if the time unit is single digit (Example 09 instead of 9)
@TheDcoder
TheDcoder / LocalDateTime.bat
Created October 19, 2017 12:47
Locale-indepent way to get time and date in batch
@echo off
rem I do not claim authorship of this snippet, original source: https://serverfault.com/a/227375/414453
rem Get the time from WMI - at least that's a format we can work with
set X=
for /f "skip=1 delims=" %%x in ('wmic os get localdatetime') do if not defined X set X=%%x
echo.%X%
rem dissect into parts
set DATE.YEAR=%X:~0,4%
@TheDcoder
TheDcoder / IsWindowNotResponding.au3
Last active December 6, 2017 14:02
IsWindowNotResponding
#include <WinAPISys.au3>
; #FUNCTION# ====================================================================================================================
; Name ..........: IsWindowNotResponding
; Description ...: Checks if a Window is not responding
; Syntax ........: IsWindowNotResponding($hWindow[, $iTimeout = 5000])
; Parameters ....: $hWindow - A window handle.
; $iTimeout - [optional] Shouldn't matter, Timeout in milliseconds. Default is 5000.
; Return values .: @error set by _WinAPI_SendMessageTimeout
; Author ........: Damon Harris (TheDcoder)
@TheDcoder
TheDcoder / Example.au3
Last active December 11, 2017 05:29
Generate custom/fake/pseudo events in OnEvent mode in AutoIt
; This snippet will show you a "hack" that you can use in GUI OnEvent mode in AutoIt
; With this hack you can create fake/pseudo events for a control in a OnEvent "handler"
; function which is registered with multiple controls.
; Usually you can get around this by using a unique function for every control
; but I like to use a single function that I use as a handler for a group of related
; controls. Looks neat and organized :)
; Let's get started!