Jump to content

Script doesnt work and dont know the problem


Jayden
 Share

Recommended Posts

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

 

Link to comment
Share on other sites

  • Developers
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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

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
Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

#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
Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • Developers

 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

 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Jos locked this topic
Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...