Page 1 of 1

How to set input focus only on that control which is editable or not read only?

Posted: 19 Apr 2017, 12:29
by Sabestian Caine
Friends I want that when I press f1 key then it should set input focus on the control which is editable or not read only. for example please look at this image-
Image

In the above image you can see that I used ranorexspy tool to get the information of current window’s controls and it is showing that the state of the current control is focusable and currently it is focused.

Now please look at this image-
Image

In this image you can see that the state of this control is unavailable and it is read only.

I know I can use winget command to get the list of all controls of the active window and then I can use a parsing loop to get specific control and then controlsetfocus can be used to set input focus on the specific control. Moreover, control’s ClassNN or Control ID can be retrieved by control’s position and the width and the height of the control but all these methods does not specify which control of the active window is focusable or not read only.

Can anybody help me to solve this issue?

Thanks a lot....

Re: How to set input focus only on that control which is editable or not read only?  Topic is solved

Posted: 19 Apr 2017, 15:44
by A_AhkUser
Hi,

Maybe you could take advantage of the ControlGet, OutputVar, Style command.
It appears in the code above that controlStyle variable change depending on whether or not control has ReadOnly property:

0x50211844 ; << +readonly
0x50211044 ; << -readonly

Code: Select all

Gui, Add, Edit, vmyEditControl hwndCID x1 y1 w300 h30 +ReadOnly, blabla
Gui, Show, AutoSize, test
return


!i:: ; CTRL+I
ControlGet, controlStyle, Style,,, % "ahk_id " . CID
MsgBox % controlStyle
GuiControl -ReadOnly, myEditControl
ControlGet, controlStyle, Style,,, % "ahk_id " . CID
MsgBox % controlStyle
GuiControl +ReadOnly, myEditControl
ControlGet, controlStyle, Style,,, % "ahk_id " . CID
MsgBox % controlStyle
return

Actually, for edit controls, among Styles Usable by the Gui and GuiControl Commands we can find this one:

ES_READONLY := "0x800" ; for edit control.
I can't really say if it's reliable.


Hope this helps.

Re: How to set input focus only on that control which is editable or not read only?

Posted: 21 Apr 2017, 00:27
by Sabestian Caine
A_AhkUser wrote:Hi,

Maybe you could take advantage of the ControlGet, OutputVar, Style command.
It appears in the code above that controlStyle variable change depending on whether or not control has ReadOnly property:

0x50211844 ; << +readonly
0x50211044 ; << -readonly

Code: Select all

Gui, Add, Edit, vmyEditControl hwndCID x1 y1 w300 h30 +ReadOnly, blabla
Gui, Show, AutoSize, test
return


!i:: ; CTRL+I
ControlGet, controlStyle, Style,,, % "ahk_id " . CID
MsgBox % controlStyle
GuiControl -ReadOnly, myEditControl
ControlGet, controlStyle, Style,,, % "ahk_id " . CID
MsgBox % controlStyle
GuiControl +ReadOnly, myEditControl
ControlGet, controlStyle, Style,,, % "ahk_id " . CID
MsgBox % controlStyle
return

Actually, for edit controls, among Styles Usable by the Gui and GuiControl Commands we can find this one:

ES_READONLY := "0x800" ; for edit control.
I can't really say if it's reliable.


Hope this helps.

Thanks dear A_Ahkuser................
you really did a great job.................