Jump to content
Sign in to follow this  
korunks

Having trouble with script

Recommended Posts

I am trying to get a program that will.

run

upon the typing of ctrl-s (^s) run an infinite loop that

every five seconds will send to a program Ctrl-x(^x)

and upon entering ctrl-a(^a) will exit the loop and program.

any one want to help?

Share this post


Link to post
Share on other sites

I am trying to get a program that will.

run

upon the typing of ctrl-s (^s) run an infinite loop that

every five seconds will send to a program Ctrl-x(^x)

and upon entering ctrl-a(^a) will exit the loop and program.

any one want to help?

Hey Korunks,

I think what you want to do is look at the HotKey Function in the Help File. With this function you can set keys (such as Ctrl+s) which when pressed start a function within a script. As for your Ctrl+x I think you just need to use the Send ^x) command and then put a Sleep(5000) between it. Again, your hotkey could be used to exit the program. So I've had a quick stab and I would put something like this:-

Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("^a", "Terminate")
HotKeySet("+!d", "ShowMessage")

Func One()
While 1
      Send(^x)
      Sleep(5000)
WEnd
EndFunc

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

Share this post


Link to post
Share on other sites

@locutus243,

Try running your code :-)

... but like you said, it was a quick stab.

@korunks,

Welcome to the forums.

Perhaps this will work for you:

HotKeySet("^s", "Start")
HotKeySet("^a", "Stop")

While 1
    Sleep(100)
WEnd

Func Start()
    While 1
       ;WinActivate("Untitled - Notepad")
       ;WinWaitActive("Untitled - Notepad")
        Send("^x")
        Sleep(5000)
    WEnd
EndFunc

Func Stop()
    Exit
EndFunc
The two lines of code that mention Notepad are commented out using the ";" character. You can run the code as is and these two lines will have no impact. However, I would suggest that you use the AutoIt Window Info Tool and copy/paste the exact title of the window that you want the Ctrl-x to be sent to... just paste it over the Untitled - Notepad part of each of those two lines of code. Then remove the ";" from the start of the each of those two lines of code.

enjoy....


[size="1"][font="Arial"].[u].[/u][/font][/size]

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...