Jump to content

send keys to an IE input object in an inactive window


Recommended Posts

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

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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!

Link to comment
Share on other sites

Did you try _IEFormElementSetValue?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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"

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...