0
votes

I'm trying to force a window to close by pressing it's "Cancel" button, but I'm having a hard time using either ControlSend or ControlClick to accomplish this. I know what the control is called via Window Spy, and I know I have my syntax/names correct. I've had problems like this before with this particular program's popup windows not responding well to Controlsend. I could just send a couple of {Tab}'s, but I'd rather be precise about it.

So, here's my question. Can you use the CONTROL text, rather than the window text to control where a command is sent?

Here's my current code:

ControlSend, TmtBitBtn2, {Enter} ahk_class TROListForm

Here's what Window Spy says about this button:

( Now Under Mouse Cursor )

ClassNN: TmtBitBtn2

Text: Cancel

Color: 0xF0F0F0 (Blue=F0 Green=F0 Red=F0)

Is there any way I can use the text "Cancel" instead of the ClassNN?

Thanks! Paul

1

1 Answers

0
votes
F1:: ControlClick,  Cancel, ahk_class TROListForm

or

F1::
Loop
{
 Sleep, 100
 IfWinExist, ahk_class TROListForm
    ControlSend, TmtBitBtn2, {Enter} ahk_class TROListForm
     ; or
     ; ControlClick, Cancel, ahk_class TROListForm
}
return