Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

GuiControl bug when using HWND as ControlID



  • Please log in to reply
7 replies to this topic
just me
  • Members
  • 1496 posts
  • Last active: Nov 03 2015 04:32 PM
  • Joined: 28 May 2011
#NoEnv
#SingleInstance Force

Gui, Add, Radio, vRB1 hwndHRB1, Hello world!
Gui, Add, Radio, vRB2 hwndHRB2, Hello world!
Gui, Show, y100 w300

Gui, New, +LabelGu1
Gui, Add, Button, hwndHBT1 gAction1, Disable Radio 2
Gui, Add, Button, hwndHBT2 gAction2, Disable Radio 2
Gui, Show, y250 w300
Return

Action1:
   GuiControl, Disable, RB2
Return

Action2:
   GuiControl, Disable, %HRB2%
Return

GuiClose:
GuiEscape:
ExitApp

Prefer ahkscript.org for the time being.


Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
✓  Best Answer

Fixed in v1.1.09.03.

 

Your code now correctly fails instead of disabling the wrong control.  If the control is not on the default Gui, the correct Gui must be specified even if the ControlID uniquely identifies a single control, such as if it is a HWND or the associated variable of a control.  (This has not changed.)



just me
  • Members
  • 1496 posts
  • Last active: Nov 03 2015 04:32 PM
  • Joined: 28 May 2011

Thanks.

 

Would you change this in v2? Unlike associated variables, ClassNNs, and control IDs HWNDs are unique as long as the controls exist. So we don't need the GUI name to detect the right control.

 

Furthermore I suggest to make Win, Control, and Post/SendMessage commands work for hidden windows in either case in v2 whenever a HWND is used as identifier.


Prefer ahkscript.org for the time being.


qwerty0
  • Members
  • 39 posts
  • Last active: Feb 25 2013 09:45 AM
  • Joined: 25 Oct 2012

Thanks.

 

Would you change this in v2? Unlike associated variables, ClassNNs, and control IDs HWNDs are unique as long as the controls exist. So we don't need the GUI name to detect the right control.

 

Furthermore I suggest to make Win, Control, and Post/SendMessage commands work for hidden windows in either case in v2 whenever a HWND is used as identifier.

+1

And the Gui,Tab Command too.

To use Control IDs/Hwnds is easier than the associated variables.



Coco
  • Members
  • 697 posts
  • Last active: Oct 31 2015 07:26 PM
  • Joined: 27 Jul 2012

To use Control IDs/Hwnds is easier than the associated variables.

 

Perhaps have A_GuiControl return the control's Hwnd if the control does not have an associated variable..this would be nice as well.wink.png  Or add something like A_GuiControlHwnd



qwerty0
  • Members
  • 39 posts
  • Last active: Feb 25 2013 09:45 AM
  • Joined: 25 Oct 2012

it has been requested .http://www.autohotke...a-guicontrolid/.



Coco
  • Members
  • 697 posts
  • Last active: Oct 31 2015 07:26 PM
  • Joined: 27 Jul 2012

@qwerty0: Cool, thanks for making the request



Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006

Would you change this in v2?

Maybe.

 

I almost did it this time, but it would've been too convoluted.  Normally resolving the ControlID requires first resolving the GUI.  As it is, if the current/default GUI doesn't exist, the command aborts before looking at ControlID.

 

I don't see much need to change it.

 

+1
And the Gui,Tab Command too.
To use Control IDs/Hwnds is easier than the associated variables.

Which part of just me's post are you referring to?  There was no suggestion to allow HWNDs in additional commands.  In any case, I wholly disagree with your suggestion that it's easier to use a HWND; except in special cases where the HWND is the only identifier you have.