Jump to content

Trouble controlling another window


Recommended Posts

I'm trying to control another app by adjusting sliders and clicking buttons. Here's the details of one of the buttons:

>>>> Window <<<<
Class: ThunderRT6FormDC
Position: 1, -3
Size: 733, 564
Style: 0x16020000
ExStyle: 0x00040000
Handle: 0x004B08FC
>>>> Control <<<<
Class: ThunderRT6UserControlDC
Instance: 47
ClassnameNN: ThunderRT6UserControlDC47
Advanced (Class): [CLASS:ThunderRT6UserControlDC; INSTANCE:47]
Position: 474, 299
Size: 105, 18
ControlClick Coords: 84, 10
Style: 0x56000000
ExStyle: 0x00000000
Handle: 0x00490A30

I have verified I can control the window:

If WinActive("[CLASS:ThunderRT6FormDC]") Then
  ConsoleWrite("Window was active" & @CRLF)
  ConsoleWrite("Window was not active" & @CRLF)

However, when attempting to click a button I get no response:

ControlClick("[CLASS:ThunderRT6FormDC]", "", "CLASS:ThunderRT6UserControlDC; INSTANCE:47")


ControlClick("[CLASS:ThunderRT6FormDC]", "", "ClassnameNN:ThunderRT6UserControlDC47")

I've also tried preceding those commands with:


This yielded no change. Any suggestions?? Does this appear to be an issue with my code or the app? As a last resort, any other ways of control aside from these Controlxxx commands? (not 'mouse emulation' please.) :D

Edited by DrJeseuss
Link to comment
Share on other sites

Have you tried ControlSend and send "{ENTER}" or "{SPACE}"? Sometimes that is easier than clicking and it still gives you the same level of control.

Edit: Send "{APPSKEY}" if emulating a mouse right-click

Edited by Varian
Link to comment
Share on other sites

I've tried tis suggestion and it appears this also is not working. I did a bit of 'error checking' and it appears I'm not getting focus to the controls:

ControlFocus("[CLASS:ThunderRT6FormDC]", "", "[ClassnameNN:ThunderRT6CheckBox15]")  ; Checkbox
$a = ControlGetFocus("[CLASS:ThunderRT6FormDC]")
ConsoleWrite("Focus: " & $a & @CRLF)
ControlSend("[CLASS:ThunderRT6FormDC]", "", "[ClassnameNN:ThunderRT6CheckBox15]", "{+}")
ControlFocus("[CLASS:ThunderRT6FormDC]", "", "[ClassnameNN:ThunderRT6UserControlDC3]")   ; Slider that adjusts with up or down arrow when in focus
$a = ControlGetFocus("[CLASS:ThunderRT6FormDC]")
ConsoleWrite("Focus: " & $a & @CRLF)
ControlSend("[CLASS:ThunderRT6FormDC]", "", "[ClassnameNN:ThunderRT6UserControlDC3]", "{DOWN}")

Both of my ControlGetFocus commands return the same value, and not the control I've requested (15 and 3 as above). It instead reports both as the last control I clicked manually before running the script. Any ida why these aren't getting focus or commands?

Just did more checking. here's the code:

$a = ControlFocus("[CLASS:ThunderRT6FormDC]", "", "[ClassNameNN:ThunderRT6CheckBox15]")  ; Failure returns 0
ConsoleWrite("ControlFocus?: " & $a & @CRLF)
$a = ControlGetFocus("[CLASS:ThunderRT6FormDC]")
ConsoleWrite("Focus: " & $a & @CRLF)
$a = ControlSend("[CLASS:ThunderRT6FormDC]", "", "[ClassnameNN:ThunderRT6CheckBox15]", "{+}")  ; Failure returns 0 if window/control is not found.
ConsoleWrite("ControlSend?: " & $a & @CRLF)

And the response.

ControlFocus?: 0
Focus: ThunderRT6CheckBox15
ControlSend?: 0

It appears to be failing to find the control. Is there something I'm missing here?

(Note: I manually set focus to the control in the above demonstration. If manually clicking a different control, it's ClassNameNN is shown instead. I chose this one to match with my code to verify correct naming, syntax, etc.)

Edited by DrJeseuss
Link to comment
Share on other sites

I have success... somewhat... Hee's my code:

ControlFocus("[CLASS:ThunderRT6FormDC]", "", "[CLASSNN:ThunderRT6UserControlDC44]")
ControlSend("[CLASS:ThunderRT6FormDC]", "", "[CLASSNN:ThunderRT6UserControlDC44]", "{SPACE}")
ControlFocus("[CLASS:ThunderRT6FormDC]", "", "[CLASSNN:ThunderRT6CheckBox15]")
ControlSend("[CLASS:ThunderRT6FormDC]", "", "[CLASSNN:ThunderRT6CheckBox15]", "{SPACE}")
ControlFocus("[CLASS:ThunderRT6FormDC]", "", "[CLASSNN:ThunderRT6UserControlDC3]")
ControlSend("[CLASS:ThunderRT6FormDC]", "", "[CLASSNN:ThunderRT6UserControlDC3]", "{DOWN}")

I had a syntax problem before. Now my issue is that I must have focus on the control and simulate key presses... which means an active GUI. I can hide it, though each time I press a button to change pages the GUI reappears. I can rehide, but this makes for a lot of flashing. Any ideas?

Link to comment
Share on other sites

Can you still interact with your controls if the window is moved out of the viewable screen? You can "restore" it when you are finished messing with your controls. Here is an example:

$wPos = WinGetPos('[CLASS:CalcFrame]')
Local $x = $wPos[0], $y = $wPos[1]
While 1
WinMove('[CLASS:CalcFrame]', '', $x, $y)
If $x < @DesktopWidth + 10 Then $x += 5
If $y < @DesktopHeight + 10 Then $y += 5
If ($x >= @DesktopWidth + 10) And ($y >= @DesktopHeight + 10) Then ExitLoop
ControlSend('[CLASS:CalcFrame]', '', '[CLASS:#32770; INSTANCE:1]', @YEAR)
WinMove('[CLASS:CalcFrame]', '', $wPos[0], $wPos[1])
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...