这是代码,ahk v2
需要这个UIA库 AutoHotkey 使用 UI Automation(UIA) 获取相关信息教程 - 火冷 - 博客园 (cnblogs.com)
有需要的人可以自己改一改,加一加。
#include Class_UIA.ah2
#Warn All, Off
#SingleInstance force
global ID
global ifok
ifok := 0
return
^+g::{
global ID
global ifok
if ifok = 0 {
MouseGetPos , , , &ID, 2
msgbox("已开启和谐模式")
ifok := 1
}else{
msgbox("已开启骂人模式")
ifok := 0
}
return
}
#HotIf (ifok = 1)
$1:: {
global ID
local n
try
{
elWin := UIA.ElementFromHandle(ID)
cond := UIA.CreatePropertyCondition("name", "1")
Element := elWin.FindFirst(cond, 4)
Element := Element.GetNext()
itemName := Element.GetCurrentPropertyValue(30005)
}
catch
{
itemName :=""
}
pingbici := FileRead("屏蔽词.txt", "UTF-8")
Loop parse, pingbici, "`n", "`r"
{
If (InStr(itemName, A_LoopField))
{
send "{esc}"
msgbox("消消气,不要骂人!和谐社会!")
return 2
}
}
Send "{Raw}1"
return
}
$space:: {
global ID
local n
try
{
elWin := UIA.ElementFromHandle(ID)
cond := UIA.CreatePropertyCondition("name", "1")
Element := elWin.FindFirst(cond, 4)
Element := Element.GetNext()
itemName := Element.GetCurrentPropertyValue(30005)
}
catch
{
itemName :=""
}
pingbici := FileRead("屏蔽词.txt", "UTF-8")
Loop parse, pingbici, "`n", "`r"
{
If (InStr(itemName, A_LoopField))
{
send "{esc}"
msgbox("消消气,不要骂人!和谐社会!")
return 2
}
}
Send "{space}"
return
}
$2:: {
global ID
local n
try
{
elWin := UIA.ElementFromHandle(ID)
cond := UIA.CreatePropertyCondition("name", "2")
Element := elWin.FindFirst(cond, 4)
Element := Element.GetNext()
itemName := Element.GetCurrentPropertyValue(30005)
}
catch
{
itemName :=""
}
pingbici := FileRead("屏蔽词.txt", "UTF-8")
Loop parse, pingbici, "`n", "`r"
{
If (InStr(itemName, A_LoopField))
{
send "{esc}"
msgbox("消消气,不要骂人!和谐社会!")
return 2
}
}
Send "{Raw}2"
return
}
$3:: {
global ID
local n
try
{
elWin := UIA.ElementFromHandle(ID)
cond := UIA.CreatePropertyCondition("name", "3")
Element := elWin.FindFirst(cond, 4)
Element := Element.GetNext()
itemName := Element.GetCurrentPropertyValue(30005)
}
catch
{
itemName :=""
}
pingbici := FileRead("屏蔽词.txt", "UTF-8")
Loop parse, pingbici, "`n", "`r"
{
If (InStr(itemName, A_LoopField))
{
send "{esc}"
msgbox("消消气,不要骂人!和谐社会!")
return 2
}
}
Send "{Raw}3"
return
}
$4:: {
global ID
local n
try
{
elWin := UIA.ElementFromHandle(ID)
cond := UIA.CreatePropertyCondition("name", "4")
Element := elWin.FindFirst(cond, 4)
Element := Element.GetNext()
itemName := Element.GetCurrentPropertyValue(30005)
}
catch
{
itemName :=""
}
pingbici := FileRead("屏蔽词.txt", "UTF-8")
Loop parse, pingbici, "`n", "`r"
{
If (InStr(itemName, A_LoopField))
{
send "{esc}"
msgbox("消消气,不要骂人!和谐社会!")
return 2
}
}
Send "{Raw}4"
return
}
$5:: {
global ID
local n
try
{
elWin := UIA.ElementFromHandle(ID)
cond := UIA.CreatePropertyCondition("name", "5")
Element := elWin.FindFirst(cond, 4)
Element := Element.GetNext()
itemName := Element.GetCurrentPropertyValue(30005)
}
catch
{
itemName :=""
}
pingbici := FileRead("屏蔽词.txt", "UTF-8")
Loop parse, pingbici, "`n", "`r"
{
If (InStr(itemName, A_LoopField))
{
send "{esc}"
msgbox("消消气,不要骂人!和谐社会!")
return 2
}
}
Send "{Raw}5"
return
}
$6:: {
global ID
local n
try
{
elWin := UIA.ElementFromHandle(ID)
cond := UIA.CreatePropertyCondition("name", "6")
Element := elWin.FindFirst(cond, 4)
Element := Element.GetNext()
itemName := Element.GetCurrentPropertyValue(30005)
}
catch
{
itemName :=""
}
pingbici := FileRead("屏蔽词.txt", "UTF-8")
Loop parse, pingbici, "`n", "`r"
{
If (InStr(itemName, A_LoopField))
{
send "{esc}"
msgbox("消消气,不要骂人!和谐社会!")
return 2
}
}
Send "{Raw}6"
return
}
$7:: {
global ID
local n
try
{
elWin := UIA.ElementFromHandle(ID)
cond := UIA.CreatePropertyCondition("name", "7")
Element := elWin.FindFirst(cond, 4)
Element := Element.GetNext()
itemName := Element.GetCurrentPropertyValue(30005)
}
catch
{
itemName :=""
}
pingbici := FileRead("屏蔽词.txt", "UTF-8")
Loop parse, pingbici, "`n", "`r"
{
If (InStr(itemName, A_LoopField))
{
send "{esc}"
msgbox("消消气,不要骂人!和谐社会!")
return 2
}
}
Send "{Raw}7"
return
}
$8:: {
global ID
local n
try
{
elWin := UIA.ElementFromHandle(ID)
cond := UIA.CreatePropertyCondition("name", "8")
Element := elWin.FindFirst(cond, 4)
Element := Element.GetNext()
itemName := Element.GetCurrentPropertyValue(30005)
}
catch
{
itemName :=""
}
pingbici := FileRead("屏蔽词.txt", "UTF-8")
Loop parse, pingbici, "`n", "`r"
{
If (InStr(itemName, A_LoopField))
{
send "{esc}"
msgbox("消消气,不要骂人!和谐社会!")
return 2
}
}
Send "{Raw}8"
return
}
$9:: {
global ID
local n
try
{
elWin := UIA.ElementFromHandle(ID)
cond := UIA.CreatePropertyCondition("name", "9")
Element := elWin.FindFirst(cond, 4)
Element := Element.GetNext()
itemName := Element.GetCurrentPropertyValue(30005)
}
catch
{
itemName :=""
}
pingbici := FileRead("屏蔽词.txt", "UTF-8")
Loop parse, pingbici, "`n", "`r"
{
If (InStr(itemName, A_LoopField))
{
send "{esc}"
msgbox("消消气,不要骂人!和谐社会!")
return 2
}
}
Send "{Raw}9"
return
}