可以在商业软件中检测事件并显示消息吗?

本文关键字:显示 消息 事件 检测 商业软件 | 更新日期: 2023-09-27 18:18:58

我是编程新手,想创建一个程序,检测商店购买的软件中的事件,并显示一个消息框,要求用户单击"确定"才能继续。商业程序在Windows XP中运行,我需要它来检测当有人点击一个特定的菜单选项。什么编程语言将是最好的,这是可能的,如果我没有访问到商业程序的源代码?如果程序检测到屏幕上出现的特定单词,它也可能起作用,因为在单击商业程序中的菜单选项后,会出现某些独特的文本。

可以在商业软件中检测事件并显示消息吗?

t1085ok,

答案是肯定的。

我建议自动热键(AHK)。它是初学者级别的,但提供了强大的功能来做你想做的事情。

你可以在这里免费下载:http://ahkscript.org/download/

您可以直接将代码写入记事本文档(或免费的社区开发的文本编辑器之一),并将其保存为*。创建一个脚本文件

命令如下:

Run, Chrome.exe
WinWait, New Tab - Google Chrome
WinActivate, New Tab - Google Chrome
Send, {F6}www.example.com{Enter}
Sleep, 1000
MsgBox, Action complete.
Return

脚本

  • 开始Chrome
  • 等待,直到一个名为"新选项卡-谷歌Chrome"的窗口存在
  • 激活窗口
  • 发送按键[F6] www.example.com [Enter]
  • 停止1秒
  • 显示"动作完成"的消息框。

甚至有GUI脚本用于创建带有按钮和控件的表单。这是一个代码片段从一个表单应用程序,我正在工作一段时间后:

Gui, Add, Button, x16 y15 w108, Activate Window 1
Gui, Add, Button, x16 y44 w108, Activate Window 2
Gui, Add, Button, x16 y73 w108, Activate Window 3
Gui, Add, Button, c000000 x24 y469 w100, Reset
Gui, Add, Button, x24 y498 w100 default, Run
Gui, Color, 404040, 000000
Gui, Show, Center w645, Repeat Keystrokes
return
buttonActivateWindow1:
Gui, Submit, NoHide
GuiControl,, Keystrokes, %Keystrokes%<window>%Activate1WindowText%</window>
GuiControl, Focus, Keystrokes
Send, ^a{End}
return
buttonActivateWindow2:
Gui, Submit, NoHide
GuiControl,, Keystrokes, %Keystrokes%<window>%Activate2WindowText%</window>
GuiControl, Focus, Keystrokes
Send, ^a{End}
return
buttonActivateWindow3:
Gui, Submit, NoHide
GuiControl,, Keystrokes, %Keystrokes%<window>%Activate3WindowText%</window>
GuiControl, Focus, Keystrokes
Send, ^a{End}
return

是的,你可以处理事件当文本在一个特定的窗口,甚至当一个特定的图像在一个窗口。

下面是我写的一个复制粘贴脚本的例子,它允许你复制多个项目,然后一个接一个地粘贴它们:

#SingleInstance Force
#CommentFlag //
#Persistent
// '#SingleInstance Force' only allows one instance of this script
// to run at a time.
// '#CommentFlag //' changes the scripts comment delimiter. I like
// "//" for comments.
// '#Persistent' kees the script running for objects like a timer.

// Create new array as an object.
ParseBoard := Object()
// Define new hotkey event for Ctrl+C
// It overrides the system's event for Ctrl+C
$^c::
     KeyWait, c
// Clear the clipboard.
clipboard =
// Copy the selected text.
Send, ^c
ClipWait
// Add text to array.
ParseBoard.Push(clipboard)
// Store the number of items currently in the array, as 'ParseCount'.
ParseCount := ParseBoard.MaxIndex()
// Display number of items copied on a tooltip for 2.5 seconds.
ToolTip, %ParseCount%
SetTimer, RemoveTT, 2500
Return
Return

// Define new hotkey event: Ctrl+V
^v::
// Stop if the shift key is down.
if (GetKeyState("Shift", "P") = 1)
     Return
KeyWait, v
// Return oldest string in array, and send keystrokes.
CurrentString := ParseBoard.RemoveAt(1)
SendInput, %CurrentString%
// Update the total items in array, within variable 'ParseCount'.
ParseCount := ParseBoard.MaxIndex()
// Display tooltip of remaining items for 2.5 seconds
ToolTip, %ParseCount%
SetTimer, RemoveTT, 2500
// Stop script.
Return

// The go-to tag for the timers. Removes tooltip from the screen.
RemoveTT:
     SetTimer, RemoveTT, Off
     ToolTip
     Return

// New hotkey event: Ctrl+Shift+V
$^+v::
KeyWait, v
// Send the last pasted item, instead of the next.
SendInput, %CurrentString%
// Stop script.
return

// Allow user to kill the entire script with the Escape key.
^Esc::ExitApp

和脚本可以做什么你想做的是张贴在这里:http://ahkscript.org/docs/commands/ImageSearch.htm

它在屏幕上搜索图像,并允许您相应地处理。

在您的例子中,您可以获取消息框的快照,保存它,引用它的路径,并使用if(…)…其他…

它还带有一个编译器,因此您可以在其他计算机上使用它作为*.exe文件。