Sending Strings with HoldKey

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
fightcancer
Macro Veteran
Posts: 239
Joined: Fri Apr 15, 2005 8:32 am

Sending Strings with HoldKey

Post by fightcancer » Fri Mar 25, 2022 4:30 am

Any way to send strings using HoldKey? I'd like to send a string without parsing each character. (An app I'm using only accepts HoldKey input, i.e. not Send, VBScript, etc.) Thanks!

ocnuybear
Pro Scripter
Posts: 100
Joined: Sun Jul 15, 2018 5:14 pm

Re: Sending Strings with HoldKey

Post by ocnuybear » Fri Mar 25, 2022 10:02 am

How about these two options?
1.

Code: Select all

UISetValue>{"Untitled - Notepad"},{"Text Editor"},{%Str%}
OR

2.

Code: Select all

HoldKey>Str,500,0
As seen in the script below- both works with Notepad

Code: Select all

LabeltoVar>String,Str
SetFocus>Notepad*
WaitWindowFocused>Notepad*

//UISetValue>{"Untitled - Notepad"},{"Text Editor"},{%Str%}
HoldKey>Str,500,0

/*
String:
const btn = document.createElement("button");
const object1 = document.querySelectorAll(":hover").item(9);
const htm1 = object1.outerHTML;
btn.innerHTML = htm1;
document.body.appendChild(btn);
*/

fightcancer
Macro Veteran
Posts: 239
Joined: Fri Apr 15, 2005 8:32 am

Re: Sending Strings with HoldKey

Post by fightcancer » Fri Mar 25, 2022 2:39 pm

Thanks for showing me the UI commands. Hadn't seen those before that I remember.

Hmmm.... That script does nothing for me except to focus the Notepad window. If I remove the "//" comment from the UISetValue> line, then it enters into Notepad the text in Str.

Sadly, UISetValue> does not work with this app. Thanks though!

For now I'm using this:

Code: Select all

Let>GW=0.1
GoSub>HoldKeyStr,AnyText

SRT>HoldKeyStr
//Send a string one character at a time using HoldKey.
Let>Str=HoldKeyStr_Var_1
Length>Str,StrLen
Let>kStr=0
Repeat>kStr
  Add>kStr,1
  MidStr>Str,kStr,1,HoldKeyChar
  HoldKey>HoldKeyChar,1,0
    Wait>GW
Until>kStr,StrLen
END>HoldKeyStr

ocnuybear
Pro Scripter
Posts: 100
Joined: Sun Jul 15, 2018 5:14 pm

Re: Sending Strings with HoldKey

Post by ocnuybear » Fri Mar 25, 2022 5:05 pm

Hi fightcancer,

Please try using the "Send Keys to Objects Wizard" under Keyboard Commands:

Code: Select all

//Send keystrokes directly to Notepad's edit control (Notepad does not require focus)
GetWindowHandle>Untitled - Notepad,hWndParent
FindObject>hWndParent,Edit,,1,hWnd,X1,Y1,X2,Y2,result
ObjectSendKeys>hWnd,{"Hello World"}

fightcancer
Macro Veteran
Posts: 239
Joined: Fri Apr 15, 2005 8:32 am

Re: Sending Strings with HoldKey

Post by fightcancer » Fri Mar 25, 2022 5:45 pm

Yes, I can automate Notepad, but the goal is to automate another app I'm using, an app that doesn't have objects discernible to MS besides Minimize, Maximize and Close.

I have a functional solution for now. Thanks!

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