Skip to content

Instantly share code, notes, and snippets.

@MattDiesel
MattDiesel / tetris.au3
Created February 15, 2013 04:48
Tetris implemented in 100 lines of 100 characters of AutoIt code by Matt Diesel (Mat on the english AutoIt forums) for the C² competition.
Dim $3="script.au3",$f=FileInstall("tetris.au3",$3)&FileRead($3),$l=StringRegExp($f,":(\d)",3),$s[ _
22][10],$n[4][4],$m=StringRegExp($f,"~(-?\d)",3),$o=StringRegExp($f,"@(\d+)",3),$p=StringRegExp($f _
,";(\d)",3),$c=StringRegExp($f,"`(\d+)",3),$t='"Score: "&$u&@LF&"Lines: "&$v&@LF&"Level: "&$w',$r[ _
5]=[0,1,3,5,8],$kc=0,$ka=0,$i=@TAB&"Highscores:",$d="Mat's Tetris²",$j=GUICreate($d,420,464),$k,$1 _
="GUICtrlCreateDummy()",$kk=StringRegExp($f,"%(\w)",3),$a[5][3]=[["w",Execute($1)],["a",Execute($1 _
)],["s",Execute($1)],["d",Execute($1)],["b",Execute($1)]],$2=GUISetAccelerators($a);`11141120~-2~1..
If $CmdLine[0] Or Run('"'&@AutoItExe&'" '&$CmdLineRaw&" m")*0 Then Exit AutoItWinSettitle(@TAB)+m(0)
Func m($3);4;1;2;3;2;1;0;0;2;4;3;2;1;2;3;4;2;0;0;0;1;2;3;5;7;6;5;4;2;4;3;2;1;1;2;3;4;2:2:1:1:2:1:1:2
Return $3<40 And m($3+Beep($o[$p[$3]],210*$l[$3])) Or Run('"'&@AutoItExe&'" '&$CmdLineRaw);0@220:1;0
EndFunc;:1:2:1:1:3:1:2:2:2:2:1:1:1:1:3:1:2:1:1:3:1:2:1:1:2:1:1:2:2:2:2:2@247@262@294@330@349@392@419
@MattDiesel
MattDiesel / AuLex.au3
Last active December 18, 2015 07:09
First implementation of a simple AutoIt lexer.
#include <Math.au3>
#include <Array.au3>
#include "al_keywords.au3"
#include "al_funcs.au3"
#include "al_macros.au3"
Global Enum $AL_TOK_EOF = 0, _ ; End of File
$AL_TOK_EOL, _ ; End of Line
#include <Array.au3>
#include <Math.au3>
Global $__CmdLine_StrictMode = False
Global $__CmdLine_PrefixLong = "--"
Global $__CmdLine_PrefixShort = "-"
Global $__CmdLine_StringChars = "'"""
Global $__CmdLine_SplitChars = " =:" & @TAB
@MattDiesel
MattDiesel / AuOpt.au3
Created June 11, 2013 21:02
Example of using AuLex to write a preprocessor. Currently supports #define #undef #ifdef #ifndef #else #endif.
#include <Array.au3>
#include "AuLex.au3"
Local $s = "TestOpt.au3"
MsgBox(0, $s, _PreProcess($s))
Func _PreProcess($sFile)
Local $aDefined[1][2] = [[0, 0]] ; NAME, VALUE
@MattDiesel
MattDiesel / AuParse.au3
Created June 12, 2013 22:08
AutoIt parser written in AutoIt.
#cs
Syntax Tree Usage:
The syntax tree is a flat array of "branches". The branches can point to each other by referencing
the child branches index. In a simplistic way, the following tree:
1
/ \
@MattDiesel
MattDiesel / AuLex_GenDb
Created June 13, 2013 07:53
Generates include files used in AuLex.au3
Local $__AL_AU3API = FileRead("C:\Program Files\AutoIt3\SciTE\api\au3.api")
Global $__AL_KEYWORDS = StringRegExp($__AL_AU3API, "(\w+)\?4", 3)
Global $__AL_FUNCS = StringRegExp($__AL_AU3API, "(?:\n|\A)([^\_]\w+)\s\(", 3)
Global $__AL_MACROS = StringRegExp($__AL_AU3API, "(?:\n|\A)(@\w+)\?3", 3)
Local $aTypes[3] = ["KEYWORDS", "FUNCS", "MACROS"]
Local $aArrays[3] = [$__AL_KEYWORDS, $__AL_FUNCS, $__AL_MACROS]
Local $hFile, $a
@MattDiesel
MattDiesel / _ToBase.au3
Created June 19, 2013 10:44
Convert to/from numeric bases/
Func _ToBase($iNumber, $iBase, $iPad = 1, $sCharSet = Default)
Local Static $sDefCharSet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/"
Local $sRet = "", $iDigit
If $sCharSet = Default Then $sCharSet = $sDefCharSet
Do
$iDigit = Mod($iNumber, $iBase)
$sRet = StringMid($sCharSet, $iDigit + 1, 1) & $sRet
$iNumber = Int($iNumber / $iBase)
Local $handleDLL = DLLOpen("C:\DelcomDLL.dll")
Local $devices = DllCall($handleDLL,"dword","DelcomGetDeviceCount","dword",0)
Local $stStrings[$devices[0]]
Local $tDeviceArray = DllStructCreate("wchar* Items[" & $devices[0] & "]")
For $i = 1 To $devices[0]
$stStrings[$i - 1] = DllStructCreate("wchar Name[512]")
DllStructSetData($tDeviceArray, "Items", $stStrings[$i - 1], $i)
Global $packetID = "UCAS"
Local $inbuff = "", $n
While 1
;ManageTray()
;Sleep(50) ; (to allow script to make way for other software. Not sure if it does though?)
$inbuff = $inbuff & _Commgetstring()
#include <iostream>
#include "inst_none.h"
const int matrixSize = 1000;
int a[matrixSize][matrixSize];
int b[matrixSize][matrixSize];
int c[matrixSize][matrixSize];
int main() {