[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
	}
}

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

AutoHotkey (AHK) 是一种自动化脚本语言,它允许用户编写快捷键、鼠标操作和自动化任务。如果你想要通过AHKExcel的第一列提取数据,特别是获取昵称并发送到微信,你需要完成以下几个步骤: 1. **读取Excel数据**:使用`A_HotKey Lib`库中的`ReadDataFromExcel`函数打开Excel文件,选择包含微信昵称的第一列数据。 ```ahk Run, ahk_excel, C:\path\to\your\file.xlsx, , firstCol ;假设第一列的索引是从0开始的 ``` 2. **处理数据**:遍历获取的数据,从中提取出每一行的昵称。这通常涉及到数组的操作。 ```ahk ; 假设变量MyArray存储了所有昵称 For i, row, cols In MyArray Nickname := MyArray[row, 1] ; 获取昵称 ; 对NickName进行进一步处理,例如清理空格或特殊字符 Next ``` 3. **发送微信消息**:利用微信的API或者第三方工具,将昵称转换成实际的微信消息发送。由于涉及到隐私和API权限,这部分通常是受限的,需要合法授权。 ```ahk ; 这部分代码取决于是否有可用的微信消息发送插件或库 If IsExist, WechatSendMessagePlugin ; 假设有WechatSendMessagePlugin WechatSendMessagePlugin, %Nickname% ; 发送消息 Else MsgBox, 没有找到微信消息发送功能。 ``` 请注意,实际操作中,可能需要你注册微信开发者账号,并获取相应的access_token等权限才能实现此功能。此外,微信官方对第三方应用发送消息有着严格的限制。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值