Author Topic: stop execution by pressing the same key  (Read 3732 times)

grumpelstielzchen

  • Guest
stop execution by pressing the same key
« on: September 01, 2019, 07:25:14 AM »
hello there.

first of all thanks for this amazing application!! I use it for my simulations (rfactor 2 and elite dangerous).

Here's my question:

Is there a command wich says likely "execute until the key is pressed twice"?
Or to be more precise; am I able to stop a command wich is repeating continously by pressing the same button wich is used to start execute the command?


Do you get me?  ;D

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: stop execution by pressing the same key
« Reply #1 on: September 01, 2019, 11:15:54 PM »
That can be achieved using something like
Code: [Select]
Begin Boolean Compare : [>{CMDWHENISAY}running] Equals True
    Set Boolean [>{CMDWHENISAY}running] to False
End Condition - Exit when condition met
Set Boolean [>{CMDWHENISAY}running] to True
Start Loop While : [>{CMDWHENISAY}running] Equals True
    Write [Blue] 'Command running' to log
    Pause 1 second
End Loop
Write [Blue] 'Command stopped' to log

"Allow other commands to execute while this one is running" and "Evaluate 'Not Set' as false" (for the condition and the loop) should be checked.

Note that as with any loop, the condition is checked only when the actions within the loop are finished.
With the 1 second delay in this example, it can take up to one second for the command to write "Command stopped" to the log.
« Last Edit: September 03, 2019, 04:08:26 AM by Pfeil »

grumpelstielzchen

  • Guest
Re: stop execution by pressing the same key
« Reply #2 on: September 02, 2019, 01:15:00 PM »
Hey Pfeil. Thank you for your reply. I'll give it a try. Hopefully I understand it and get it right.
In case of another question...your nickname sounds german to me. Is that right? So can we talk in german via pm?

Edit:

Thank you so mutch! It works very well!! It did take some time to understand what to write in the command. But finally I get it!

For all who'd like to do it the same way, look at the screenshots below. Note: the B-key is binded to "toggle pit limiter" and the L-key is for "toggle headlights" in the simulation (rfactor 2)








« Last Edit: September 03, 2019, 06:08:28 AM by grumpelstielzchen »

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: stop execution by pressing the same key
« Reply #3 on: September 02, 2019, 10:18:10 PM »
your nickname sounds german to me. Is that right? So can we talk in german via pm?
It is, but I'm not. I also prefer using public topics, so others may learn from the discussion.

PS: Can you tell me how to add pictures in here, to show it to other noobs like me?
You can attach them to your post if you expand the "Attachments and other options" section below the text field and click the "Browse..." button to select a file (you can click "more attachments" to add up to six attachments in this manner), and they'll be uploaded when you submit your post.

grumpelstielzchen

  • Guest
Re: stop execution by pressing the same key
« Reply #4 on: September 03, 2019, 04:00:49 AM »
Thanks again! I edited my post.

Maybe some guys find it useful too!?

Is it okay to link this thread in another thread on a different forum? I'd like to link it in the s397 forum. This is the official forum of the developer of this sim.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: stop execution by pressing the same key
« Reply #5 on: September 03, 2019, 04:02:59 AM »
This is a publicly available forum, so there's nothing stopping you.


I would like to note that my example (which I now modified to use the ">" prefix rather than the ">>" prefix, as the command would be stopped when switching profiles anyway) uses the "{CMDWHENISAY}" token to make the variable name unique automatically, E.G. in your case the variable would have been named ">Pit Limiter onrunning".
This enables you to copy and paste everything but the actions within the loop (assuming those are unique per command), without having to worry about manually changing the variable name.


Also, I was under the impression attachments are publicly visible, but it appears they are not. You'll want to upload your screenshots to an image host (I usually just go with imgur), then use img tags to display them in your post.

grumpelstielzchen

  • Guest
Re: stop execution by pressing the same key
« Reply #6 on: September 03, 2019, 06:24:55 AM »
okay...I hope the screenshots are visible now.

I have to check the first part of your reply. I don't get it yet because I´m a very noob in programming. So for now it works very well for me how I created the command. Actually I only use two profiles. The profile for Elite Dangerous don't need commands like the one for my racing simulation.
So I'll check your suggestion later if I'm more into programming macros in voice attack.

Thank you so far!