Jump to content

Question about pausing script and send keys


Guest tmcradnet
 Share

Recommended Posts

Guest tmcradnet

Ok so I posted a question a while back pertaining to Caps Lock and the send function and I guess it looks like a glitch in AutoIt. Effectivly this code will send whatever key the user presses so long as the user is not in a specific app (in this case freecell) which the code will do some function (in this case create a message box). The code works great except for Caps Lock the send command sends keystrokes irregardless of caps lock being pressed or not. It was suggested to pause the script when my chosen app is not being ran (therefor sending the key through windows) and then restarting the scripts once the chosen app becomes active however I was not able to figure out code that could both pause the script and restart the script without trunkating a key stroke (effectivly if the user presses "i" the first "i" is spent turning the script off).

heres the link to the old post http://www.autoitscript.com/forum/index.ph...93&hl=caps+lock

Any suggestions?

Thanks

HotKeySet("i", "FunOne")


While 1
    Sleep(100)
WEnd



Func FunOne()
If WinActive("FreeCell") Then
        MsgBox(4096, "MenuBox", "You are in FreeCell", 10)

    Else
            HotKeySet("i")
            Send("i")
            HotKeySet("i", "FunOne")

    Endif
Endfunc
Edited by tmcradnet
Link to comment
Share on other sites

You could do something like this:

local $win = "FreeCell"

func myFunc()

...

endFunc

while 1

winWaitActive($win)

; activate hotkey

hotkeySet("i", "myFunc")

winWaitNotActive($win)

; deactivate hotkey

hotkeySet("i")

wEnd
Link to comment
Share on other sites

straight from help

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

Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
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 "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    Exit 0
EndFunc

Func ShowMessage()
    MsgBox(4096,"","This is a message.")
EndFunc

8)

NEWHeader1.png

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...