Skip to content

Instantly share code, notes, and snippets.

@TLMcode
TLMcode / Random String Generator
Last active January 23, 2017 23:08
Random String Generator
gen( len )
{
loop % (122, d="~")
cStr .= chr( (i:=a_index)>32&&i<60 ? i : i>59&&i<91 ? i : i>93&&i<125 ? i : "" ) d
cStr:=regexreplace(cStr, d d)
while ( strlen(nStr)<len )
{
sort, cStr, % "Random D" d
nStr .= ((v:=substr(regexreplace(cStr,d),1,20))~="\d"
@TLMcode
TLMcode / ExecScript.ahk
Last active December 18, 2018 18:54
Execute an script
ExecScript( Script, Params="", AhkPath="" )
{
AhkPath := !AhkPath ? A_AhkPath : AhkPath
Loop % ( 2, Pipe := [], Name := "AHK_" A_TickCount )
Pipe[A_Index] := DllCall( "CreateNamedPipe", "Str", "\\.\pipe\" name, "UInt", 2, "UInt", 0
, "UInt", 255, "UInt", 0, "UInt", 0, "UPtr", 0, "UPtr", 0, "UPtr" )
if !FileExist( AhkPath )
throw Exception( "AutoHotkey runtime not found: " AhkPath )
@TLMcode
TLMcode / main.cs
Created October 1, 2015 04:33
Reading & Writing .wav file (C# + .net)
// Waveファイル 読み込みと書き込み
// 16bit形式のみ対応
// 読み込んだデータはList<short>に格納されます
using System;
using System.Collections.Generic;
using System.IO;
namespace ConsoleApplication1
{
class Program
@TLMcode
TLMcode / EnumClipFormats.ahk
Created September 30, 2015 20:18
EnumClipFormats(). Retrieves a list of formats in the clipboard
msgbox % EnumClipFormats()
EnumClipFormats()
{
DllCall("OpenClipboard"), VarSetCapacity( buf, 256 )
Loop % DllCall("CountClipboardFormats")
{
fmt := DllCall("EnumClipboardFormats", uint, a_index=1?0:fmt )
DllCall("GetClipboardFormatName", uInt, fmt, str, buf, int, 128 )
@TLMcode
TLMcode / ComExcelConnect.ahk
Created August 4, 2015 18:34
ComExcelConnect() creates a COM connection to a open workbook
xlObj := ComExcelConnect( "ahk_class XLMAIN" ).Application
msgbox % xlObj.Range("A1").value
ExitApp
ComExcelConnect( WinTitle )
{
objID := "-16", objID &= 0xFFFFFFFF
refID := -VarSetCapacity( iid, 16 )
iid_type := NumPut( 0x46000000000000C0
@TLMcode
TLMcode / anon_test.js
Last active August 29, 2015 14:26
anon view test
(function()
{
var view =
{
init: function()
{
this.cacheDom();
this.render();
},
cacheDom: function()
#SingleInstance, Off
#NoEnv
SetBatchLines, -1
FilePath = C:\Windows\ShellNew\Template.ahk
DefaultName = %A_UserName%
DefaultDesc =
Indent := "`t"
Title = CodeQuickTester
@TLMcode
TLMcode / GetCharacterDescription.ahk
Last active August 29, 2015 14:21
Get Character Description
cSharp =
(
using System;
using System.Text;
using System.Runtime.InteropServices;
public class Win32ResourceReader : IDisposable
{
private IntPtr _hModule;
@TLMcode
TLMcode / UriDecode() 64bit
Created December 20, 2014 02:28
UriDecode() for AHk64 bit using htmlfile object
uri := "file:///D:/03%20Schreiben/01_Texte/15%20%E2%80%93%20Encyclop%C3%A4dien/Encyclopedia%20of%20Sociology.pdf"
msgbox % decodeURI( uri )
decodeURI( u )
{
( obj:=ComObjCreate("HTMLfile") ).write("<p>/</p><script>document.getElementsByTagName(""p"")[0].innerHTML=decodeURI(`""" u `""");</script>")
return obj.getElementsByTagName("p")[0].innerHTML
}
@TLMcode
TLMcode / UriDecode()
Created December 10, 2014 08:21
UriDecode() for AHk using jScript
uri := "file:///D:/03%20Schreiben/01_Texte/15%20%E2%80%93%20Encyclop%C3%A4dien/Encyclopedia%20of%20Sociology.pdf"
msgbox % UriDecode( uri )
UriDecode( u )
{
( obj := ComObjCreate( "ScriptControl" ) ).Language := "JScript"
return obj.Eval( "decodeURI(`""" u `""");" )
}