Jump to content
Sign in to follow this  
lucario

Simple Program Help

Recommended Posts

lucario

Hi, i have this script, all it does is:

Click a certain area on screen the move to another area and click multiple times.

ive tried using HotKeySet but cant seem to get it to work.

I want it so it clicks, moves, clicks the multiple times, but have a hotkey to stop the clicking then another one to start the clicking again.

anyone help??? Thanks

HotKeySet("+!d", "End")

MouseClick("left", 915, 161, 1);

MouseClick( "left", 738, 186, 300, 100);

Func End()

Exit 0

EndFunc

Share this post


Link to post
Share on other sites
Authenticity

What's not working? the script that terminating immediately or the function "End". Anyway, as I see, it's the you don't have any loop to hold this program running, example:

While 1
   MouseClick("left", 915, 161, 1);
   MouseClick( "left", 738, 186, 300, 100);
   Sleep(50) ; To not spike your processor.
WEnd

Share this post


Link to post
Share on other sites
lucario

it runs the clicks but when i use the hotkeys, they dont pause the script. and i probally need something to start the script once its paused.

Share this post


Link to post
Share on other sites
Authenticity

You need a flag to "stop" or "resume" the script execution of these 3 line of code of the earlier loop:

HotKeySet("+!d", "End")
Dim $fStop = False
.
.
.

Func End()
    $fStop = Not $fStop

    While $fStop
        Sleep(20) ; A good habit.
    WEnd
EndFunc

The first time this function is entered the $fStop variable is set to true so it'll start loop and do nothing but sleep. The next time this function is entered $fStop is set again to False and so this loop won't get executed (same for the earlier loop that have started).

Share this post


Link to post
Share on other sites
lucario

Still cant seem to get it working. here is what i have:

HotKeySet("+!d", "End")
HotKeySet("+!g", "Go")
Dim $fStop = False
Func End()
    $fStop = Not $fStop

    While $fStop
        Sleep(20); A good habit.
    WEnd
EndFunc
Func Go()
While 1
        MouseMove(917,161,1);
        MouseClick("left");
        MouseMove(738,186,1);
        MouseClick( "left",738,186,300);
        Sleep(300); To not spike your processor.
    WEnd
EndFunc

Share this post


Link to post
Share on other sites
lucario

if it helps, you could change the hotkeys to something more suitable

Share this post


Link to post
Share on other sites
Authenticity

; O.K.
HotKeySet("+!d", "End")
HotKeySet("+!g", "Go")
HotKeySet("{ESC}", "_EXIT")

Dim $fStop = False
Go()



Func End()
    $fStop = Not $fStop
    ToolTip('"Not running"', 0, 0)
    While $fStop
        Sleep(20)
    WEnd
    ToolTip('"Running"', 0, 0)
EndFunc


Func Go()
    ToolTip('"Running"', 0, 0)
    While 1
        ;MouseMove(917,161,1)
        ;MouseClick("left")
        ;MouseMove(738,186,1)
        ;MouseClick( "left",738,186,300)
        
        Sleep(30)
    WEnd
EndFunc


Func _EXIT()
    Exit
EndFunc

It's ok, it'll get better as time passes. ;]

Share this post


Link to post
Share on other sites
SpookMeister

HotKeySet("{F6}", "Toggle")
$i_toggle = 0
While 1
    Sleep(100) ; always a good idea so you dont max your cpu
    While $i_toggle
        ToolTip("Running")
    WEnd
    ToolTip("")
WEnd

Func Toggle()
    $i_toggle = Not $i_toggle
EndFunc ;==>


[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Share this post


Link to post
Share on other sites
lucario

The hotkeys are working. I know this because the Tooltip changes when i push them. but now the clicks wont work when you hit "Shift+Alt+G". So there seems to be a problem there. any ideas?

Share this post


Link to post
Share on other sites
Authenticity

Three hundreds clicks on the same spot, mm... interesting. So what you believe is not working? the move part? the clicks?

Share this post


Link to post
Share on other sites
lucario

I dont know what i did, but its actually working :-s

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.