Skip to content

Instantly share code, notes, and snippets.

xls2arr(xlsFile, ByRef retArr) {
ComObjError(0)
Loop, % xlsFile
xlsFile := A_LoopFileLongPath
If !xl := ComObjGet(xlsFile) {
xl := ComObjCreate("Excel.Application")
xl.Workbooks.Open(xlsFile)
needClose := True
#Persistent
Small := 32
Medium := 48
Large := 96
IconSize := Small
hDesktop := GetDesktop()
HalfW := A_ScreenWidth/2
; Modified from http://www.autohotkey.com/board/topic/54752-listview-select-alldeselect-all/?p=343662
; Examples: LVSel(1 , "SysListView321", "Win Title") ; Select row 1. (or use +1)
; LVSel(-1, "SysListView321", "Win Title") ; Deselect row 1
; LVSel(+0, "SysListView321", "Win Title") ; Select all
; LVSel(-0, "SysListView321", "Win Title") ; Deselect all
; LVSel(+0, , "ahk_id " HLV) ; Use listview's hwnd
lvSel(r:=1, Control:="", WinTitle:="") {
VarSetCapacity(LVITEM, 4*15, 0) ;Do *13 if you're not on Vista or Win 7 (see MSDN)
state := InStr(r, "-") ? 0x00000000 : 0x00000002
; Usage: Gui_NoActivate(GuiHwnd)
Gui_NoActivate(wParam:="", lParam:="", msg:="", hwnd:="") {
static WM_NCLBUTTONDOWN := 0xA1
, WM_NCMOUSEMOVE := 0xA0
, WS_EX_NOACTIVATE := 0x08000000
, pre_hForegroundWnd
If (msg = WM_NCLBUTTONDOWN) {
pre_hForegroundWnd := DllCall("GetForegroundWindow")
WinSet, ExStyle, -%WS_EX_NOACTIVATE%, ahk_id %hwnd%
;
; AHK版本: B:1.0.48.5 L:1.0.92.0
; 语言: 中文/English
; 平台: Win7
; 作者: 海盗 <[email protected]>
; 类型: 函数
; 描述: 识别图像类型
;
;
;~ File=C:\Users\Robin\Desktop\Temp\甲抗YST一条龙扫高安.tif
; Update: 2015-6-4 - Added BinArr_ToFile()
BinArr_FromString(str) {
oADO := ComObjCreate("ADODB.Stream")
oADO.Type := 2 ; adTypeText
oADO.Mode := 3 ; adModeReadWrite
oADO.Open
oADO.Charset := "UTF-8"
oADO.WriteText(str)
/*
CreateFormData - Creates "multipart/form-data" for http post
https://www.autohotkey.com/boards/viewtopic.php?t=7647
Usage: CreateFormData(ByRef retData, ByRef retHeader, objParam)
retData - (out) Data used for HTTP POST.
retHeader - (out) Content-Type header used for HTTP POST.
objParam - (in) An object defines the form parameters.
; by just me, http://ahkscript.org/boards/viewtopic.php?f=5&t=4673#p44099
Edit_VCENTER(HEDIT) { ; The Edit control must have the ES_MULTILINE style (0x0004 \ +Multi)!
; EM_GETRECT := 0x00B2 <- msdn.microsoft.com/en-us/library/bb761596(v=vs.85).aspx
; EM_SETRECT := 0x00B3 <- msdn.microsoft.com/en-us/library/bb761657(v=vs.85).aspx
VarSetCapacity(RC, 16, 0)
DllCall("User32.dll\GetClientRect", "Ptr", HEDIT, "Ptr", &RC)
CLHeight := NumGet(RC, 12, "Int")
SendMessage, 0x0031, 0, 0, , ahk_id %HEDIT% ; WM_GETFONT
HFONT := ErrorLevel
HDC := DllCall("GetDC", "Ptr", HEDIT, "UPtr")
; Usage: BlockSysMenu(ControlHwnd)
BlockSysMenu(wParam:="", lParam:="", msg:="", hwnd:="") {
static oHwnd := {}, WM_RBUTTONUP := 0x205, WM_CONTEXTMENU := 0x7B
, ____a := OnMessage(WM_RBUTTONUP, "BlockSysMenu")
, ____b := OnMessage(WM_CONTEXTMENU, "BlockSysMenu")
If !hwnd
Return oHwnd[wParam] := 1
If oHwnd[hwnd] || !oHwnd.MaxIndex() {
If IsLabel("GuiContextMenu") || IsFunc("GuiContextMenu")
SetTimer, GuiContextMenu, -0
/*
Makes the Gui window NoActivate but Clickable
Usage:
Gui_NoActivate(GuiHwnd, EnableEdit := False, Disable_RButton := False)
Parameters:
GuiHwnd - The Gui's hwnd
EnableEdit - True or False (default). Whether activates the GUI when an Edit Control is focused.
Disable_RButton - True or False (default)