 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
cronejp Guest
|
Posted: Fri Nov 21, 2008 9:00 pm Post subject: Bug with ControlGet and application using windowsforms? |
|
|
Couple of days ago i posted a forum question about ControlGet,
unfortunately didn't get a response. I've done some more testing
on both XP and Vista, and on both OS'es i get the same behaviour.
Grabbing some other sample code which uses controlGet, I also
get anomalous behaviour, so I'm really suspicious there is a bug here.
Running 1.0.47.06
i'm writing some automation code to allow for automatic testing of
a audio control matrix, so its a windows app with a field of checkboxes
which corresponds to a set of crosspoints in a switching matrix.
Nothing special.
The idea of the AHK code snippet below is that if a particular
checkbox is set, we flip it to the opposite state.
If its is -not- set, we flip the adjacent checkbox.
The problem is, no matter the state of Control app4227,
the adjacent checkbox is -always- set:
that is: the ControlGet call is -always- setting
currStateofButton to 0, it never gets set to one,
irrespective of whether the control app4227 has a checkbox set or unset.
I know that the correct control is being used for the activity
because the ControlClick properly addresses
the control, and flips the state of the checkbox back and forth
reliably. (if I do a loop, and don't bother with ControlGet
I can flip the control back and forth at will)
| Code: |
SetTitleMatchMode,2
IfWinExist, iCONMASTER
{
WinActivate ; Automatically uses the window found above.
}Else{
msgbox, "You Don't Have ICU open"
}
;;WindowsForms10.BUTTON.app4227
;; In case we needed focus on the Control,
;; this appeared to be used frequently in nDroid code
ControlFocus, WindowsForms10.BUTTON.app4227, iCONMASTER
;; use ControlGet to get the state of the chosen checkbox
ControlGet, currStateofButton, Checked, , WindowsForms10.BUTTON.app4227, iCONMASTER
;; If the checkbox is set (currStateofButton) is 1, use controlclick
;; to invert it
;; otherwise flip the adjacent checkbox
if currStateofButton
ControlClick, WindowsForms10.BUTTON.app4227, iCONMASTER,,LEFT,1
else
ControlClick, WindowsForms10.BUTTON.app4226, iCONMASTER,,LEFT,1
|
Is this a bug with ControlGet? I've tried every variation
with the window identifier, the spacing between the commas etc,
I've used MouseGetPos to identify the control instead, nothing. |
|
| Back to top |
|
 |
jaco0646
Joined: 07 Oct 2006 Posts: 3113 Location: MN, USA
|
Posted: Fri Nov 21, 2008 9:44 pm Post subject: |
|
|
| I did make a belated reply to your help request. It would seem that ControlGet cannot work with that type of control. |
|
| Back to top |
|
 |
cronejp Guest
|
Posted: Fri Nov 21, 2008 10:41 pm Post subject: Thank you for taking the time to respond. |
|
|
its very wierd, as I've tried this controlget with 3 different applications,
a compiled VB exe, the internal application (which uses Exceed DLL
libraries for UI) and application called PUTTY.
I suspect that because both VB and the internal application are
both using .NET the control data isn't being picked up. |
|
| Back to top |
|
 |
cronejp Guest
|
Posted: Fri Nov 21, 2008 10:50 pm Post subject: Yes, its .Net thats the problem. |
|
|
I tried a few more applications, as soon as I finally got the thought
thanks to jaco0646 that it might have been something to do with the
actual 'type' of buttons.
It appears that Auto Hot Key can't read controls from a '.NET' application???
Regular applications (non .NET) the buttons (radio and checkboxes)
report as Button<n>
The ".NET" applications report as WindowsForms10.BUTTON.app<n>
and AutoHotKey does not capture the checkbox states. |
|
| Back to top |
|
 |
.net user Guest
|
Posted: Sun Nov 23, 2008 12:16 am Post subject: |
|
|
I can confirm that.
AHK Windows spys only detects "WindowsForms10.STATIC" fields.
"WindowsForms10.Window" controls are ignored. |
|
| Back to top |
|
 |
polyethene
Joined: 11 Aug 2004 Posts: 5248 Location: UK
|
Posted: Sun Nov 23, 2008 12:56 am Post subject: |
|
|
.NET windows forms, like Java Swing or AWT, do not respond by default to standard windows messages so Control commands will not work. _________________ GitHub • Scripts • IronAHK • Contact by email not private message. |
|
| Back to top |
|
 |
cronejp Guest
|
Posted: Mon Nov 24, 2008 3:45 am Post subject: Thanks Titan: any thoughts for how to work around the " |
|
|
I mean the horribly obvious approach would be to do a color check
inside the control for the checkmark being present or not,
but that seems like such a horrible kludge.
I tried doing some digging on msdn for the appropriate
DLL library call to be able to query the state of the control
but I'm really more of a unix guy than a windows guy, and
I quickly got utterly lost...
Anyone else have ideas for how to burrow into ".NET" to get
control state? |
|
| Back to top |
|
 |
stewcam
Joined: 24 May 2008 Posts: 7
|
Posted: Sun Nov 30, 2008 7:29 am Post subject: |
|
|
I'm not familiar with your app, but the following might work:
1. Use MouseClick to focus the checkbox control
2. SendInput Down and Up keys to move to the desired setting
3. SendInput Tab to toggle the existing setting
4. SendInput Enter to finish |
|
| Back to top |
|
 |
pajenn
Joined: 07 Feb 2009 Posts: 384
|
Posted: Sat Feb 27, 2010 12:48 pm Post subject: |
|
|
I seem to be having the same issue with AHK v1.0.48.05.
Here's the app with WindowsForms: http://www.say-now.com/
I want to toggle the microphone on/off with a custom hotkey. Code:
| Code: |
#g::
ControlGet,MicOff,Checked,,WindowsForms10.BUTTON.app325,Say-Now Standard ahk_class WindowsForms10.Window.8.app3
If MicOff
Control,Check,,WindowsForms10.BUTTON.app324,Say-Now Standard ahk_class WindowsForms10.Window.8.app3
Else Control,Check,,WindowsForms10.BUTTON.app325,Say-Now Standard ahk_class WindowsForms10.Window.8.app3
return |
The Control commands work, but the ControlGet command always returns 0. _________________ Hardware: 1.8 GHz laptop with 4 GB ram, Windows XP/SP3
Software: Prevx, Privatefirewall, KeyScrambler. |
|
| Back to top |
|
 |
jaco0646
Joined: 07 Oct 2006 Posts: 3113 Location: MN, USA
|
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|