Jump to content

Loop Stop error


OneTime!
 Share

Recommended Posts

Hia folks :P

First day here, trying to understand Auto-it and so far I think Im doing pretty well at it :nuke:

Created my first script and I'm having a lil bit of trouble actually topping the loop.

I know it's super easy but it's 2am , I'm a lil tired and I would like your help/input. Meanwhile you answer my topic I will be busy trying to see if I can get it to stop myself (back to help/syntax files :"> )

Thank you and heres the code :

While 1
HotKeySet("+!x", "terminate")
WinActivate("SwgClient")
Opt("MouseCoordMode", 2)
MouseClick("Left", 622, 347, 2, 50)
Opt("MouseClickDelay", 250)
MouseClick("Left", 622, 347, 2, 50)
Opt("MouseClickDelay", 250)
MouseClick("Left", 622, 347, 2, 50)
Opt("MouseClickDelay", 250)
MouseClick("Left", 622, 347, 2, 50)
Opt("MouseClickDelay", 250)
WEnd
Func terminate()
    Exit 0
    EndFunc
Link to comment
Share on other sites

coudl this be it ? forgot to use ControlSend() and/or Send() ??

When you set a hotkey, AutoIt captures the key-press and does not pass it on to the active application, with one exception: the Lock keys (NumLock, CapsLock, and ScrollLock) still toggle their respective state!

To Send() a key combination which will trigger a HotKeySet() event, either use ControlSend() or unregister the HotKeySet() event, otherwise, the Send() event may trigger an infinite loop.

; capture and pass along a keypress

HotKeySet("{Esc}", "captureEsc")

Func captureEsc()

; ... can do stuff here

HotKeySet("{Esc}")

Send("{Esc}")

HotKeySet("{Esc}", "captureEsc")

EndFunc

P.S. Did I mention it's my first time using AutoIt ? :P :">

Link to comment
Share on other sites

  • Moderators

In your function, you can kill it and reacivate it.

HotKeySet('s', 'Sends')

While 1
    Sleep(1000)
WEnd

Func Sends()
    HotKeySet('s', '');kill it
    Send('s')
   ;Do Something
    HotKeySet('s', 'Sends');reactivate it
EndFunc
Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

I don't know what you're trying to do either, but I think you ought to replace those "Opt("MouseClickDelay", 250)"s with "sleep(250)". Besides, the Opt command only needs to be run once, at the top of the script.

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Link to comment
Share on other sites

  • Moderators

LOL, well I took the fact that he mentioned an endless loop, and he doesn't have a loop in what he showed, that he is using Send('s') in the HotKeySet('s'), so it keeps repeating itself over and over.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

I'm confused in what exactly you're trying to do, so can you explain step by step what

you want your script to do ? Also, it might help if you mention what application you are

trying to work with..

Just trying to get the hang of it and because I have a game client open, I decided to try a simple mouseclik script to go with it.

Basically I want it to find the Game window, check if its active, and if so run the script (which basically double cliks endlessly till I stop it).

If game window is not active, its supposed to do nothing (working on that line in the code as we speak)

Link to comment
Share on other sites

In your function, you can kill it and reacivate it.

HotKeySet('s', 'Sends')

While 1
    Sleep(1000)
WEnd

Func Sends()
    HotKeySet('s', '');kill it
    Send('s')
  ;Do Something
    HotKeySet('s', 'Sends');reactivate it
EndFunc

Ok so with this added to my code , will "s" activate it and stop it whenever I want it correct ? In the client window ?

If so I will go tweak it right now and see what happens.

Link to comment
Share on other sites

LOL, well I took the fact that he mentioned an endless loop, and he doesn't have a loop in what he showed, that he is using Send('s') in the HotKeySet('s'), so it keeps repeating itself over and over.

The loop is working, and the problem IS that its endless. I will go modify the script based on the new imput and see if I can control it (aka stop it/turn it on ) and post back.

Link to comment
Share on other sites

Ok , I've been playing with WinClose and WinShow, is there a way to leave the script running ONLY in the window specified ? Say if I want to run two separate scripts in two different windows.... ?

Try the control functions

ControlClick()

ControlSend()

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...