Sign in to follow this  
Followers 0
Kammamuri

send keys to an IE input object in an inactive window

6 posts in this topic

Hello!

I'm currently using this code:

$oInputs = _IETagNameGetCollection ($oIE, "input")
For $oInput In $oInputs
    If ($oInput.type = "text" And $oInput.name = "name") Then _IEAction ($oInput, "focus")
Next
Send($accountname)

However I'd like to be able to do other things on my pc while my program is running, so the IE window would be open but not on top of all other open windows (ideally i'd like to run also full screen games while the program is running in the background). So my question is how do i modify the above to work in that case? I've searched a bit and seen something with "ControlSend" but it doens't seem to work with ieobjects

thanks in advance,

Kamma

Share this post


Link to post
Share on other sites



If the input is part of a form you could use _IEFormElementSetValue.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Hi again, sorry for the time it took me to reply..

I finally managed to make it with ControlSend

Example: 

$oForm = _IEFormGetObjByName($oIE, "login")
$oInput = _IEFormElementGetObjByName($oForm, "name")
_IEAction($oInput, "focus")
_IEAction($oInput, "selectall")
ControlSend($hIE, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", $accountname)

_IEAction($oInput, "blur")
Sleep($SleepTime1)

$oInput = _IEFormElementGetObjByName($oForm, "password")
_IEAction($oInput, "focus")
_IEAction($oInput, "selectall")

ControlSend($hIE, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", $accountpassword)                         ;Inserisce la password

However I'm experiencing a problem with the following lines:

$oForm = _IEFormGetObjByName($oIE, "snd")
$oInput = _IEFormElementGetObjByName($oForm, "x")
_IEAction($oInput, "focus")
ControlSend($hIE, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", $X)

$oForm = _IEFormGetObjByName($oIE, "snd")
$oInput = _IEFormElementGetObjByName($oForm, "y")
_IEAction($oInput, "focus")
ControlSend($hIE, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", $Y)

they cause the window i'm currently working on to lose focus, which is pretty annoying .. but  i have no idea why, they seem the same to the ones above which work just fine.

ps note that $hIE is running as "Invisible"

please help!

Share this post


Link to post
Share on other sites

Did you try _IEFormElementSetValue?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Just did and it seems to be working much better with _IEFormElementSetValue! Thanks a lot :D

the reason why i was trying to do it  the other way is that i'm not 100% sure i'll always need to interact with objects that are part of a "Form"

Share this post


Link to post
Share on other sites

If you have the first non-form object to cope with, post here and we will see how to solve this problem then.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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