Jump to content

My 1st script !


Recommended Posts

So ... the problem is i don't know how to bind up the buttons to what they do .... for ex : Button1 = Start/Pause ... to bind it to the hotkey ... the result shoud be Button1 = Send("F1")

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

 AutoIt Version: 3.1.1.0
 Author:         DaiKa7aNa/Trol4ever
 Script Function:
    Template AutoIt script.

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

; Script Start - Add your code below here
Sleep(2000)
Global $Paused
[i][b]#include <GUIConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("2Moons Fishing Bot BETA v0.1", 252, 178, 201, 115)
$Button1 = GUICtrlCreateButton("Start/Pause", 16, 16, 97, 73, 0)
$Button2 = GUICtrlCreateButton("Hide Window", 128, 16, 89, 33, 0)
$Button3 = GUICtrlCreateButton("Show Window", 128, 56, 89, 33, 0)
$Input1 = GUICtrlCreateInput("    Created By DaiKa7aNa@Trol4ever", 16, 96, 201, 21)
$Input2 = GUICtrlCreateInput("F1 = Start/Pause", 16, 120, 97, 21)
$Input3 = GUICtrlCreateInput("F2 = Hide Window", 120, 120, 97, 21)
$Input4 = GUICtrlCreateInput("F3 = Show Window", 64, 144, 113, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###[/b][/i]

[b]While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        
        Case $Button1
        
        
        Case $Button2
    EndSwitch
WEnd[/b]
HotKeySet("{F1}", "Pause")
HotKeySet("{F2}", "Hide")
HotKeySet("{F3}", "Show") 
Func Pause()
$Paused = NOT $Paused
While $Paused
sleep(100)
ToolTip('Script is "Paused"',0,0)
WEnd
ToolTip("")
EndFunc 
Func Hide()
GUISetState(@SW_HIDE)
EndFunc 
Func Show()
GUISetState(@SW_SHOW)
EndFunc
Func Escape()
Exit
EndFunc 
Send("l")
Sleep(1000)
MouseDown("left")
MouseUp("left")
Sleep(500)
MouseDown("left")
Sleep(6500)
MouseUp("left")
Sleep(100)

hope some1 can help me binding them ..

Link to comment
Share on other sites

trol4ever

1. The HotkeySet function must go before the main loop, otherwise the script is not reach these funcs, it always in loop.

2. The functions usually placed in the end of script.

3. Just put the functions into "Case"

Global $Paused
#include <GUIConstants.au3>
HotKeySet("{F1}", "Pause")
HotKeySet("{F2}", "Hide")
HotKeySet("{F3}", "Show") 

$Form1 = GUICreate("2Moons Fishing Bot BETA v0.1", 252, 178, 201, 115)
$Button1 = GUICtrlCreateButton("Start/Pause", 16, 16, 97, 73, 0)
$Button2 = GUICtrlCreateButton("Hide Window", 128, 16, 89, 33, 0)
$Button3 = GUICtrlCreateButton("Show Window", 128, 56, 89, 33, 0)
$Input1 = GUICtrlCreateInput("    Created By DaiKa7aNa@Trol4ever", 16, 96, 201, 21)
$Input2 = GUICtrlCreateInput("F1 = Start/Pause", 16, 120, 97, 21)
$Input3 = GUICtrlCreateInput("F2 = Hide Window", 120, 120, 97, 21)
$Input4 = GUICtrlCreateInput("F3 = Show Window", 64, 144, 113, 21)
GUISetState(@SW_SHOW)

Send("l")
Sleep(1000)
MouseDown("left")
MouseUp("left")
Sleep(500)
MouseDown("left")
Sleep(6500)
MouseUp("left")
Sleep(100)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            Pause()
        Case $Button2
            Hide()
        Case $Button3
            Show()
    EndSwitch
WEnd

Func Pause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc

Func Hide()
    GUISetState(@SW_HIDE)
EndFunc 

Func Show()
    GUISetState(@SW_SHOW)
EndFunc

Func Escape()
    Exit
EndFunc

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

ty for help ... but still [ u fixed my hotkeys ... ]

but now the problem is another ... when i open the script everything is ok ... the script starts paused ... if u push the start button it doesnt start ... if u push the hotkey the program starts but in 2 seconds its paused again ... why ?

Link to comment
Share on other sites

trol4ever

In autoIt there is a usefull Option that work with events - Opt("GuiOnEventMode", 1), in that case, is what i think we need:

#include <GUIConstants.au3>
Opt("GuiOnEventMode", 1)

Global $Paused = 0, $IsHotkey = 0
HotKeySet("{F1}", "PauseByHotKey")
HotKeySet("{F2}", "Hide")
HotKeySet("{F3}", "Show") 

$Form1 = GUICreate("2Moons Fishing Bot BETA v0.1", 252, 178, 201, 115)
$Button1 = GUICtrlCreateButton("Pause", 16, 16, 97, 73, 0)
$Button2 = GUICtrlCreateButton("Hide Window", 128, 16, 89, 33, 0)
$Button3 = GUICtrlCreateButton("Show Window", 128, 56, 89, 33, 0)
$Input1 = GUICtrlCreateInput("    Created By DaiKa7aNa@Trol4ever", 16, 96, 201, 21)
$Input2 = GUICtrlCreateInput("F1 = Start/Pause", 16, 120, 97, 21)
$Input3 = GUICtrlCreateInput("F2 = Hide Window", 120, 120, 97, 21)
$Input4 = GUICtrlCreateInput("F3 = Show Window", 64, 144, 113, 21)

GUISetOnEvent($GUI_EVENT_CLOSE, "Escape")
GUICtrlSetOnEvent($Button1, "Pause")
GUICtrlSetOnEvent($Button2, "Hide")
GUICtrlSetOnEvent($Button3, "Show")

GUISetState(@SW_SHOW)

Pause()

Send("l")
Sleep(1000)
MouseDown("left")
MouseUp("left")
Sleep(500)
MouseDown("left")
Sleep(6500)
MouseUp("left")
Sleep(100)

While 1
   Sleep(100)
WEnd

Func PauseByHotKey()
    If $Paused Then $IsHotkey = 1
    Pause()
EndFunc

Func Pause()
    Opt("GuiOnEventMode", 0)
    GUICtrlSetData($Button1, "Start")
    $Paused = 1
    While $Paused
        Sleep(10)
        $Msg = GUIGetMsg()
        ToolTip('Script is "Paused"',0,0)
        If $Msg = $Button1 Or $IsHotkey = 1 Then ExitLoop
    WEnd
    $IsHotkey = 0
    $Paused = 0
    ToolTip("")
    Opt("GuiOnEventMode", 1)
    GUICtrlSetData($Button1, "Pause")
EndFunc

Func Hide()
    GUISetState(@SW_HIDE)
EndFunc 

Func Show()
    GUISetState(@SW_SHOW)
EndFunc

Func Escape()
    Exit
EndFunc

I have change a litle the way that script works :whistle: - now the Start/Paused name is shown when needed.

What for you need the lines with Send and MouseDown(Up) in the script? what they do?

Edited by MsCreatoR

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

actually this is a normal recorded script to fish in 2Moons Online.

But can u explain me pls what u did in the script ?

and how can i start my script autopaused . .. so i can start it whenever i want?

Edited by trol4ever
Link to comment
Share on other sites

trol4ever

But can u explain me pls what u did in the script ?

Sorry, my english is not wery good, but i try...

In the begining of the script, i put Opt("GuiOnEventMode", 1), this allow to script “know” that the control is defined as event, and then i write the funcs:

GUISetOnEvent($GUI_EVENT_CLOSE, "Escape")

GUICtrlSetOnEvent($Button1, "Pause")

GUICtrlSetOnEvent($Button2, "Hide")

GUICtrlSetOnEvent($Button3, "Show")

Weach is “says” to script that functions will executed when you press some button or use other control.

And the loop itself is just for holding the script runed - the Sleep(100) is nesessary to avoiding CPU load.

The OnEvent funcs is like the HotkeySet functions, it use UDF (User Defined Functions) to complish needed effects (needed actions of the script, etc).

Don't try to understand all concepts at once, it will come to you with time :whistle: (if you continue to learn).

I hope i explain this in way that you understand :">

how can i start my script autopaused

Just after the GUISetState(@SW_SHOW) put the function Pause(), it will execute the pause process after the GUI is shown... (i have change my previous post that you can see how to do it - i just added Pause()).

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

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

  • Recently Browsing   0 members

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