Hold time key in "ObjectSendKeys"

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
Torkas
Newbie
Posts: 10
Joined: Wed Sep 30, 2015 5:41 pm

Hold time key in "ObjectSendKeys"

Post by Torkas » Tue Oct 31, 2017 10:02 pm

Hi, I need to open an application in background state sending [CTRL+8]. I am using "ObjectSendKeys" command but It doesn't work correctly. I use "ObjectSendKeys>%hWnd%,CTRL_DN,VK56,CTRL_UP" and it doesn't work but If I use "ObjectSendKeys>%hWnd%,CTRL_DN,CTRL_DN,CTRL_DN,VK56,VK56,VK56,CTRL_UP,CTRL_UP,CTRL_UP" sometimes it works but ONLY sometimes ... :((( I have tried multiple combinations adding more or less "CTRL_DN/UP" but the problem is the same, It isn't stable and sometimes the application opens 2 times. If I try to open the application using "SetFocus>%hWnd% / Press CTRL / SendText>8 / Release CTRL" it works correctly and It is stable but I need to open this application in background state !

Any idea about this ??? Maybe the problem is in the hold time key in "ObjectSendKeys" command ...

Sorry my bad English & So regards ! :)

Torkas
Newbie
Posts: 10
Joined: Wed Sep 30, 2015 5:41 pm

Re: Hold time key in "ObjectSendKeys"

Post by Torkas » Sun Nov 05, 2017 2:54 pm

Hi again to everybody,

I tested more combinations sending the HotKey [CTRL+8] by the "ObjectSendKeys" command and I discovered that the problem isn't in "CTRL_DN/UP" keys but in "VK56" key, this is the result:

- "ObjectSendKeys>%hWnd%,CTRL_DN,VK56,CTRL_UP": [IT DOESN'T WORK]

- "ObjectSendKeys>%hWnd%,CTRL_DN,VK56,VK56,VK56,VK56,VK56,VK56,VK56,VK56,CTRL_UP": [IT ONLY WORKS ABOUT 70% AT THE FIRST TRY AND BETWEEN 80-90% THE SECOND AND THIRD TRIES]

- "ObjectSendKeys>%hWnd%,CTRL_DN,VK56 [Between 15 & 20 times],CTRL_UP": [IT WORKS ABOUT 90% BUT SOMETIMES THE APPLICATION OPENS 2 OR 3 TIMES]

Therefore, I understand that the problem is the time by which the "VK56" is held pressed. Does anybody know which is the hold time of the key when using the "ObjectSendKeys" command ? If It isn't possible to change this value by using MS_SCRIPT, would it be possible to change it by using VB_SCRIPT ?

Thank you so much again in advance !!! :)

User avatar
Marcus Tettmar
Site Admin
Posts: 7378
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: Hold time key in "ObjectSendKeys"

Post by Marcus Tettmar » Sun Nov 05, 2017 7:50 pm

Use the HoldKey function:

Press CTRL
HoldKey>VK56,500
Release CTRL

This will hold VK56 for 500 milliseconds. Adjust the delay accordingly.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Torkas
Newbie
Posts: 10
Joined: Wed Sep 30, 2015 5:41 pm

Re: Hold time key in "ObjectSendKeys"

Post by Torkas » Mon Nov 06, 2017 6:59 pm

Thank you for your answer, Marcus ! :)

I had already tried the option with the "Press" command and It always worked correctly without changing the hold time of the key. But I need to execute this HotKey in background without focus ... :(((

It would be perfect if in a future software version the "ObjectSendKeys" supported the "HoldKey" command ... :D

User avatar
Marcus Tettmar
Site Admin
Posts: 7378
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: Hold time key in "ObjectSendKeys"

Post by Marcus Tettmar » Tue Nov 07, 2017 9:58 am

How about trying this:

Code: Select all

//Press CTRL
ObjectSendKeys>%hWnd%,CTRL_DN

//Loop for 500ms, pressing VK56 all the while ...
Timer>start
Let>elapsed=start
Repeat>elapsed
  ObjectSendKeys>%hWnd%,VK56
  Timer>elapsed
Until>elapsed>={%start%+500}

//Release CTRL
ObjectSendKeys>%hWnd%,CTRL_UP
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Torkas
Newbie
Posts: 10
Joined: Wed Sep 30, 2015 5:41 pm

Re: Hold time key in "ObjectSendKeys"

Post by Torkas » Fri Nov 10, 2017 5:48 pm

I am sorry Marcus, but until today I could not to check your script but It doesn't work either ... :( I think that when the MS ends reading the "ObjectSendKeys" line all the keys [_DN] are unpressed and therefore It is necessary that all the [HotKeys] keys are in the same "ObjectSendKeys" line. Is it possible ?

Thank you so much again for your help ! :D

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts