Jump to content

How to make commands shorter?


Recommended Posts

Hello I'm trying to figure out how to make a key press command into an abbreviated version to use in a script, so that I dont take up tons of lines. I know this must be extremely simple but I've been looking everywhere and cant figure it out. I'll show an example blow.

Global $Cata = Send("{2 down}")
Send("{5 down}")
sleep(100)
Send("{2 up}")
Send("{5 up}")
sleep(2500) 

how do I make it so in a script by just using $Cata that it will know to send the text following?

Link to comment
Share on other sites

You probably wouldn't believe me but I managed to emulate a ps4 controller through my computer. Remapped the controller buttons to keys on my laptop. I've made a few scripts over 5000 lines of code and getting hard to find spots that I made an error with that many lines. I know there has so be a some way to shorten those key press commands but I just cant figure. If you can help me with the solution to this problem I'd very much appreciate it.  Thank you :)

Link to comment
Share on other sites

One possible way: you can put all the Send() and Sleep() sequence into a single string by separating them with the + sign and then use Execute () to execute that string of commands; something like this for example:

HotKeySet("{Esc}", "Bye")
HotKeySet("{PAUSE}", "captureMyKey")

Global $Cata = 'Send("{2 down}") + Send("{5 down}") + sleep(100) + Send("{2 up}") + Send("{5 up}") + sleep(2500)'

While Not GUIGetMsg()
WEnd

Func captureMyKey()
    Execute($Cata)
EndFunc   ;==>captureMyKey

Func Bye()
    Exit
EndFunc   ;==>Bye

 

Edited by Chimp
function name correction

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

  • Moderators

@Jakew626 We generally frown on any kind of game automation in this forum, as stated in our forum rules. Please read them and ensure you are following them. For the time being, I will let the thread run so long as it keeps to this general subject only:

21 hours ago, Jakew626 said:

I've made a few scripts over 5000 lines of code and getting hard to find spots that I made an error with that many lines. I know there has so be a some way to shorten those key press commands but I just cant figure.

If it delves into anything game related, it will be locked.

Also, to the person that reported the thread, please review the following posts/threads. It is not your job to "draw it out of" anyone. If you believe a thread is questionable, then report it and move on, please.

1. 

2. 

 

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Another approach is to use a function that combines send key and sleep ie..

_key_slp("keys ",2000)

Func _key_slp($k,$s=0)
    Send($k)
    Sleep($s)
EndFunc

If you use sleep a lot could cut down quite a bit on the number of lines.  Remapping the controller sounds challenging, good luck and don't forget to enjoy the process.

Link to comment
Share on other sites

  • 2 weeks later...

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...