AutoHotkey Community

It is currently May 26th, 2012, 1:15 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: November 21st, 2008, 10:00 pm 
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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 21st, 2008, 10:44 pm 
Offline

Joined: October 7th, 2006, 4:50 pm
Posts: 3157
Location: MN, USA
I did make a belated reply to your help request. It would seem that ControlGet cannot work with that type of control.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: November 21st, 2008, 11:41 pm 
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.


Report this post
Top
  
Reply with quote  
PostPosted: November 21st, 2008, 11:50 pm 
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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 23rd, 2008, 1:16 am 
I can confirm that.

AHK Windows spys only detects "WindowsForms10.STATIC" fields.

"WindowsForms10.Window" controls are ignored.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 23rd, 2008, 1:56 am 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5347
Location: UK
.NET windows forms, like Java Swing or AWT, do not respond by default to standard windows messages so Control commands will not work.

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: November 24th, 2008, 4:45 am 
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?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 30th, 2008, 8:29 am 
Offline

Joined: May 24th, 2008, 11:07 am
Posts: 7
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 27th, 2010, 1:48 pm 
Offline

Joined: February 7th, 2009, 11:28 pm
Posts: 384
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 27th, 2010, 5:30 pm 
Offline

Joined: October 7th, 2006, 4:50 pm
Posts: 3157
Location: MN, USA
ControlGet List doesn't work with .NET Windows.Forms


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group