Jump to content

Case $msg = $MenuExit


Recommended Posts

I am using a Menu Bar at the top of my GUI like File Edit ect. But For some reason none of the things are working. My Exit in the File drop Down is $MenuExit, however when I ...

Case $msg = $MenuExit
            Exit

It does not work when I click Exit in the File Drop Down.

Any Help would be appreciated. :)

I am also posting this in the GUI Help section because I dont know exactly where this fits.

Edited by inline853
Link to comment
Share on other sites

  • Moderators

I am using a Menu Bar at the top of my GUI like File Edit ect. But For some reason none of the things are working. My Exit in the File drop Down is $MenuExit, however when I ...

Case $msg = $MenuExit
            Exit

It does not work when I click Exit in the File Drop Down.

Any Help would be appreciated. :)

I am also posting this in the GUI Help section because I dont know exactly where this fits.

Write a demonstration script that replicates the issue. No one can give you an "factual" answer without seeing what you did to create the menu to begin with.

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.

Link to comment
Share on other sites

I am using a Menu Bar at the top of my GUI like File Edit ect. But For some reason none of the things are working. My Exit in the File drop Down is $MenuExit, however when I ...

Case $msg = $MenuExit
            Exit

It does not work when I click Exit in the File Drop Down.

Any Help would be appreciated. :)

I am also posting this in the GUI Help section because I dont know exactly where this fits.

If you press Esc this will exit and restart the script:

HotKeySet("{ESC}", "Restart")

;Restart the script

Func Restart()

Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & @ScriptFullPath & '" /restart')

Exit

EndFunc ;==>Restart

Or alternatively

CODE

