mc83 Posted March 4, 2007 Posted March 4, 2007 (edited) hey guys.I'm trying to write very basic autoclicker, but i'm rather new to AutoIt (just started using it 6 hours ago), so i made a mistake, but I CAN'T figure out what it is.here is the code, and below it a description of what happensexpandcollapse popup#include <GUIConstants.au3> Opt("GUIOnEventMode", 1) ; Change to OnEvent mode $mainwindow = GUICreate("autoclick", 80, 140, 930, 50,-1,$WS_EX_TOPMOST) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") $startbutton = GUICtrlCreateButton("Start", 10, 10, 60) $pausebutton = GUICtrlCreateButton("Pause", 10, 45, 60) $statuslabel = GuiCtrlCreateLabel("NOT STARTED", 10, 80, 60, 30) GUICtrlSetOnEvent($startbutton, "start") GUICtrlSetOnEvent($pausebutton, "pause") GUISetState(@SW_SHOW) $pause = 0 ;clicker running While 1 Sleep(1000) ; Idle around WEnd Func start() GUICtrlSetData ($statuslabel, "CLICKING") While 1 If not $pause = 1 Then Sleep(5000) MouseClick("left") EndIf WEnd EndFunc Func pause() If $pause = 1 Then $pause = 0 GUICtrlSetData ($pausebutton, "Pause") GUICtrlSetData ($statuslabel, "CLICKING") Else $pause = 1 GUICtrlSetData ($pausebutton, "Resume") GUICtrlSetData ($statuslabel, "PAUSED") EndIf EndFunc Func CLOSEClicked() Exit EndFuncok... the GUI is pretty much self explanatory: the "Start" button should make the program start clicking, the "Pause" button should pause it first time it is clicked, and resume it the next time.the thing is... it doesn't do that. I mean... if i hit the "Pause" button before hitting "Start", it works just fine, no matter how many times i use it (i know that because its caption and the text of the label change the way they are supposed to), but if i hit start first and then try to use "Pause", nothing happens.Can anyone please help? I assume this would not take much time for someone with experience using AutoIt.Thank you Edited March 4, 2007 by mc83
Moderators SmOke_N Posted March 4, 2007 Moderators Posted March 4, 2007 You can try this:expandcollapse popup#include <GUIConstants.au3> Opt("GUIOnEventMode", 1) ; Change to OnEvent mode Global $mainwindow = GUICreate("autoclick", 80, 140, 930, 50,-1,$WS_EX_TOPMOST) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") Global $startbutton = GUICtrlCreateButton("Start", 10, 10, 60) Global $pausebutton = GUICtrlCreateButton("Pause", 10, 45, 60) Global $statuslabel = GuiCtrlCreateLabel("NOT STARTED", 10, 80, 60, 30) GUICtrlSetOnEvent($startbutton, "start") GUICtrlSetOnEvent($pausebutton, "pause") GUISetState(@SW_SHOW) Global $pause, $startit While 1 If $startit Then GUICtrlSetData($statuslabel, "CLICKING") Local $nTimer = TimerInit() While Not $pause If $pause Then ExitLoop If TimerDiff($nTimer) >= 5000 Then $nTimer = TimerInit() MouseClick('right') EndIf Sleep(10) WEnd EndIf Sleep(100) WEnd Func start() $startit = Not $startit EndFunc Func pause() $pause = Not $pause $startit = Not $startit If Not $pause Then GUICtrlSetData ($pausebutton, "Pause") GUICtrlSetData ($statuslabel, "CLICKING") Else GUICtrlSetData ($pausebutton, "Resume") GUICtrlSetData ($statuslabel, "PAUSED") EndIf EndFunc Func CLOSEClicked() Exit EndFuncI "think" it's the result you want. 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.
mc83 Posted March 5, 2007 Author Posted March 5, 2007 thank you SmOke_N, that is exactly what i wanted.i'm starting to really like AutoIt
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now