Sign in to follow this  
Followers 0
TwistedGA

ControlGetFocus

8 posts in this topic

Hey guys, in need of a little assistance again..

I've got everythign working as normal, but I'm unable to retain GUI operation once it's started. I belive it's due to the loop doing no check to see if the input box already has focus, instead it just continues to give it focus..

I've tried a few different things, started with ControlGetFocus() but because the input is in IE, I can't get a return on the handle of the control to run a focus check, I tried some things using WinAPI and didn't have much luck... Any help would be grealty appreciated as always.. Thanks in advance!

Share this post


Link to post
Share on other sites



Hey guys, in need of a little assistance again..

I've got everythign working as normal, but I'm unable to retain GUI operation once it's started. I belive it's due to the loop doing no check to see if the input box already has focus, instead it just continues to give it focus..

I've tried a few different things, started with ControlGetFocus() but because the input is in IE, I can't get a return on the handle of the control to run a focus check, I tried some things using WinAPI and didn't have much luck... Any help would be grealty appreciated as always.. Thanks in advance!

Have you tried _IEAction ( $oSubmit, "focus" ) ?

but with the script its better for help...


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

There's not much to post really,

I need to check to see if a control has focus already, if it does then void the loop that wants to give it focus.

So in a nutshell:

If controlhasfocus = 1 Then
Else
ControlFocus()
EndIf

The problem is finding out what has focus on the IE form. I couldn't find anything like that in the IE management section of the help file.

Without knowing what has focus and running the check, it continues to set focus in the input I tell it to, and my Kill Loop button is useless.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Try this... I haven't, so no guarentees. It should work in theory, but as Einstein so rightly put: "In theory, practice and theory are the same. In practice they're not."

If _IEGetActiveObj($oIE) <> $oElement Then
    ; focus it
EndIf

Func _IEGetActiveObj($oIE)
    $oDoc = _IEDocGetObj($oIE)
    Return $oDoc.activeElement
EndFunc

Edit: Source: http://msdn.microsoft.com/en-us/library/ms533065(VS.85).aspx

Edited by Mat

Share this post


Link to post
Share on other sites

I should be able to consolewrite the result of the $oDoc.activeElement right?

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

I should be able to consolewrite the result of the $oDoc.activeElement right?

Try it and see. I imagine it's an object so I don't know what the result will be, but $oDoc.activeElement.innerHTML should definitely work.

Edit: If you want help from someone who knows what they are talking about then you need a more descriptive title, ideally something like "IE - Check if an object has focus" or something like that.

Edited by Mat

Share this post


Link to post
Share on other sites

Try it and see. I imagine it's an object so I don't know what the result will be, but $oDoc.activeElement.innerHTML should definitely work.

Edit: If you want help from someone who knows what they are talking about then you need a more descriptive title, ideally something like "IE - Check if an object has focus" or something like that.

I was afraid to be too specific with the title of the thread so any information that comes out of it would be easier to find in searches.. Then again, I usually don't find much because I try to be too specific I think.

I couldn't get any results with the $oDoc.activeElement, adding innerHTML resulted in a '0' result, no matter what has focus. I'll keep at it and hopefully come up with a solution. Thanks for you help man, if you have any other suggestions I'd be more than happy to hear them. I'll post up if I find anything that works so others can see it.

Share this post


Link to post
Share on other sites

Hmmm... Not sure what the problem is then. As said, I am not too good at IE stuff, maybe the fact that its in a form is not helping.

Reading the MSDN page it would appear you have to wait for the whole page to load before using it (I assume this isn't a problem if you are using IE.au3). I'll see if I get time to test tomorrow, as this could be useful.

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