Jump to content
Sign in to follow this  
Kammamuri

send keys to an IE input object in an inactive window

Recommended Posts

Kammamuri

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
water

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


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
Kammamuri

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
water

Did you try _IEFormElementSetValue?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
Kammamuri

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
water

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 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
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  

×