Jayden

Script doesnt work and dont know the problem

18 posts in this topic

Dear people on autoit forum!

My name is Jayden and i am making a script that will automatically click. but my script doesnt work can someone help me?

 

Script:

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.14.2
 Author:         myName

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

$looplmb = 1
$looprmb = 1
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <AutoItConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 239, 165, -1, -1)
GUISetBkColor(0x0000FF)
$Label1 = GUICtrlCreateLabel("Label1", 16, 8, 148, 41)
GUICtrlSetBkColor(-1, 0xFFFFFF)
$Combo1 = GUICtrlCreateCombo("", 144, 72, 73, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData($Combo1, "{F1}|{F2}|{F3}|{F4}|{F5}|{F6}|{F7}|{F8}|{F9}|{F10}|{F11}|{F12}", "Choose")
$Label2 = GUICtrlCreateLabel("Hotkey LMB:", 16, 72, 116, 17)
GUICtrlSetBkColor(-1, 0xFFFFFF)
$Button1 = GUICtrlCreateButton("Donate", 176, 8, 51, 33)
$Label3 = GUICtrlCreateLabel("Hotkey RMB:", 16, 104, 116, 17)
GUICtrlSetBkColor(-1, 0xFFFFFF)
$Label4 = GUICtrlCreateLabel("Hotkey Stop:", 16, 136, 116, 17)
GUICtrlSetBkColor(-1, 0xFFFFFF)
$Combo2 = GUICtrlCreateCombo("", 144, 104, 73, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Combo3 = GUICtrlCreateCombo("", 144, 136, 73, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData($Combo2, "{F1}|{F2}|{F3}|{F4}|{F5}|{F6}|{F7}|{F8}|{F9}|{F10}|{F11}|{F12}", "Choose")
GUICtrlSetData($Combo3, "{F1}|{F2}|{F3}|{F4}|{F5}|{F6}|{F7}|{F8}|{F9}|{F10}|{F11}|{F12}", "Choose")
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Combo1
            $ComboRead1 = GUICtrlRead ($Combo1)
        Case $Combo2
            $ComboRead2 = GUICtrlRead ($Combo2)
        Case $Combo3
            $ComboRead3 = GUICtrlRead ($Combo3)
    EndSwitch
WEnd


HotKeySet ($ComboRead1, "LMB")
HotKeySet ($ComboRead2, "RMB")
HotKeySet ($ComboRead3, "Stop")


Func LMB ()
    $looplmb = 0
EndFunc

Func RMB ()
    $looprmb = 0
EndFunc

Func Stop ()
    $looplmb = 1
    $looprmb = 1
EndFunc

While $looplmb = 0
    MouseClick ($MOUSE_CLICK_LEFT)
    Sleep (100)
WEnd

While $looprmb = 0
    MouseClick ($MOUSE_CLICK_RIGHT)
    Sleep (100)
WEnd

 

Share this post


Link to post
Share on other sites



14 minutes ago, Jayden said:

Dear people on autoit forum!

My name is Jayden and i am making a script that will automatically click. but my script doesnt work can someone help me?

Don't you think it would help when you also tell us what exactly the script is supposed to do and what isn't working?

What are you expecting these"never executed as their are outside the While-Went loop" lines to do:?

HotKeySet ($ComboRead1, "LMB")
HotKeySet ($ComboRead2, "RMB")
HotKeySet ($ComboRead3, "Stop")

So...  start explaining what you want your script to do. ;)

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

36 minutes ago, Jos said:

Don't you think it would help when you also tell us what exactly the script is supposed to do and what isn't working?

What are you expecting these"never executed as their are outside the While-Went loop" lines to do:?

HotKeySet ($ComboRead1, "LMB")
HotKeySet ($ComboRead2, "RMB")
HotKeySet ($ComboRead3, "Stop")

So...  start explaining what you want your script to do. ;)

Jos

Thanks for your fast reply. I want that if hotkey is pressed that there is going to be a loop that it wil click automatic and if hotkey stop is pressed the loop will stop . and it didnt click thats what happend

 

Edited by Jayden
forgot smth

Share this post


Link to post
Share on other sites

Did you have a look at the help file? The examples for HotKeySet exactly explain how to start/stop a function using a Hotkey.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

As stated already: the HotKey's are never set with those 3 lines. Change that so they are set when pressing the combo control where you do the GuiCtrlRead().

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

2 hours ago, Jos said:

As stated already: the HotKey's are never set with those 3 lines. Change that so they are set when pressing the combo control where you do the GuiCtrlRead().

Jos

Thanks but it still didnt work. or do I need to add a button "Save" and then if it is pressed that the combos are read and hotkeys are set?

 

Edited by Jayden

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Sweet ... guess you made an error then ;)

