Skip to content

Instantly share code, notes, and snippets.

/*
Functions:
CreateByArray(outputFile, arr)
CreateByHLV(outputFile, HLV, Obj_LV_Colors := "", IncludeLvHeader := false)
HLV - Listview hwnd
Obj_LV_Colors - Created by using 'New LV_Colors(HLV)'
ChangeLog:
v1.05 (2017-8-17) - Added "Column AutoFit"; Added .xls file support
v1.04 (2016-12-9) - 'IncludeLvHeader' option now doesn't need to change default listview
v1.03 (2016-12-9) - Added support for LV_Colors's AlternateRows/AlternateCols
ExcelToArray(FileName, nSheet := 1)
{
return ExcelToArray.DoIt(FileName, nSheet)
}
class ExcelToArray
{
DoIt(FileName, nSheet := 1)
{
if !FileExist(FileName)
#NoEnv
cad := ComObjActive("AutoCAD.Application")
; AddText
point := Point3d("789.72", "1500.45", "0.0")
textObj := cad.ActiveDocument.ModelSpace.AddText("AutoHotkey", point, 80.77)
textObj.Update
; AddLine
; ----------------------------------------------------------------------------------------------------------------------
; Name ..........: TrayIcon library
; Description ...: Provide some useful functions to deal with Tray icons.
; AHK Version ...: AHK_L 1.1.13.01 x32/64 Unicode
; Original Author: Sean (http://goo.gl/dh0xIX) (http://www.autohotkey.com/forum/viewtopic.php?t=17314)
; Update Author .: Cyruz (http://ciroprincipe.info) (http://ahkscript.org/boards/viewtopic.php?f=6&t=1229)
; Mod Author ....: Fanatic Guru
; License .......: WTFPL - http://www.wtfpl.net/txt/copying/
; Version Date...: 2014 - 01 - 16
; Note ..........: Many people have updated Sean's original work including me but Cyruz's version seemed the most straight
/*
Modified version by tmplinshi
Changes:
* Default set with "Accept-Encoding: gzip, deflate" header and INTERNET_OPTION_HTTP_DECODING,
which will request a compressed response and decode automatically. (Requires Vista+ or XP SP3?)
* Fixed encoding problems of the non-ANSI characters in response headers.
*/
/*
; 判断 word 文件是否已经打开
IsDocOpened(FileName) {
; 确保 FileName 是完整路径
if !InStr(FileName, ":")
FileName := A_ScriptDir "\" FileName
try {
oWord := ComObjActive("Word.Application")
oWord.Documents(FileName)
return true
DisableFadeEffect() {
; SPI_GETCLIENTAREAANIMATION = 0x1042
DllCall("SystemParametersInfo", "UInt", 0x1042, "UInt", 0, "UInt*", isEnabled, "UInt", 0)
if isEnabled {
; SPI_SETCLIENTAREAANIMATION = 0x1043
DllCall("SystemParametersInfo", "UInt", 0x1043, "UInt", 0, "UInt", 0, "UInt", 0)
Progress, 10:P100 Hide
Progress, 10:Off
DllCall("SystemParametersInfo", "UInt", 0x1043, "UInt", 0, "UInt", 1, "UInt", 0)
CreateGist(content, description:="", filename:="file1.ahk", token:="", public:=true) {
url := "https://api.github.com/gists"
obj := { "description": description
, "public": (public ? "true" : "false")
, "files": { (filename): {"content": content} } }
whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
whr.Open("POST", url)
whr.SetRequestHeader("Content-Type", "application/json; charset=utf-8")
if token {
; ===============================================================================================================================
; Check if a process is elevated
; ===============================================================================================================================
IsProcessElevated(ProcessID)
{
if !(hProcess := DllCall("OpenProcess", "uint", 0x0400, "int", 0, "uint", ProcessID, "ptr"))
throw Exception("OpenProcess failed", -1)
if !(DllCall("advapi32\OpenProcessToken", "ptr", hProcess, "uint", 0x0008, "ptr*", hToken))
throw Exception("OpenProcessToken failed", -1), DllCall("CloseHandle", "ptr", hProcess)
; Requires Internet Explorer 8.0 or later.
InternetGetCookieEx(URL) {
Loop, 2 {
if (A_Index = 2) {
VarSetCapacity(cookieData, size, 0)
}
DllCall( "Wininet.dll\InternetGetCookieEx"
, "ptr", &URL, "ptr", 0, "ptr", &cookieData, "int*", size
, "uint", 8192 ; INTERNET_COOKIE_HTTPONLY
, "ptr", 0 )