2
votes

I am trying to write a script in AHK to detect windows popup and capture the message.

For example: Program X will create a popup with a message. The AHK script should be able to detect the popup and get the message in it.

Is this possible?

I tried the example from http://www.autohotkey.com/board/topic/23221-run-command-prompt-commands-and-capture-output/ but it is too complicated.

I just need to capture the message of a popup using AHK script.

1
Does the popup always have the same title and/or class? This would be needed in order to grab the window's message.Elliot DeNolf
@ElliotDeNolf ahk_exe or even ahk_pid are pretty good identifiers, too. Anyway, message boxes often can only be detected by using DetectHiddenWindows, On.MCL

1 Answers

2
votes

Actually this can be done. The AHK code below will detect a Windows popup with the title "Test" and each time such a popup is detected it will write a message into a textfile.

Loop
   {
      Sleep 500

      if (WinExist("Test"))
      {
         FileAppend, Another line. , C:\Users\user1\Desktop\testahk.txt
      }
   }

Take note: it is in a loop, so it will run continuously.

However I'm still trying to figure out how to grab the whatever message that will be shown inside the popup.

Still working on it. Anybody have an idea on that one?