GUICreate("Processor", 500, 285, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$exitbutton = GUICtrlCreateButton("Exit", 170, 225, 85, 25)

GUISetState()

While 1

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE Or $msg = $exitbutton

GUIDelete()

Exit

EndSelect

WEnd

Ant..
Link to comment
Share on other sites

Okay here is the script ... It is incomplete, but the Exit Menu Part is done enough to work.

#NoTrayIcon
#include <GUIConstants.au3>
#include <Misc.au3>

Opt("GUIOnEventMode", 1)

#Region ;GLOBALS
Global $CurrentColor = "9003840" ;<== Sets the Current Color to a HEX or RBG Color Code
Global $CurrentDropColor = "0xDE7D37" ;<== Sets the Current Drop Color to a HEX or RBG Color Code
Global $DropColor = $CurrentDropColor ;<== Sets the Drop Color to the Current Drop Color
Global $StartX = IniRead("MineData.ini", "Pos", "X",0) ;<== Reads a Default Starting X Coordinate for the Ore Finder from an .Ini file.
Global $StartY = IniRead("MineData.ini", "Pos", "Y",0) ;<== ;<== Reads a Default Starting Y Coordinate for the Ore Finder from an .Ini file.
Global $smallStartX = IniRead("MineData.ini", "DropPos", "X",0) ;<== Reads a Default Starting X Coordinate for the Drop Finder from an .Ini file.
Global $smallStartY = IniRead("MineData.ini", "DropPos", "Y",0) ;<== Reads a Default Starting Y Coordinate for the Drop Finder from an .Ini file.
Global $x = $StartX, $y = $StartY ;<== Sets $x to $StartX so $x can later be manipulated.
Global $smallx = $smallStartX, $smally = $smallStartY ;<== Sets $x to $StartX so $x can later be manipulated.
Global $ScanWidth = 110, $ScanHeight = 45 ;<== Sets the Scan Width and Height for the Ore Finder.
Global $SmallScanWidth = 40, $SmallScanHeight = 40 ;<== Sets the Scan Width and Height for the Drop Finder.
Global $T1[5],$T2[5] ;<== Creates the Array Storage for the Check Interval and Mining Interval time Values.
Global $SleepCheck = 500, $SleepMine = 6000, $SleepDrop = 1500  ;<== Sets Sleep() time variables for the Check, Mining, and Dropping Functions.
Global $Idle = 0 ;<== Sets Idle to 0
Global $MoveMode = True ;<== Sets $MoveMode to True
Global $SmallMoveMode = True  ;<== Sets $smallMoveMode to True
Global $AppTitle = "RS - HYBERMINER" ;<== Sets the Application Title to "RS - HYBERMINER"
Global $ColorClay = IniRead("MineData.ini", "Colors", "Clay", "?") ;<== Reads the Color for Clay for the Ore Finder.
Global $ColorCopper = IniRead("MineData.ini", "Colors", "Copper", 9003840) ;<== Reads the Color for Copper for the Ore Finder.
Global $ColorTin = IniRead("MineData.ini", "Colors", "Tin", 7432553);<== Reads the Color for Tin for the Ore Finder.
Global $ColorIron = IniRead("MineData.ini", "Colors", "Iron", 4072732);<== Reads the Color for Iron for the Ore Finder.
Global $ColorSilver = IniRead("MineData.ini", "Colors", "Silver", 16777215);<== Reads the Silver for Clay for the Ore Finder.
Global $ColorCoal = IniRead("MineData.ini", "Colors", "Coal", 3815975) ;<== Reads the Color for Coal for the Ore Finder.
Global $ColorGold = IniRead("MineData.ini", "Colors", "Gold", 10193720) ;<== Reads the Color for Gold for the Ore Finder.
Global $ColorMithril = IniRead("MineData.ini", "Colors", "Mithril", 5329529) ;<== Reads the Color for Mithril for the Ore Finder.
Global $ColorAddy = IniRead("MineData.ini", "Colors", "Addy", "?") ;<== Reads the Color for Adamantite for the Ore Finder.
Global $ColorRunite = IniRead("MineData.ini", "Colors", "Runite", "?") ;<== Reads the Color for Runite for the Ore Finder.
Global $DropColorClay = IniRead("MineData.ini", "DropColors", "Clay", "?") ;<== Reads the Color for Clay for the Drop Finder.
Global $DropColorCopper = IniRead("MineData.ini", "DropColors", "Copper", 0xDF813B) ;<== Reads the Color for Copper for the Drop Finder.
Global $DropColorTin = IniRead("MineData.ini", "DropColors", "Tin", 0x8C8284) ;<== Reads the Color for Tin for the Drop Finder.
Global $DropColorIron = IniRead("MineData.ini", "DropColors", "Iron", 0x321F17) ;<== Reads the Color for Iron for the Drop Finder.
Global $DropColorSilver = IniRead("MineData.ini", "DropColors", "Silver", 0xB2B2BB) ;<== Reads the Color for Silver for the Drop Finder.
Global $DropColorCoal = IniRead("MineData.ini", "DropColors", "Coal", 0x3B3B27) ;<== Reads the Color for Coal for the Drop Finder.
Global $DropColorGold = IniRead("MineData.ini", "DropColors", "Gold", 0x977B11) ;<== Reads the Color for Gold for the Drop Finder.
Global $DropColorMithril = IniRead("MineData.ini", "DropColors", "Mithril", 0x48496B) ;<== Reads the Color for Mithril for the Drop Finder.
Global $DropColorAddy = IniRead("MineData.ini", "DropColors", "Addy", 0x4E634F) ;<== Reads the Color for Adamantite for the Drop Finder.
Global $DropColorRunite = IniRead("MineData.ini", "DropColors", "Runite", 0x4C6A74) ;<== Reads the Color for Runite for the Drop Finder.
Global $Sens = IniRead("MineData.ini", "Beta", "Sensitifity", 8) ;<== Reads the Sensitivity for the Color Dedtection from and .Ini file.
Global $AverageX, $AverageY, $i ;<== Initializes the variables $AverageX, $AverageY, and $i

;Draws the Top of the Drop Finder Box
$smallTop = GUICreate("Top Line", $smallScanWidth, 2,$smallx,$smally + 40,$WS_POPUP,-1)
GUISetBkColor(0xFF0000)
GUISetState()

;Draws the Left Side of the Drop Finder Box
$smallLeft = GUICreate("Left Line", 2, $smallScanHeight,$smallx,$smally + 40,$WS_POPUP,-1)
GUISetBkColor(0xFF0000)
GUISetState()

;Draws the Right Side of the Drop Finder Box
$smallRight = GUICreate("Right Line", 2, $smallScanHeight,$smallx + $smallScanWidth - 2,$smally + 40,$WS_POPUP,-1)
GUISetBkColor(0xFF0000)
GUISetState()

;Draws the Bottom of the Drop Finder Box
$smallBottom = GUICreate("Bottom Line", $smallScanWidth, 2,$smallx,$smally + 40 + $smallScanHeight,$WS_POPUP,-1)
GUISetBkColor(0xFF0000)
GUISetState()

;Draws the Top of the Ore Finder Box
$Top = GUICreate("Top Line", $ScanWidth, 2,$x,$y + 40,$WS_POPUP,-1)
GUISetBkColor(0xFF0000)
GUISetState()

;Draws the Left Side of the Ore Finder Box
$Left = GUICreate("Left Line", 2, $ScanHeight,$x,$y + 40,$WS_POPUP,-1)
GUISetBkColor(0xFF0000)
GUISetState()
            
;Draws the Right Side of the Ore Finder Box
$Right = GUICreate("Right Line", 2, $ScanHeight,$x + $ScanWidth - 2,$y + 40,$WS_POPUP,-1)
GUISetBkColor(0xFF0000)
GUISetState()
            
;Draws the Bottom of the Ore Finder Box
$Bottom = GUICreate("Bottom Line", $ScanWidth, 2,$x,$y + 40 + $ScanHeight,$WS_POPUP,-1)
GUISetBkColor(0xFF0000)
GUISetState()

HotKeySet("^z","Start")
HotKeySet("^x","Stop")
;HotKeySet("^a","movehide")
HotKeySet("!^x", "Abort")

#EndRegion

#Region ;GUI
$GUI = GUICreate("HYBERMINER v2.2", 301, 186, 359, 202) ;<== Creates the GUI
WinSetOnTop($GUI,"",1)
GUISetBkColor(0x000000) ;<== Sets the Main GUI Background color to black.
GUISetOnEvent($GUI_EVENT_CLOSE, "MainClose") ;<== Sets the EVENT_CLOSE to the MainClose Function.
$CaptionStatus = GUICtrlCreateLabel("Status:", 5, 15, 38, 19) ;<== Creates the Label $CaptionStatus.
GUICtrlSetFont(-1, 8, 400, 0, "@Arial Unicode MS") ;<== Sets the Font to @Arial Unicode MS.
GUICtrlSetColor(-1, 0xFFFFFF) ;<== Sets the Font Color to White.
GUICtrlSetBkColor(-1, 0x000000) ;<== Sets the Background Color to black.
$LabelStatus = GUICtrlCreateLabel("Stopped", 48, 15, 44, 19) ;<== Creates the Label $LabelStatus
GUICtrlSetFont(-1, 8, 400, 0, "@Arial Unicode MS") ;<== Sets the Font to @Arial Unicode MS.
GUICtrlSetColor(-1, 0xFFFFFF) ;<== Sets the Font Color to White.
GUICtrlSetBkColor(-1, 0x000000) ;<== Sets the Background Color to black.
$DropColorDisplay = GUICtrlCreateLabel("Drop Finder Color", 176, 40, 91, 19) ;<== Creates the Label $DropColorDisplay
GUICtrlSetFont(-1, 8, 400, 0, "@Arial Unicode MS") ;<== Sets the Font to @Arial Unicode MS.
GUICtrlSetColor(-1, 0xFFFFFF) ;<== Sets the Font Color to White.
GUICtrlSetBkColor(-1, 0x000000) ;<== Sets the Background Color to black.
$CurrentColorDisplay = GUICtrlCreateLabel("Ore Finder Color", 175, 13, 86, 19) ;<== Creates the Label $CurrentColorDisplay
GUICtrlSetFont(-1, 8, 400, 0, "@Arial Unicode MS") ;<== Sets the Font to @Arial Unicode MS.
GUICtrlSetColor(-1, 0xFFFFFF) ;<== Sets the Font Color to White.
GUICtrlSetBkColor(-1, 0x000000) ;<== Sets the Background Color to black.
$StartButton = GUICtrlCreateButton("Start (Ctrl - Z)", 48, 120, 90, 25, 0) ;<== Creates the Button $StartButton
GUICtrlSetFont(-1, 8, 400, 0, "@Arial Unicode MS") ;<== Sets the Font to @Arial Unicode MS.
$StopButton = GUICtrlCreateButton("Stop (Ctrl - X)", 152, 120, 90, 25, 0) ;<== Creates the Button $StopButton
GUICtrlSetFont(-1, 8, 400, 0, "@Arial Unicode MS") ;<== Sets the Font to @Arial Unicode MS.
$CaptionCheckInterval = GUICtrlCreateLabel("Check Interval:", 5, 48, 78, 19) ;<== Creates the Label $CaptionCheckInterval
GUICtrlSetFont(-1, 8, 400, 0, "@Arial Unicode MS") ;<== Sets the Font to @Arial Unicode MS.
GUICtrlSetColor(-1, 0xFFFFFF) ;<== Sets the Font Color to White.
GUICtrlSetBkColor(-1, 0x000000) ;<== Sets the Background Color to black.
$CaptionMineInterval = GUICtrlCreateLabel("Mine Interval:", 5, 80, 69, 19) ;<== Creates the Label $CaptionMineInterval
GUICtrlSetFont(-1, 8, 400, 0, "@Arial Unicode MS") ;<== Sets the Font to @Arial Unicode MS.
GUICtrlSetColor(-1, 0xFFFFFF) ;<== Sets the Font Color to White.
GUICtrlSetBkColor(-1, 0x000000) ;<== Sets the Background Color to black.
$LabelCheckInterval = GUICtrlCreateLabel("N/A", 95, 48, 22, 19) ;<== Creates the Label $LabelCheckInterval
GUICtrlSetFont(-1, 8, 400, 0, "@Arial Unicode MS") ;<== Sets the Font to @Arial Unicode MS.
GUICtrlSetColor(-1, 0xFFFFFF) ;<== Sets the Font Color to White.
GUICtrlSetBkColor(-1, 0x000000) ;<== Sets the Background Color to black.
$LableMineInterval = GUICtrlCreateLabel("N/A", 95, 80, 22, 19) ;<== Creates the Label $LableMineInterval
GUICtrlSetFont(-1, 8, 400, 0, "@Arial Unicode MS") ;<== Sets the Font to @Arial Unicode MS.
GUICtrlSetColor(-1, 0xFFFFFF) ;<== Sets the Font Color to White.
GUICtrlSetBkColor(-1, 0x000000) ;<== Sets the Background Color to black.
$MenuFile = GUICtrlCreateMenu("File") ;<== Creates Menu File in the Top Menu Bar
$MenuStart = GUICtrlCreateMenuItem("Start!", $MenuFile) ;<== Creates MenuItem Start in the File Menu
$MenuStop = GUICtrlCreateMenuItem("Stop", $MenuFile) ;<== Creates MenuItem Stop in the File Menu
$MenuPreferences = GUICtrlCreateMenuItem("Preferences", $MenuFile) ;<== Creates MenuItem Preferences in the File Menu
$MenuExit = GUICtrlCreateMenuItem("Exit", $MenuFile) ;<== Creates MenuItem Exit in the File Menu
$MenuOptions = GUICtrlCreateMenu("Options") ;<== Creates Menu File in the Top Menu Bar
$MenuOreFinder = GUICtrlCreateMenu("Ore Finder", $MenuOptions) ;<== Creates Menu Ore Finder in the Options Menu
$MenuMoveOreFinder = GUICtrlCreateMenuItem("Move", $MenuOreFinder) ;<== Creates MenuItem Move in the Ore Finder Menu
$MenuResizeOreFinder = GUICtrlCreateMenuItem("Resize", $MenuOreFinder) ;<== Creates MenuItem Resize in the Ore Finder Menu
$MenuDropFinder = GUICtrlCreateMenu("Drop Finder", $MenuOptions) ;<== Creates Menu Drop Finder in the Options Menu
$MenuMoveDropFinder = GUICtrlCreateMenuItem("Move", $MenuDropFinder) ;<== Creates the MenuItem Move in the Drop Finder Menu
$MenuChooseColors = GUICtrlCreateMenu("Choose Colors", $MenuOptions)  ;<== Creates the Choose Color Menu in the Options Menu
$MenuChooseColorsOre = GUICtrlCreateMenu("Ore Finder", $MenuChooseColors) ;<== Creates the Menu Ore Finder in the Choose Color Menu
$MenuChooseColorsOreByColor = GUICtrlCreateMenuItem("By Color", $MenuChooseColorsOre) ;<== Creates the MenuItem By Color in the Ore Finder Menu
$MenuChooseColorsOreByOre = GUICtrlCreateMenu("By Ore", $MenuChooseColorsOre) ;<== Creates the Menu By Ore in the Ore Finder Menu
$MenuOreTin = GUICtrlCreateMenuItem("Tin", $MenuChooseColorsOreByOre) ;<== Creates the MenuItem Tin in the By Ore Menu
$MenuOreCopper = GUICtrlCreateMenuItem("Copper", $MenuChooseColorsOreByOre) ;<== Creates the MenuItem Copper in the By Ore Menu
$MenuOreIron = GUICtrlCreateMenuItem("Iron", $MenuChooseColorsOreByOre) ;<== Creates the MenuItem Iron the By Ore Menu
$MenuOreCoal = GUICtrlCreateMenuItem("Coal", $MenuChooseColorsOreByOre) ;<== Creates the MenuItem Coal in the By Ore Menu
$MenuOreGold = GUICtrlCreateMenuItem("Gold", $MenuChooseColorsOreByOre) ;<== Creates the MenuItem Gold in the By Ore Menu
$MenuOreMithril = GUICtrlCreateMenuItem("Mithril", $MenuChooseColorsOreByOre) ;<== Creates the MenuItem Mithril in the By Ore Menu
$MenuOreAdamantite = GUICtrlCreateMenuItem("Adamantite", $MenuChooseColorsOreByOre) ;<== Creates the MenuItem Adamantite in the By Ore Menu
$MenuOreRunite = GUICtrlCreateMenuItem("Runite", $MenuChooseColorsOreByOre) ;<== Creates the MenuItem Runite in the By Ore Menu
$MenuChooseColorsDrop = GUICtrlCreateMenu("Drop Finder", $MenuChooseColors) ;<== Creates the Menu Drop Finder in the Choose Color Menu
$MenuChooseColorsDropByColor = GUICtrlCreateMenuItem("By Color", $MenuChooseColorsDrop) ;<== Creates the MenuItem By Color in the Drop Finder Menu
$MenuChooseColorsDroByOre = GUICtrlCreateMenu("By Ore", $MenuChooseColorsDrop) ;<== Creates the Menu By Ore in the Drop Finder Menu
$MenuDropTin = GUICtrlCreateMenuItem("Tin", $MenuChooseColorsDroByOre);<== Creates the MenuItem Tin in the By Ore Menu
$MenuDropCopper = GUICtrlCreateMenuItem("Copper", $MenuChooseColorsDroByOre) ;<== Creates the MenuItem Copper in the By Ore Menu
$MenuDropIron = GUICtrlCreateMenuItem("Iron", $MenuChooseColorsDroByOre) ;<== Creates the MenuItem Iron the By Ore Menu
$MenuDropCoal = GUICtrlCreateMenuItem("Coal", $MenuChooseColorsDroByOre) ;<== Creates the MenuItem Coal in the By Ore Menu
$MenuDropGold = GUICtrlCreateMenuItem("Gold", $MenuChooseColorsDroByOre) ;<== Creates the MenuItem Gold in the By Ore Menu
$MenuDropMithril = GUICtrlCreateMenuItem("Mithril", $MenuChooseColorsDroByOre) ;<== Creates the MenuItem Mithril in the By Ore Menu
$MenuDropAdamantite = GUICtrlCreateMenuItem("Adamantite", $MenuChooseColorsDroByOre) ;<== Creates the MenuItem Adamantite in the By Ore Menu
$MenuDropRunite = GUICtrlCreateMenuItem("Runite", $MenuChooseColorsDroByOre) ;<== Creates the MenuItem Runite in the By Ore Menu
$MenuCheckInterval = GUICtrlCreateMenu("Check Interval", $MenuOptions) ;<== Creates the Menu Check Interval  in the Options Menu
$MenuCheckInterval2 = GUICtrlCreateMenuItem("2000(ms)", $MenuCheckInterval) ;<== Creates the MenuItem 2000(ms) in the Check Interval Menu
$MenuCheckInterval4 = GUICtrlCreateMenuItem("4000(ms)", $MenuCheckInterval) ;<== Creates the MenuItem 4000(ms) in the Check Interval Menu
$MenuCheckInterval6 = GUICtrlCreateMenuItem("6000(ms)", $MenuCheckInterval) ;<== Creates the MenuItem 6000(ms) in the Check Interval Menu
$MenuCheckIntervalCustom = GUICtrlCreateMenuItem("Custom", $MenuCheckInterval) ;<== Creates the MenuItem Custom in the Check Interval Menu
$MenuMiningInterval = GUICtrlCreateMenu("Mining Interval", $MenuOptions) ;<== Creates the Menu Mining Interval  in the Options Menu
$MenuMiningInterval2 = GUICtrlCreateMenuItem("2000(ms)", $MenuMiningInterval) ;<== Creates the MenuItem 2000(ms) in the Mining Interval Menu
$MenuMiningInterval4 = GUICtrlCreateMenuItem("4000(ms)", $MenuMiningInterval) ;<== Creates the MenuItem 4000(ms) in the Mining Interval Menu
$MenuMiningInterval6 = GUICtrlCreateMenuItem("6000(ms)", $MenuMiningInterval) ;<== Creates the MenuItem 6000(ms) in the Mining Interval Menu
$MenuMiningIntervalCustom = GUICtrlCreateMenuItem("Custom", $MenuMiningInterval) ;<== Creates the Custom in the Mining Interval Menu
$MenuHelp = GUICtrlCreateMenu("Help") ;<== Creates the Menu Help in the Top Menu Bar
$MenuInstructions = GUICtrlCreateMenuItem("Instructions", $MenuHelp) ;<== Creates the MenuItem Instructions in the Help Menu
$MenuHotkeys = GUICtrlCreateMenu("HotKeys", $MenuHelp) ;<== Creates the Menu HotKeys in the Help Menu
$MenuHotKeyStart = GUICtrlCreateMenuItem("Start (Ctrl - Z)", $MenuHotkeys) ;<== Cretaes the MenuItem Start (Ctrl - Z) in the Hotkeys Menu
$MenuHotKeyStop = GUICtrlCreateMenuItem("Stop (Ctrl - X)", $MenuHotkeys) ;<== Cretaes the MenuItem Stop (Ctrl - X) in the Hotkeys Menu
$MenuHotKeyMove = GUICtrlCreateMenuItem("Move Ore Finder (Ctrl - A)", $MenuHotkeys) ;<== Cretaes the MenuItem Move Ore Finder (Ctrl - A in the Hotkeys Menu
$MenuHotKeyEmergencyStop = GUICtrlCreateMenuItem("Emeregency Stop (Ctrl + Alt - X)", $MenuHotkeys) ;<== Cretaes the MenuItem Emeregency Stop (Ctrl + Alt - X) in the Hotkeys Menu
GUISetState(@SW_SHOW) ;<== Sets the GUI to be Visible
#EndRegion

#Region ;LOOP
While 1
    $msg = GUIGetMsg()
    Select  
        Case $msg = $StartButton OR $msg = $MenuStart OR $msg = $MenuHotKeyStart
            Start()
        Case $msg = $StopButton OR $msg = $MenuStop OR $msg = $MenuHotKeyStop
            Stop()
        Case $msg = $MenuExit
            Exit
    EndSelect   
WEnd
#EndRegion
#Region ;FUNCTIONS

Func Start()
    Check()
EndFunc

Func Stop()
    AdlibDisable()
    GUICtrlSetData($LabelStatus,"Stopped")
    AdlibDisable()
    GUICtrlSetData($LabelStatus,"Stopped")
EndFunc

Func Check()
    Sleep(Random(0,500,1))
    $Pixel = PixelSearch($x+2,$y+42,$x+2+$ScanWidth,$y+42+$ScanHeight,$CurrentColor,$Sens)
    If Not @error Then
        MouseClick("Left", $Pixel[0],$Pixel[1],1,2)
        GUICtrlSetData($LabelStatus,"Mining")
        $Idle = 0
        AdlibEnable("Check", $SleepMine)
    Else
        GUICtrlSetData($LabelStatus,"Checking")
        $Idle += $SleepCheck
        If $Idle >= 60000 Then
            MouseClick("Left")
            $Idle = 0
        EndIf
        AdlibEnable("Check", $SleepCheck)
    EndIf
EndFunc

Func SetColor()
    GUICtrlSetBkColor($CurrentColorDisplay,$CurrentColor)
    GUICtrlSetBkColor($DropColorDisplay,$CurrentDropColor)
EndFunc

Func Drop()
            $data = PixelSearch($smallx,$smally,$smallx+$smallScanWidth,$smally+$smallScanHeight,$DropColor,$Sens)
            GUICtrlSetData($LabelStatus,"Droping Ores")
            $Idle = 0
            
        
            ;Searches the Inventory for the Drop Color
            $pos = PixelSearch(810,350,990,570,$DropColor,$Sens)
            ;Makes $pos an Array
            If IsArray($pos)Then
            ;Moves Mouse to the Ore that was detected               
            MouseMove($pos[0], $pos[1])
            ;Right Clicks the Ore
            MouseClick( "right",$pos[0], $pos[1])
            ;Moves the Mouse Down to the Drop Option
            MouseMove($pos[0], $pos[1]+45)
            ;Left Clicks the Drop Option
            MouseClick( "left", $pos[0], $pos[1]+45)
            EndIf
        
            AdlibEnable("Check", $SleepDrop)
            
EndFunc     
                
Func Move()
            
            ;Loops while user moves the Scan Screen.
            While 1 
                ;Sets a Variable equal to the Mouse Position
                $MousePos = MouseGetPos()
                
                ;Moves the Sides of the Scan Screen to the Mouse Position
                WinMove($Top,"", $MousePos[0],$MousePos[1]+40)
                WinMove($Left,"", $MousePos[0],$MousePos[1]+40)
                WinMove($Right,"", $MousePos[0]+ $ScanWidth - 2,$MousePos[1]+40)
                WinMove($Bottom,"", $MousePos[0],$MousePos[1]+ 40 + $ScanHeight)
                
                ;Sets the scan Screens Current Position to its New Position
                $x = $MousePos[0]
                $y = $MousePos[1]
                
                ;When the Left Mouse Button is released the Loop ends.
                If _IsPressed(01) Then
                    ;Deletes the Box around the Scan Screen
                    Sleep(1000)
                    GuiDelete($Bottom)
                    GuiDelete($Right)
                    GuiDelete($Left)
                    GuiDelete($Top)
                    ExitLoop
                EndIf
            WEnd
EndFunc         

Func Resize()
    HotKeySet("^a")
    Stop()
    $MoveMode = True
    
    While 1
        
        $MousePos = MouseGetPos()
        
        WinMove($Top,"", $x,$y+40,$ScanWidth,2)
        WinMove($Left,"", $x,$y+40,2,$ScanHeight)
        WinMove($Right,"", $x+ $ScanWidth - 2,$y+40,2,$ScanHeight)
        WinMove($Bottom,"", $x,$y+ 40 + $ScanHeight,$ScanWidth,2)
        
        If Not (($MousePos[0] - $x + 1) <= 40) Then
            $ScanWidth = $MousePos[0] - $x + 1
        EndIf
        If Not (($MousePos[1] - $y - 39) <= 40) Then
            $ScanHeight = $MousePos[1] - $y - 39
        EndIf
        
        If _IsPressed(01) Then
            Sleep(1000)
            GuiDelete($Bottom)
            GuiDelete($Right)
            GuiDelete($Left)
            GuiDelete($Top)
            ExitLoop
        EndIf
    WEnd
    HotKeySet("^a","Move")
EndFunc         

Func Preferences()
    Stop()
    $Pref = GUICreate("Preferences", 453, 462)
    
    ; Left side
    GUICtrlCreateLabel("The colors " & $AppTitle & " looks for are below." & @CRLF & "The color can be a hex or a decimal. To get a color use the ""Select Color > By Screen Color"" mode and press ""Ctrl + F""", 5, 5, 233, 52)
    
    GUICtrlCreateGroup("Colors", 0, 55, 240, 285)
    $InputClay = GUICtrlCreateInput($ColorClay, 105, 75, 121, 21)
    GUICtrlCreateLabel("Clay", 10, 80, 43, 17)
    $InputCopper = GUICtrlCreateInput($ColorCopper, 105, 100, 121, 21)
    GUICtrlCreateLabel("Copper", 10, 105, 53, 17)
    $InputTin = GUICtrlCreateInput($ColorTin, 105, 125, 121, 21)
    GUICtrlCreateLabel("Tin", 10, 130, 53, 17)
    $InputIron = GUICtrlCreateInput($ColorIron, 105, 150, 121, 21)
    GUICtrlCreateLabel("Iron", 10, 155, 53, 17)
    $InputSilver = GUICtrlCreateInput($ColorSilver, 105, 175, 121, 21)
    GUICtrlCreateLabel("Silver", 10, 180, 53, 17)
    $InputCoal = GUICtrlCreateInput($ColorCoal, 105, 200, 121, 21)
    GUICtrlCreateLabel("Coal", 10, 205, 53, 17)
    $InputGold = GUICtrlCreateInput($ColorGold, 105, 225, 121, 21)
    GUICtrlCreateLabel("Gold", 10, 230, 53, 17)
    $InputMithril = GUICtrlCreateInput($ColorMithril, 105, 250, 121, 21)
    GUICtrlCreateLabel("Mithril", 10, 255, 53, 17)
    $InputAddy = GUICtrlCreateInput($ColorAddy, 105, 275, 121, 21)
    GUICtrlCreateLabel("Adamantite", 10, 280, 53, 17)
    $InputRunite = GUICtrlCreateInput($ColorRunite, 105, 300, 121, 21)
    GUICtrlCreateLabel("Runite", 10, 305, 53, 17)
    
    GUICtrlCreateLabel("These represent the starting point for the program. They are also the coordinates used with Ctrl + A.", 0, 345, 239, 47)
    
    GUICtrlCreateGroup("X and Y", 0, 380, 240, 50)
    
    $InputX = GUICtrlCreateInput($StartX, 30, 400, 86, 21)
    $InputY = GUICtrlCreateInput($StartY, 120, 400, 86, 21)
    
    ;Right side
    
    GUICtrlCreateLabel("The right side contains Beta functions only. These are more advanced and may cause unexplainable errors.", 245, 5, 204, 42)
    
    GUICtrlCreateGroup("Beta Options", 245, 55, 205, 285)
        $CenterCheckbox = GUICtrlCreateCheckbox("", 255, 75, 187, 17)
        $ColorCheckbox = GUICtrlCreateCheckbox("", 255, 100, 187, 17)
        GUICtrlCreateLabel("Color match sensitivity. Move the slider to the left for a harder match.", 255, 125, 179, 27)
        $SensSlider = GUICtrlCreateSlider(255, 155, 180, 30)
        GUICtrlSetLimit(-1,20,1)
        GUICtrlSetData(-1,$Sens)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    
    GUICtrlCreateGroup("Drop Options", 250, 245, 195, 85)
        $DropNormal = GUICtrlCreateRadio("Drop Normal", 260, 265, 113, 17)
        $DropMagic = GUICtrlCreateRadio("Drop Magic", 260, 285, 113, 17)
        $DropNone = GUICtrlCreateRadio("No Drop (Default)", 260, 305, 113, 17)
        GUICtrlSetState(-1,$GUI_CHECKED)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    
    
    ;Bottom Buttons
    $DefaultButton = GUICtrlCreateButton("Default Values", 5, 435, 135, 25)
    $OkButton = GUICtrlCreateButton("OK", 145, 435, 90, 25)
    GUICtrlSetState(-1,$GUI_FOCUS)
    
    GUISetState(@SW_SHOW)
    WinSetOnTop($Pref, "", 1)
    
    While 1
        $msg = GuiGetMsg()
        Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $OkButton
            IniWrite("MineData.ini", "Colors", "Clay", GUICtrlRead($InputClay))
            IniWrite("MineData.ini", "Colors", "Copper", GUICtrlRead($InputCopper))
            IniWrite("MineData.ini", "Colors", "Tin", GUICtrlRead($InputTin))
            IniWrite("MineData.ini", "Colors", "Iron", GUICtrlRead($InputIron))
            IniWrite("MineData.ini", "Colors", "Silver", GUICtrlRead($InputSilver))
            IniWrite("MineData.ini", "Colors", "Coal", GUICtrlRead($InputCoal))
            IniWrite("MineData.ini", "Colors", "Gold", GUICtrlRead($InputGold))
            IniWrite("MineData.ini", "Colors", "Mithril", GUICtrlRead($InputMithril))
            IniWrite("MineData.ini", "Colors", "Addy", GUICtrlRead($InputAddy))
            IniWrite("MineData.ini", "Colors", "Runite", GUICtrlRead($InputRunite))
            
            IniWrite("MineData.ini", "Pos", "X", GUICtrlRead($InputX))
            IniWrite("MineData.ini", "Pos", "Y", GUICtrlRead($InputY))
            
            $ColorClay = GUICtrlRead($InputClay)
            $ColorCopper = GUICtrlRead($InputCopper)
            $ColorTin = GUICtrlRead($InputTin)
            $ColorIron = GUICtrlRead($InputIron)
            $ColorSilver = GUICtrlRead($InputSilver)
            $ColorCoal = GUICtrlRead($InputCoal)
            $ColorGold = GUICtrlRead($InputGold)
            $ColorMithril = GUICtrlRead($InputMithril)
            $ColorAddy = GUICtrlRead($InputAddy)
            $ColorRunite = GUICtrlRead($InputRunite)
            
            ;beta below
            
            If GUICtrlRead($CenterCheckbox) = $GUI_CHECKED Then
                IniWrite("MineData.ini", "Beta", "CenterOnOre", 1)
            ElseIf GUICtrlRead($CenterCheckbox) = $GUI_UNCHECKED Then
                IniWrite("MineData.ini", "Beta", "CenterOnOre", 0)
            EndIf
            
            If GUICtrlRead($ColorCheckbox) = $GUI_CHECKED Then
                IniWrite("MineData.ini", "Beta", "ColorAverage", 1)
            ElseIf GUICtrlRead($ColorCheckbox) = $GUI_UNCHECKED Then
                IniWrite("MineData.ini", "Beta", "ColorAverage", 0)
            EndIf
            
            $Sens = GUICtrlRead($SensSlider)
            IniWrite("MineData.ini", "Beta", "Sensitifity", $Sens)
            
            ExitLoop
        Case $msg = $DefaultButton
            FileDelete("MineData.ini")
            MsgBox(0, $AppTitle, "Default values set, please restart " & $AppTitle)
            Exit
        EndSelect
    WEnd
    GUIDelete()
EndFunc
        
Func MainClose()
Exit
EndFunc

Func Abort()
    AdlibDisable()
    HotKeySet("!^x")
    SplashTextOn("", "Ending Program ...", 200,30)
    Sleep(800)
    Exit
EndFunc

#EndRegion
Link to comment
Share on other sites

  • Moderators

Ooch!!! I didn't mean a 400 liner as a re-creation script :) ... thank god I spotted an issue right away (or I wouldn't have looked much longer).

You can not use OnEvent with GUIGetMsg()... It has to be one or the other.

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.

Link to comment
Share on other sites

  • Moderators

works =)

Congrats... though I'm not a game fan, I see you put a lot of work in that... good luck.

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.

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...