[AHK]Get text from Excel 2007's status bar

65 篇文章 2 订阅

;MS EXCEL
Get text from status bar - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=9996


I wrote a function that gets the text from Excel 2007's status bar.

Please confirm if it works on other versions of Excel. Or use AccViewer to work out and share modified versions of the function that work on other versions of Excel.

Code: [Select all] [Expand] [Download]GeSHi © Codebox Plus

;e.g.
;WinGet, hWnd, ID, ahk_class XLMAIN
;MsgBox, % JEE_ExcelStatusBarGetText(hWnd)
;return

;e.g. status bar text: Ready/Edit/Enter
;tested on Excel 2007
;requires Acc library
JEE_ExcelStatusBarGetText(hWnd)
{
	ControlGet, hCtl, Hwnd,, NetUIHWND1, % "ahk_id " hWnd
	oAcc := Acc_Get("Object", "4.1", 0, "ahk_id " hCtl)
	vText := oAcc.accValue(0)
	oAcc := ""
	return vText
}


Acc library (MSAA) and AccViewer download links - AutoHotkey Community

https://autohotkey.com/boards/viewtopic.php?f=6&t=26201


simple functions relating to highlighting, tested on Excel 2007. I generally do everything via macros, but the 3 functions on this page are the few exceptions.

;==================================================

;e.g.
;WinGet, hWnd, ID, ahk_class XLMAIN
;JEE_ExcelFillColor(hWnd)
;return

;tested on Excel 2007
;requires Acc library
;click the Fill Color button
JEE_ExcelFillColor(hWnd)
{
	ControlGet, hCtl, Hwnd,, NetUIHWND2, % "ahk_id " hWnd
	oAcc := Acc_Get("Object", "4.14.1.1.2.11.1", 0, "ahk_id " hCtl)
	oAcc.accDoDefaultAction(0)
	oAcc := ""
}

;==================================================

;e.g.
;WinGet, hWnd, ID, ahk_class XLMAIN
;JEE_ExcelFillColorSet(hWnd, "FF0000,FFFF00,")
;return

;tested on Excel 2007
;choose the highlight colour from the Colors dialog or click Fill None
;JEE_ExcelRecentColorsAdd
JEE_ExcelFillColorSet(hWnd, vList)
{
	StrReplace(vList, ",", "", vCount), vCount += 1
	Loop, Parse, vList, % ","
	{
		if (A_LoopField = "")
		{
			SendInput !hhn ;No Fill
			continue
		}
		SendInput !hhm ;Colors dialog
		Loop, 3
			vCol%A_Index% := "0x" SubStr(A_LoopField, (A_Index*2)-1, 2)
		WinWaitActive, Colors ahk_class bosa_sdm_XL9
		WinGet, hWnd, ID, Colors ahk_class bosa_sdm_XL9
		Sleep 1000
		SendInput ^{Tab}
		ControlSetText, RichEdit20W10, % vCol1+0, % "ahk_id " hWnd
		ControlSetText, RichEdit20W11, % vCol2+0, % "ahk_id " hWnd
		ControlSetText, RichEdit20W12, % vCol3+0, % "ahk_id " hWnd
		SendInput {Enter}
		WinWaitNotActive, % "ahk_id " hWnd
		if (A_Index = vCount)
			Sleep 1000
	}
}

;==================================================

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值