Jakew626 Posted April 12, 2021 Share Posted April 12, 2021 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 More sharing options...
pseakins Posted April 12, 2021 Share Posted April 12, 2021 Oh fun! What game is this for? Phil Seakins Link to comment Share on other sites More sharing options...
Jakew626 Posted April 12, 2021 Author Share Posted April 12, 2021 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 More sharing options...
Gianni Posted April 12, 2021 Share Posted April 12, 2021 (edited) 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 April 12, 2021 by Chimp function name correction wolflake 1 Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted April 13, 2021 Moderators Share Posted April 13, 2021 @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. seadoggie01 and Musashi 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 More sharing options...
wolflake Posted April 15, 2021 Share Posted April 15, 2021 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 More sharing options...
Zedna Posted April 15, 2021 Share Posted April 15, 2021 My version: ... Send25() ... Send25() ... Func Send25() Send("{2 down}{5 down}") Sleep(100) Send("{2 up}{5 up}") Sleep(2500) EndFunc Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Jakew626 Posted April 25, 2021 Author Share Posted April 25, 2021 Thank you all for your replies :) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now