Jos

ps:I assume you didn't want any real answer as you didn't share any useful information like the current script.

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.14.2
 Author:         myName

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

$looplmb = 1
$looprmb = 1
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <AutoItConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 239, 165, -1, -1)
GUISetBkColor(0x0000FF)
$Label1 = GUICtrlCreateLabel("Label1", 16, 8, 148, 41)
GUICtrlSetBkColor(-1, 0xFFFFFF)
$Combo1 = GUICtrlCreateCombo("", 144, 72, 73, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData($Combo1, "{F1}|{F2}|{F3}|{F4}|{F5}|{F6}|{F7}|{F8}|{F9}|{F10}|{F11}|{F12}", "Choose")
$Label2 = GUICtrlCreateLabel("Hotkey LMB:", 16, 72, 116, 17)
GUICtrlSetBkColor(-1, 0xFFFFFF)
$Button1 = GUICtrlCreateButton("Donate", 176, 8, 51, 33)
$Label3 = GUICtrlCreateLabel("Hotkey RMB:", 16, 104, 116, 17)
GUICtrlSetBkColor(-1, 0xFFFFFF)
$Label4 = GUICtrlCreateLabel("Hotkey Stop:", 16, 136, 116, 17)
GUICtrlSetBkColor(-1, 0xFFFFFF)
$Combo2 = GUICtrlCreateCombo("", 144, 104, 73, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Combo3 = GUICtrlCreateCombo("", 144, 136, 73, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData($Combo2, "{F1}|{F2}|{F3}|{F4}|{F5}|{F6}|{F7}|{F8}|{F9}|{F10}|{F11}|{F12}", "Choose")
GUICtrlSetData($Combo3, "{F1}|{F2}|{F3}|{F4}|{F5}|{F6}|{F7}|{F8}|{F9}|{F10}|{F11}|{F12}", "Choose")
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Combo1
            $ComboRead1 = GUICtrlRead ($Combo1)
            HotKeySet ($ComboRead1, "LMB")
        Case $Combo2
            $ComboRead2 = GUICtrlRead ($Combo2)
            HotKeySet ($ComboRead2, "RMB")
        Case $Combo3
            $ComboRead3 = GUICtrlRead ($Combo3)
            HotKeySet ($ComboRead3, "Stop")
    EndSwitch
WEnd


Func LMB ()
    $looplmb = 0
EndFunc

Func RMB ()
    $looprmb = 0
EndFunc

Func Stop ()
    $looplmb = 1
    $looprmb = 1
EndFunc

While $looplmb = 0
    MouseClick ($MOUSE_CLICK_LEFT)
    Sleep (100)
WEnd

While $looprmb = 0
    MouseClick ($MOUSE_CLICK_RIGHT)
    Sleep (100)
WEnd

you reply fast i was just copying it but this is current ^^

 

Edited by Jayden

Share this post


Link to post
Share on other sites

Works fine for me. I added an ConsoleWrite() to the 3 Funcs for testing; started the script, select an F? for each task and hit those 3 F? keys.
They all showed the proper ConsoleWrite() output, so it is working as designed.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

1 minute ago, Jos said:

Works fine for me. I added an ConsoleWrite() to the 3 Funcs for testing; started the script, select an F? for each task and hit those 3 F? keys.
They all showed the proper ConsoleWrite() output, so it is working as designed.

Jos

^what is the consolewrite thing? and did it also click?

 

Edited by Jayden

Share this post


Link to post
Share on other sites

#11 ·  Posted

because the only thing that doesnt work is that it is not clicking or it didnt catch the hotkey

 

Share this post


Link to post
Share on other sites

#12 ·  Posted

 Example:

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.14.2
 Author:         myName

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

$looplmb = 1
$looprmb = 1
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <AutoItConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 239, 165, -1, -1)
GUISetBkColor(0x0000FF)
$Label1 = GUICtrlCreateLabel("Label1", 16, 8, 148, 41)
GUICtrlSetBkColor(-1, 0xFFFFFF)
$Combo1 = GUICtrlCreateCombo("", 144, 72, 73, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData($Combo1, "{F1}|{F2}|{F3}|{F4}|{F5}|{F6}|{F7}|{F8}|{F9}|{F10}|{F11}|{F12}", "Choose")
$Label2 = GUICtrlCreateLabel("Hotkey LMB:", 16, 72, 116, 17)
GUICtrlSetBkColor(-1, 0xFFFFFF)
$Button1 = GUICtrlCreateButton("Donate", 176, 8, 51, 33)
$Label3 = GUICtrlCreateLabel("Hotkey RMB:", 16, 104, 116, 17)
GUICtrlSetBkColor(-1, 0xFFFFFF)
$Label4 = GUICtrlCreateLabel("Hotkey Stop:", 16, 136, 116, 17)
GUICtrlSetBkColor(-1, 0xFFFFFF)
$Combo2 = GUICtrlCreateCombo("", 144, 104, 73, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Combo3 = GUICtrlCreateCombo("", 144, 136, 73, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData($Combo2, "{F1}|{F2}|{F3}|{F4}|{F5}|{F6}|{F7}|{F8}|{F9}|{F10}|{F11}|{F12}", "Choose")
GUICtrlSetData($Combo3, "{F1}|{F2}|{F3}|{F4}|{F5}|{F6}|{F7}|{F8}|{F9}|{F10}|{F11}|{F12}", "Choose")
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Combo1
            $ComboRead1 = GUICtrlRead ($Combo1)
            HotKeySet ($ComboRead1, "LMB")
        Case $Combo2
            $ComboRead2 = GUICtrlRead ($Combo2)
            HotKeySet ($ComboRead2, "RMB")
        Case $Combo3
            $ComboRead3 = GUICtrlRead ($Combo3)
            HotKeySet ($ComboRead3, "Stop")
    EndSwitch
WEnd


Func LMB ()
    $looplmb = 0
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $looplmb = ' & $looplmb & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
EndFunc

Func RMB ()
    $looprmb = 0
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $looprmb = ' & $looprmb & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
EndFunc

Func Stop ()
    $looplmb = 1
    $looprmb = 1
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $looprmb = ' & $looprmb & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
EndFunc

What are those 2 While-Wend loops supposed to do at  the end of the Script? You do realise that portion of the script is never run ...right?

Jos

 


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#13 ·  Posted

these are the clicking part if looplmb = 0 it will click and if it is 1 it wont i read it somewhere but is that the part that doesnt work?

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Understand and that should be pretty clear that is NEVER ran as it is outside of the initial endless loop.

So, what is this script really supposed to do?  

Jos

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

it needs to click every 100 ms and if the stop key is clicked it needs to be stopped.

Edited by Jayden

Share this post


Link to post
Share on other sites

#17 ·  Posted

Im not going to use it for that its more for a practise I dont know what to make in autoit and I want to beat my friends with clicking we always bet who can click the best. (so little bit a game)

Share this post


Link to post
Share on other sites

#18 ·  Posted

Yea right ...  let me point you to the Forum rules so we are sure you know them and I will close this topic as you have been informed on the issue you have.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.