Sign in to follow this  
Followers 0
m0nster

Execute One Function While Another Is Running?

6 posts in this topic

Hello,

I'm new to AutoIt, or any programming language for that matter, and I have a small issue where I want to set a hotkey to emulate 100 key presses, but also be able to hit a seperate hotkey to stop it at anytime while it's doing so. I already tried, but failed.

Is this possible? Or could it possibly be an error in my coding?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hello,

I'm new to AutoIt, or any programming language for that matter, and I have a small issue where I want to set a hotkey to emulate 100 key presses, but also be able to hit a seperate hotkey to stop it at anytime while it's doing so. I already tried, but failed.

Is this possible? Or could it possibly be an error in my coding?

Hi & welcome,

that should be possible. Please show what you've got so far. Then it is much easier to help at the right point.

So long,

Mega

Edited by th.meger

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

well yes it is possible just have it call one function to start all the key press and then another hotkey to go to a pause function... cant whip you up an example cuz i got to go to school :think:

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Well, I tried that method, but it didn't work, so I made another hotkey/function to terminate (exit) the script along with the main function that repeats the key 100 times. While it was repeating, I tried the hotkey to terminate the script, but it didn't work. So, that made me think it wasn't possible. I'll give it another look over when I get back to school and post the source if I still haven't debugged it.

Thanks guys!

Edited by m0nster

Share this post


Link to post
Share on other sites

maybe

; Press Esc to terminate script, Pause/Break to "pause"

Global $Paused
HotKeySet("{PAUSE}", "TogglePause");  to send the z's
HotKeySet("{ESC}", "Terminate")
HotKeySet("+!d", "ShowMessage");Shift-Alt-d

;;;; Body of program would go here;;;;
While 1
    Sleep(100)
WEnd
;;;;;;;;

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Running"',0,0)
Send("{Z}")
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    Exit 0
EndFunc

Func ShowMessage()
    MsgBox(4096,"thanks...",",,, Valuater.", 2)
EndFunc

sends z until paused or exited

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Algorithm: Define both your hotkeys. Put the key press inside a loop that is processed 100 times and the loop is exited early if the other key is pressed.

Post what you have so far - you may already have a working script with just a typo, or you may have the logic wrong. We cannot tell without looking at it.

The help file is your friend.

Edited by Confuzzled

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0