Sign in to follow this  
Followers 0
Vladi243

Focus input always

7 posts in this topic

Is there a way to make the GUI focus only on the input, even if I press on a button?

Share this post


Link to post
Share on other sites



Is there a way to make the GUI focus only on the input, even if I press on a button?

Not exactly, but you could put it back very quickly with ControlFocus(). If necessary you could check/restore focus continuously in a loop.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Not exactly, but you could put it back very quickly with ControlFocus(). If necessary you could check/restore focus continuously in a loop.

:)

Yes, I know that I can use ControlFocus(), and I've already tried it. The problem is that this function always selects the content in the input. I want that the content will be unselected.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

guictrlsendmsg($input,$EM_SETSEL,1000,1000)

I believe that would select the ending of the input after you focus it so nothing would be selected if that's what you want.

EDIT: Also controlfocus doesn't select all the text for me....

Edited by MerkurAlex

[quote name='PsaltyDS' post='635433' date='Jan 27 2009, 07:04 AM']Larry is a mass murderer?! It's always the quiet, clean cut, bald guys... [/quote]

Share this post


Link to post
Share on other sites

Yes, I know that I can use ControlFocus(), and I've already tried it. The problem is that this function always selects the content in the input. I want that the content will be unselected.

That's tricky. You can restore focus with ControlFocus() then immediately ControlSend() an "{END}" to put the cursor at the end of the string. I don't know how you would restore focus AND return the cursor to a previous position in the middle of the string...

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

That's tricky. You can restore focus with ControlFocus() then immediately ControlSend() an "{END}" to put the cursor at the end of the string. I don't know how you would restore focus AND return the cursor to a previous position in the middle of the string...

:)

I would use my guictrlsendmsg but yes that would also work.

Have you tried this i doubt its any different:

GUICtrlSetState($input,$GUI_FOCUS)

[EDIT]

I bet you could use GUICtrlGetState to see if it has focus if it does set a global variable to GUICtrlRecvMsg with $em_getsel(i think) in a loop and then when it looses focus refocus it and use my GUICtrlSendMsg with $em_setsel to 0,global variable.

Edited by MerkurAlex

[quote name='PsaltyDS' post='635433' date='Jan 27 2009, 07:04 AM']Larry is a mass murderer?! It's always the quiet, clean cut, bald guys... [/quote]

Share this post


Link to post
Share on other sites

Thanks guys, all the possibilities that you suggested is working, but they making the script slow for me (there some special things in the script that I can't tell you).

The most fast is what MarkurAlex suggested.

ControlFocus ()
GUICtrlSendMsg ($PasswordInput, $EM_SETSEL,1000,1000)

I think that I'll use this option.

Thanks again guys.

Share this post


Link to post
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
Sign in to follow this  
Followers 0