Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

True In-Line Send Sleep


  • Please log in to reply
6 replies to this topic
AfterLemon
  • Moderators
  • 237 posts
  • Connoisseur of Boobs
  • Last active: Jan 04 2016 11:12 PM
  • Joined: 09 Oct 2012

Supports Milliseconds by default, but with a single character after the number, supports seconds.

 

Syntax is as simple as any other key.

e.g.:

   {500}     = 500ms

   {20000} = 20s

   {20s}     = 20s

   {2.5a}    = 2.5s (2500ms)

   {-20}      = ClipWait max of 20 seconds.

 

NOTE: Any (ms) sleep below standard Windows minimum of 15 or 17.8 will sleep for the standard time. See: Sleep

Send(String,Raw:="",RawKeys:=""){
    D:="{",E="}",S:=String D,i=0,T=1,R=(Raw?1:(SubStr(S,1,5)="{RAW}"?1:0)),M="+,!,#,^",K=RawKeys
    While i:=InStr(S,D,V,i+1){
        Send,% (R?"{RAW}":"") SubStr(S,T,InStr(S,D,V,i)-T)
        B:=SubStr(S,InStr(S,D,V,i)+1,InStr(S,E,V,i)-StrLen(S)-1),A=SubStr(B,1,-1)
        If InStr(S,D,V,i+1)
            If(B&1=""){
                If(A&1!="")
                    Sleep,% A*1000
                else{
                    L:=(!R?(InStr(S,E,V,i)-StrLen(B)-2>4?4:InStr(S,E,V,i)-StrLen(B)-2):0)
                    Loop,%L%{
                        C:=SubStr(SubStr(S,InStr(S,D,V,i)-L,L),A_Index,1)
                        If C in %M%
                        {    C:=SubStr(S,InStr(S,D,V,i)-(L+1-A_Index),L+1-A_Index)
                            break
                        }else C:=""
                    }Send,% (K?"{RAW}":"") C D B E
            }}else If(W:=SubStr(B,2))
                ClipWait,%W%
            else Sleep,%B%
        T:=InStr(S,E,V,i+1)+1
}}

An Example:

Send("Really,{2000} any sleep !fcould{3000}{Enter} go+{Tab 8} here {3.5s}and it {500}should work.",1)

This will output as:

Really, any sleep !fcould
 go+                                 here and it should work.

I thought it was time for a real working function. Still looking for bugs and will keep up to date.

 

--AfterLemon

 

EDIT: Modifier Keys are fixed and should be fully functional.

EDIT: ClipWait integration.


Edited by AfterLemon, 04 January 2016 - 11:08 PM.
Added ClipWait functionality


Grendahl
  • Members
  • 416 posts
  • Last active: Jul 07 2014 08:01 PM
  • Joined: 10 Aug 2009
How about some documentation as to what the possible options are?
R = Raw, etc.
Always have your scripts when you need them with Dropbox.
Sign up for free! http://db.tt/9Hrieqj

AfterLemon
  • Moderators
  • 237 posts
  • Connoisseur of Boobs
  • Last active: Jan 04 2016 11:12 PM
  • Joined: 09 Oct 2012

For any string, you can pass the items with modifier keys sent, or without, by omitting or including, respectively the Raw parameter. If it is anything other than 0 or blank, it will use the {RAW} option for the Send.

 

All sleeps must be wrapped in {} just as {Enter} and {Esc} for example.

 

Dynamic inline sleeps can be done easily as well:

Sleep:=10000
Send("Sleeping for 10 seconds. Please Wait.... {" Sleep "}Done Sleeping.")

OR

Sleep2:=10000
Send("Sleeping for 10 seconds. Please Wait.... {" Sleep2/20 "}Done Sleeping.")


AfterLemon
  • Moderators
  • 237 posts
  • Connoisseur of Boobs
  • Last active: Jan 04 2016 11:12 PM
  • Joined: 09 Oct 2012

Updated (with a sad loss of minimalism) to accept modified, braced keys:

Send("+{Enter}+!{Tab 8}#!+^{Del}")


Grendahl
  • Members
  • 416 posts
  • Last active: Jul 07 2014 08:01 PM
  • Joined: 10 Aug 2009
Love the use of ternary on this. Keeps it nice and compact, even with the expansion for the modifiers.
Always have your scripts when you need them with Dropbox.
Sign up for free! http://db.tt/9Hrieqj

AfterLemon
  • Moderators
  • 237 posts
  • Connoisseur of Boobs
  • Last active: Jan 04 2016 11:12 PM
  • Joined: 09 Oct 2012

Updated to include the option to send {Braced Keys} as plaintext rather than as a key.

 

Send("{Enter}",,1) will output as: {Enter}

 

Unbraced keys are still affected by the Raw parameter (param #2) rather than RawKeys (param #3). e.g. ^v ^c ^x



AfterLemon
  • Moderators
  • 237 posts
  • Connoisseur of Boobs
  • Last active: Jan 04 2016 11:12 PM
  • Joined: 09 Oct 2012

It's been a long time since I've been here, but I felt this deserved a quick update to include the ability to ClipWait (obviously only useful if your Send includes a "^c".