Sign in to follow this  
Followers 0
Gift3d

Simple script, but i need help.

8 posts in this topic

I'm a newbie to autoit, and i've been toying with this script for a few days and i can't get it right.

What it want it to do is whenever i press caps lock, press escape, click the mouse at location 400,240 instantly, and that's it.

The code i'm using is below, it presses escape and clicks at the right spot, but then continues pressing escape so i exit out of everything until it gives me an overflow error.

What i want to do is have it quickly escape click, then stop and not execute any furthermore actions. Then if i press caps lock again, it'll escape+click quickly and so on and so fort, so i can keep using it.

I know it's very simple and i've looked all over, in the f1 help in autoit, but i keep getting the same thing >.<

Thanks in advance for any help!

Global $Paused
HotKeySet("{CAPSLOCK}", "TogglePause")
HotKeySet("{HOME}", "Terminate")

While 1
    Sleep(100)
WEnd

Func TogglePause()
    $Paused = NOT $Paused
        Send ("{esc}")
        MouseClick("left", 400, 240, 2, 0)
        Sleep(5)
EndFunc

Func Terminate()
    Exit 0
EndFunc

Share this post


Link to post
Share on other sites



I'm a newbie to autoit, and i've been toying with this script for a few days and i can't get it right.

What it want it to do is whenever i press caps lock, press escape, click the mouse at location 400,240 instantly, and that's it.

The code i'm using is below, it presses escape and clicks at the right spot, but then continues pressing escape so i exit out of everything until it gives me an overflow error.

What i want to do is have it quickly escape click, then stop and not execute any furthermore actions. Then if i press caps lock again, it'll escape+click quickly and so on and so fort, so i can keep using it.

I know it's very simple and i've looked all over, in the f1 help in autoit, but i keep getting the same thing >.<

Thanks in advance for any help!

Global $Paused
HotKeySet("{CAPSLOCK}", "TogglePause")
HotKeySet("{HOME}", "Terminate")

While 1
    Sleep(100)
WEnd

Func TogglePause()
    $Paused = NOT $Paused
        Send ("{esc}")
        MouseClick("left", 400, 240, 2, 0)
        Sleep(5)
EndFunc

Func Terminate()
    Exit 0
EndFunc
Just for clarity, I would initialize $Paused as 1 or 0 with Global $Paused = 0, or some such, but that is not your problem. Maybe you should try it with a key that does not "lock" the way CapsLock does. Does it work if you use HotKeySet("!p", "TogglePause") instead (Alt + p)?

:D


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Just for clarity, I would initialize $Paused as 1 or 0 with Global $Paused = 0, or some such, but that is not your problem. Maybe you should try it with a key that does not "lock" the way CapsLock does. Does it work if you use HotKeySet("!p", "TogglePause") instead (Alt + p)?

:D

Yes, i've tried to see if that was the problem (tried LSHIFT and F1) but it still keeps looping till i get an overflow error.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Global $Paused = 1
HotKeySet("{CAPSLOCK}", "TogglePause")
HotKeySet("{HOME}", "Terminate")

While 1
    If Not $Paused Then
        Send("{esc}")
        MouseClick("left", 400, 240, 2, 0)
        Sleep(5)
        TogglePause()
    Else
        Sleep(100)
    EndIf
WEnd

Func TogglePause()
    $Paused = Not $Paused
EndFunc   ;==>TogglePause

Func Terminate()
    Exit 0
EndFunc   ;==>Terminate

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Global $Paused = 1
HotKeySet("{CAPSLOCK}", "TogglePause")
HotKeySet("{HOME}", "Terminate")

While 1
    If Not $Paused Then
        Send("{esc}")
        MouseClick("left", 400, 240, 2, 0)
        Sleep(5)
        TogglePause()
    Else
        Sleep(100)
    EndIf
WEnd

Func TogglePause()
    $Paused = Not $Paused
EndFunc   ;==>TogglePause

Func Terminate()
    Exit 0
EndFunc   ;==>Terminate
By my reading (just running it in my head 'cause I'm not on a Windows box right now) that changes the functionality. Oops. Missed the call to TogglePause() inside the loop. :">

P.S. I don't think we have all the code from Gift3d. Per the quote below, he is getting overflows. That's not coming from the snippet we have, is it?

...it still keeps looping till i get an overflow error.

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

By my reading (just running it in my head 'cause I'm not on a Windows box right now) that changes the functionality. I don't think he wants it to repeat the ESC, Click sequence, just do it once per hotkey press. It's not at all clear to me what $Paused is being used for in his original script (if anything), and your version gives it a purpose, but the text description reads as once per press. :D

P.S. I don't think we have all the code from Gift3d. Per the quote below, he is getting overflows. That's not coming from the snippet we have, is it?

That's exactly what it does, once per hotkey press, press CapsLock and it does the sequence and then toggles the pause so it doesn't repeat.

Gary


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

That's exactly what it does, once per hotkey press, press CapsLock and it does the sequence and then toggles the pause so it doesn't repeat.

Gary

Sheepishly noted... :">

Do you see anything in there that could cause an overflow without there being more code involved? Can you get that just from hitting a key repeatedly?

Just taking what he had, removing the unused reference to $Paused, seems it should have worked:

HotKeySet("{CAPSLOCK}", "EscClick")
HotKeySet("{HOME}", "Terminate")

While 1
    Sleep(100)
WEnd

Func EscClick()
    Send ("{esc}")
    MouseClick("left", 400, 240, 2, 0)
    Sleep(5)
EndFunc

Func Terminate()
    Exit 0
EndFunc

:D

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Sheepishly noted... :">

Do you see anything in there that could cause an overflow without there being more code involved? Can you get that just from hitting a key repeatedly?

Couldn't see any reason from the code that was posted.


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

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