Jump to content

Help with FOCUS


 Share

Recommended Posts

Hi. I'm new to AutoIt and this forum. I wrote a func to Place several Labels on a form, when the loop is finished placing them, i have another loop to detect users input by using a Select Case inside another While loop at the end of the function, the problem is, the first label placed on the form seems to keep the focus, I have tried GUISetState($PicMain, $GUI_FOCUS) to put the focus back onto the main form before the while loop starts running the Select Case code, but this doesnt work, it keeps trying to activate the first Case statement. Below is my entire code.

Func CalcCrop3()

Sleep(1000)

_ScreenCapture_Capture("Farm.jpg");Captures the screen view

msgbox(0, 'Done', 'Screen Capture Complete, Press OK to continue.')

GLOBAL $PicMain = GUICreate("FarmBot - [Calibration Mode]", 1024, 768, -3, -29); Creates window to place picture in

GLOBAL $ImgForm = GUICtrlCreatePic("Farm.JPG", 0, 0, 1024, 768); places picture in new window

GUISetState() ;Mayneed to add: @SW_SHOW

; GUICtrlSetState($PicMain, $GUI_FOCUS)

;=========THIS SECTION GETS THE 4 CORNERS OF YOUR FARM LAYOUT==============

MsgBox(0, "Crop Select", "Place curser over Top Crop and Press: [ENTER]")

$GetCrop = MouseGetPos()

Sleep(100)

INIWRITE("FarmBotBeta4.ini", "Calibrate", "FirstX", $GetCrop[0])

INIWRITE("FarmBotBeta4.ini", "Calibrate", "FirstY", $GetCrop[1])

MsgBox(0, "Crop Select", "Place curser over Bottom Crop and Press: [ENTER]")

$GetCrop = MouseGetPos()

Sleep(100)

INIWRITE("FarmBotBeta4.ini", "Calibrate", "LastX", $GetCrop[0])

INIWRITE("FarmBotBeta4.ini", "Calibrate", "LastY", $GetCrop[1])

MsgBox(0, "Crop Select", "Place curser over Left Crop and Press: [ENTER]")

$GetCrop = MouseGetPos()

Sleep(100)

INIWRITE("FarmBotBeta4.ini", "Calibrate", "LeftX", $GetCrop[0])

INIWRITE("FarmBotBeta4.ini", "Calibrate", "LeftY", $GetCrop[1])

MsgBox(0, "Crop Select", "Place curser over Right Crop and Press: [ENTER]")

$GetCrop = MouseGetPos()

Sleep(100)

INIWRITE("FarmBotBeta4.ini", "Calibrate", "RightX", $GetCrop[0])

INIWRITE("FarmBotBeta4.ini", "Calibrate", "RightY", $GetCrop[1])

Sleep(500)

;===================================================================================

;=============LOCAL VARIABLES LIST===================================================

Local $FirstX = IniRead("FarmBotBeta4.ini", "Calibrate", "FirstX", "Error")

Local $FirstY = IniRead("FarmBotBeta4.ini", "Calibrate", "FirstY", "Error")

Local $LastX = IniRead("FarmBotBeta4.ini", "Calibrate", "LastX", "Error")

Local $LastY = IniRead("FarmBotBeta4.ini", "Calibrate", "LastY", "Error")

Local $LeftX = IniRead("FarmBotBeta4.ini", "Calibrate", "LeftX", "ERROR")

Local $LeftY = IniRead("FarmBotBeta4.ini", "Calibrate", "LeftY", "ERROR")

Local $RightX = IniRead("FarmBotBeta4.ini", "Calibrate", "RightX", "ERROR")

Local $RightY = IniRead("FarmBotBeta4.ini", "Calibrate", "RightY", "ERROR")

Local $1StepX = $RightX - $FirstX

Local $1StepY = $RightY - $FirstY

Local $2StepX = $1StepX /19

Local $2StepY = $1StepY /19

Local $3StepX = 25

Local $3StepY = 12

Local $ColWidth = Round($1StepX / 25) + 1 ;Should return a value of 20 on my current farm.

INIWRITE("FarmBotBeta4.ini", "Calibrate", "ColWidth", $ColWidth)

Local $GetCrop[2];Not sure if this variable def is redundent.. may not be needed

Local $ColX = $FirstX

Local $ColY = $FirstY

Local $Counting = 0

Local $CropNum = 1

Local $Label1[576];Set to max num of fields available in farmville 24x24=576

Local $CropCoords[2]

Local $3BStepX = 25

Local $3BStepY = -12

Local $msg = 0

;=====================================================================================

Do

Local $i = 0

If $Counting = $ColWidth then ExitLoop

While $i <= $ColWidth

$TrueStepX = $i * $3StepX

$TrueStepY = $i * $3StepY

If $i = $ColWidth then EXITLOOP

$Label1[$CropNum] = GUICtrlCreateLabel($CropNum, Round($ColX + $TrueStepX, 0), Round($ColY + $TrueStepY, 0), 4, 4)

;IF THIS TEST SCRIPT SECTION DOESNT WORK. USE OLD SECTION BELOW

INIWRITE("Crops.ini", $CropNum, "XY", Round($ColX + $TrueStepX, 0) & "," & Round($ColY + $TrueStepY, 0))

;INIWRITE("Crops.ini", $CropNum, "Y", Round($ColY + $TrueStepY, 0))

;END NEW SECTION - BEGIN OLD SECTION

$i = $i + 1

$CropNum = $CropNum + 1 ; This counts total amount of crops

WEnd

$ColX = $ColX - Round($3BStepX, 0)

$ColY = $ColY - Round($3BStepY, 0)

$Counting = $Counting + 1

Until $Counting > $ColWidth

;Msgbox(0, "TEST", "Made it out of loop")

GUISetState($PicMain, $GUI_FOCUS)

While 1

$msg = GUIGetMsg(); may have to add: $PicMain inside ()

;sleep(500)

Select

Case $msg = $GUI_EVENT_CLOSE

;MsgBox(0, "Exit", "Thanks for using Farmbot!")

Call("Terminate")

Case $Label1[1]

GUICtrlSetBkColor($Label1[1], $GUI_BKCOLOR_TRANSPARENT)

GUICtrlSetColor ( $Label1[1], 0xFF0000)

iniwrite("Crops.ini", "1", "XY", "")

MsgBox(0, "Done", "That crop location has been deleted.")

Case $Label1[2]

GUICtrlSetBkColor($Label1[2], $GUI_BKCOLOR_TRANSPARENT)

GUICtrlSetColor ( $Label1[2], 0xFF0000)

iniwrite("Crops.ini", "2", "XY", "")

MsgBox(0, "Done", "That crop location has been deleted.")

Case $Label1[3]

GUICtrlSetBkColor($Label1[3], $GUI_BKCOLOR_TRANSPARENT)

GUICtrlSetColor ( $Label1[3], 0xFF0000)

iniwrite("Crops.ini", "3", "XY", "")

MsgBox(0, "Done", "That crop location has been deleted.")

Case $Label1[4]

GUICtrlSetBkColor($Label1[4], $GUI_BKCOLOR_TRANSPARENT)

GUICtrlSetColor ( $Label1[4], 0xFF0000)

iniwrite("Crops.ini", "4", "XY", "")

MsgBox(0, "Done", "That crop location has been deleted.")

Case $Label1[5]

GUICtrlSetBkColor($Label1[5], $GUI_BKCOLOR_TRANSPARENT)

GUICtrlSetColor ( $Label1[5], 0xFF0000)

iniwrite("Crops.ini", "5", "XY", "")

MsgBox(0, "Done", "That crop location has been deleted.")

Case $Label1[6]

GUICtrlSetBkColor($Label1[6], $GUI_BKCOLOR_TRANSPARENT)

GUICtrlSetColor ( $Label1[6], 0xFF0000)

iniwrite("Crops.ini", "6", "XY", "")

MsgBox(0, "Done", "That crop location has been deleted.")

Case $Label1[7]

GUICtrlSetBkColor($Label1[7], $GUI_BKCOLOR_TRANSPARENT)

GUICtrlSetColor ( $Label1[7], 0xFF0000)

iniwrite("Crops.ini", "7", "XY", "")

MsgBox(0, "Done", "That crop location has been deleted.")

Case $Label1[8]

GUICtrlSetBkColor($Label1[8], $GUI_BKCOLOR_TRANSPARENT)

GUICtrlSetColor ( $Label1[8], 0xFF0000)

iniwrite("Crops.ini", "8", "XY", "")

MsgBox(0, "Done", "That crop location has been deleted.")

Case $Label1[9]

GUICtrlSetBkColor($Label1[9], $GUI_BKCOLOR_TRANSPARENT)

GUICtrlSetColor ( $Label1[9], 0xFF0000)

iniwrite("Crops.ini", "9", "XY", "")

MsgBox(0, "Done", "That crop location has been deleted.")

Case $Label1[10]

GUICtrlSetBkColor($Label1[10], $GUI_BKCOLOR_TRANSPARENT)

GUICtrlSetColor ( $Label1[10], 0xFF0000)

iniwrite("Crops.ini", "10", "XY", "")

MsgBox(0, "Done", "That crop location has been deleted.")

Case $Label1[11]

GUICtrlSetBkColor($Label1[11], $GUI_BKCOLOR_TRANSPARENT)

GUICtrlSetColor ( $Label1[11], 0xFF0000)

iniwrite("Crops.ini", "11", "XY", "")

MsgBox(0, "Done", "That crop location has been deleted.")

Case $Label1[12]

GUICtrlSetBkColor($Label1[12], $GUI_BKCOLOR_TRANSPARENT)

GUICtrlSetColor ( $Label1[12], 0xFF0000)

iniwrite("Crops.ini", "12", "XY", "")

MsgBox(0, "Done", "That crop location has been deleted.")

Case $Label1[13]

GUICtrlSetBkColor($Label1[13], $GUI_BKCOLOR_TRANSPARENT)

GUICtrlSetColor ( $Label1[13], 0xFF0000)

iniwrite("Crops.ini", "13", "XY", "")

MsgBox(0, "Done", "That crop location has been deleted.")

Case $Label1[14]

GUICtrlSetBkColor($Label1[14], $GUI_BKCOLOR_TRANSPARENT)

GUICtrlSetColor ( $Label1[14], 0xFF0000)

iniwrite("Crops.ini", "14", "XY", "")

MsgBox(0, "Done", "That crop location has been deleted.")

Case $Label1[15]

GUICtrlSetBkColor($Label1[15], $GUI_BKCOLOR_TRANSPARENT)

GUICtrlSetColor ( $Label1[15], 0xFF0000)

iniwrite("Crops.ini", "15", "XY", "")

MsgBox(0, "Done", "That crop location has been deleted.")

Case $Label1[16]

GUICtrlSetBkColor($Label1[16], $GUI_BKCOLOR_TRANSPARENT)

GUICtrlSetColor ( $Label1[16], 0xFF0000)

iniwrite("Crops.ini", "16", "XY", "")

MsgBox(0, "Done", "That crop location has been deleted.")

Case $Label1[17]

GUICtrlSetBkColor($Label1[17], $GUI_BKCOLOR_TRANSPARENT)

GUICtrlSetColor ( $Label1[17], 0xFF0000)

iniwrite("Crops.ini", "17", "XY", "")

MsgBox(0, "Done", "That crop location has been deleted.")

Case $Label1[18]

GUICtrlSetBkColor($Label1[18], $GUI_BKCOLOR_TRANSPARENT)

GUICtrlSetColor ( $Label1[18], 0xFF0000)

iniwrite("Crops.ini", "18", "XY", "")

MsgBox(0, "Done", "That crop location has been deleted.")

Case $Label1[19]

GUICtrlSetBkColor($Label1[19], $GUI_BKCOLOR_TRANSPARENT)

GUICtrlSetColor ( $Label1[19], 0xFF0000)

iniwrite("Crops.ini", "19", "XY", "")

MsgBox(0, "Done", "That crop location has been deleted.")

Case $Label1[20]

GUICtrlSetBkColor($Label1[20], $GUI_BKCOLOR_TRANSPARENT)

GUICtrlSetColor ( $Label1[20], 0xFF0000)

iniwrite("Crops.ini", "20", "XY", "")

MsgBox(0, "Done", "That crop location has been deleted.")

Case $Label1[21]

GUICtrlSetBkColor($Label1[21], $GUI_BKCOLOR_TRANSPARENT)

GUICtrlSetColor ( $Label1[21], 0xFF0000)

iniwrite("Crops.ini", "21", "XY", "")

MsgBox(0, "Done", "That crop location has been deleted.")

Case $Label1[22]

GUICtrlSetBkColor($Label1[22], $GUI_BKCOLOR_TRANSPARENT)

GUICtrlSetColor ( $Label1[22], 0xFF0000)

iniwrite("Crops.ini", "22", "XY", "")

MsgBox(0, "Done", "That crop location has been deleted.")

Case $Label1[23]

GUICtrlSetBkColor($Label1[23], $GUI_BKCOLOR_TRANSPARENT)

GUICtrlSetColor ( $Label1[23], 0xFF0000)

iniwrite("Crops.ini", "23", "XY", "")

MsgBox(0, "Done", "That crop location has been deleted.")

Case $Label1[24]

GUICtrlSetBkColor($Label1[24], $GUI_BKCOLOR_TRANSPARENT)

GUICtrlSetColor ( $Label1[24], 0xFF0000)

iniwrite("Crops.ini", "24", "XY", "")

MsgBox(0, "Done", "That crop location has been deleted.")

Case $Label1[25]

GUICtrlSetBkColor($Label1[25], $GUI_BKCOLOR_TRANSPARENT)

GUICtrlSetColor ( $Label1[25], 0xFF0000)

iniwrite("Crops.ini", "25", "XY", "")

MsgBox(0, "Done", "That crop location has been deleted.")

Case $Label1[26]

GUICtrlSetBkColor($Label1[26], $GUI_BKCOLOR_TRANSPARENT)

GUICtrlSetColor ( $Label1[26], 0xFF0000)

iniwrite("Crops.ini", "26", "XY", "")

MsgBox(0, "Done", "That crop location has been deleted.")

Case $Label1[27]

GUICtrlSetBkColor($Label1[27], $GUI_BKCOLOR_TRANSPARENT)

GUICtrlSetColor ( $Label1[27], 0xFF0000)

iniwrite("Crops.ini", "27", "XY", "")

MsgBox(0, "Done", "That crop location has been deleted.")

Case $Label1[28]

GUICtrlSetBkColor($Label1[28], $GUI_BKCOLOR_TRANSPARENT)

GUICtrlSetColor ( $Label1[28], 0xFF0000)

iniwrite("Crops.ini", "28", "XY", "")

MsgBox(0, "Done", "That crop location has been deleted.")

Case $Label1[29]

GUICtrlSetBkColor($Label1[29], $GUI_BKCOLOR_TRANSPARENT)

GUICtrlSetColor ( $Label1[29], 0xFF0000)

iniwrite("Crops.ini", "29", "XY", "")

MsgBox(0, "Done", "That crop location has been deleted.")

EndSelect

WEnd

EndFunc

Link to comment
Share on other sites

Welcome to the forum

Please use the code style next time. It's hard to read otherwise.

Static controls such as labels and pics don't normally get focus.

You will need to insert $WS_TABSTOP when you are creating the guictrl.

Edited by picea892
Link to comment
Share on other sites

Hi. Thanks for the help, from what i can tell in the help files the $WS_TABSTOP on the $PicMain will allow the user to tab through the labels since they are controls. When i run the code as is, the first label created $Label1[1] seems to have focus, because when it exits the loop to create them, it goes into a new loop to detect user input and automatically selects the first Case $Label1[1]. I would like it to loop until i click any of the labels, then run the code below the case statement.

Link to comment
Share on other sites

What picea892 said.

Or you could do what it appears you may have been attempting tyo begin with

Change your Select/EndSelect statement to

Switch $Msg

;;case statements here

EndSwitch

You will also have to change the Case $msg = $GUI_EVENT_CLOSE to

Case $GUI_EVENT_CLOSE

so it is consistant with a switch statement.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Thanks, changing the SELECT to a SWITCH seemed to fix my loop problem, but now the $msg doesnt recognize mouse clicks on the labels. i need the case statements to trigger when the mouse clicks the proper labels. any further advise? ive made a small test script and it works great, when i click the labels i can change the text color, write info to an ini but in my script above it doesnt seem to recognize the mouse click as a trigger to the case statements.

Link to comment
Share on other sites

Thanks, changing the SELECT to a SWITCH seemed to fix my loop problem, but now the $msg doesnt recognize mouse clicks on the labels. i need the case statements to trigger when the mouse clicks the proper labels. any further advise? ive made a small test script and it works great, when i click the labels i can change the text color, write info to an ini but in my script above it doesnt seem to recognize the mouse click as a trigger to the case statements.

Did you used named variables for the labels and add them into the switch statement?

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

I switched the labels temporarily to buttons just to test a theory. I can tab through them and press the enter key, and the case statements will trigger just as they should, but they still wont recognize a mouse click, even if i tab and highlight the button, and move the mouse over it and click it, the button doesnt click down and doesnt trigger the case statements. very strange. I am using a local var = the label but im not sure how to add it to the switch statement, the switch is working only with Tab and Enter. I must get it to click for trigger the case.

Link to comment
Share on other sites

Here is the entire Func:

Sleep(5000)
    
    _ScreenCapture_Capture("Farm.jpg");Captures the screen view
    msgbox(0, 'Done', 'Screen Capture Complete, Press OK to continue.')

    GLOBAL $PicMain = GUICreate("FarmBot - [Calibration Mode]", 1024, 768, -3, -29); Creates window to place picture in
    GLOBAL $ImgForm = GUICtrlCreatePic("Farm.JPG", 0, 0, 1024, 768); places picture in new window

    GUISetState()   ;Mayneed to add: @SW_SHOW
    
    ;   GUICtrlSetState($PicMain, $GUI_FOCUS)
    ;=========THIS SECTION GETS THE 4 CORNERS OF YOUR FARM LAYOUT============== 
        MsgBox(0, "Crop Select", "Place curser over Top Crop and Press: [ENTER]")
        $GetCrop = MouseGetPos()
        Sleep(100)
INIWRITE("FarmBotBeta4.ini", "Calibrate", "FirstX", $GetCrop[0])
INIWRITE("FarmBotBeta4.ini", "Calibrate", "FirstY", $GetCrop[1])
        
        MsgBox(0, "Crop Select", "Place curser over Bottom Crop and Press: [ENTER]")
        $GetCrop = MouseGetPos()
        Sleep(100)
INIWRITE("FarmBotBeta4.ini", "Calibrate", "LastX", $GetCrop[0])
INIWRITE("FarmBotBeta4.ini", "Calibrate", "LastY", $GetCrop[1])
        
        MsgBox(0, "Crop Select", "Place curser over Left Crop and Press: [ENTER]")
        $GetCrop = MouseGetPos()
        Sleep(100)
INIWRITE("FarmBotBeta4.ini", "Calibrate", "LeftX", $GetCrop[0])
INIWRITE("FarmBotBeta4.ini", "Calibrate", "LeftY", $GetCrop[1])
        
        MsgBox(0, "Crop Select", "Place curser over Right Crop and Press: [ENTER]")
        $GetCrop = MouseGetPos()
        Sleep(100)
INIWRITE("FarmBotBeta4.ini", "Calibrate", "RightX", $GetCrop[0])
INIWRITE("FarmBotBeta4.ini", "Calibrate", "RightY", $GetCrop[1])
        Sleep(500)
    ;===================================================================================
    
    
    ;=============LOCAL VARIABLES LIST===================================================
    Local $FirstX = IniRead("FarmBotBeta4.ini", "Calibrate", "FirstX", "Error")
    Local $FirstY = IniRead("FarmBotBeta4.ini", "Calibrate", "FirstY", "Error")
    Local $LastX = IniRead("FarmBotBeta4.ini", "Calibrate", "LastX", "Error")
    Local $LastY = IniRead("FarmBotBeta4.ini", "Calibrate", "LastY", "Error")
    Local $LeftX = IniRead("FarmBotBeta4.ini", "Calibrate", "LeftX", "ERROR")
    Local $LeftY = IniRead("FarmBotBeta4.ini", "Calibrate", "LeftY", "ERROR")
    Local $RightX = IniRead("FarmBotBeta4.ini", "Calibrate", "RightX", "ERROR")
    Local $RightY = IniRead("FarmBotBeta4.ini", "Calibrate", "RightY", "ERROR")
    Local $1StepX = $RightX - $FirstX
    Local $1StepY = $RightY - $FirstY
    Local $2StepX = $1StepX /19
    Local $2StepY = $1StepY /19
    Local $3StepX = 25
    Local $3StepY = 12
    Local $ColWidth = Round($1StepX / 25) + 1 ;Should return a value of 20 on my current farm.
    INIWRITE("FarmBotBeta4.ini", "Calibrate", "ColWidth", $ColWidth)
    Local $GetCrop[2];Not sure if this variable def is redundent.. may not be needed
    Local $ColX = $FirstX
    Local $ColY = $FirstY
    Local $Counting = 0
    Local $CropNum = 1
    Local $Label1[576];Set to max num of fields available in farmville 24x24=576
    Local $CropCoords[2]
    Local $3BStepX = 25
    Local $3BStepY = -12
    ;Local $nMsg = 0
    ;=====================================================================================
    
While $Counting < $ColWidth 
    ;Do 
    Local $i = 0
    
        If $Counting = $ColWidth then ExitLoop
        While $i <= $ColWidth
    
                $TrueStepX = $i * $3StepX
                $TrueStepY = $i * $3StepY
            
                If $i = $ColWidth then EXITLOOP
                ;$Label1[$CropNum] = GUICtrlCreateLabel($CropNum, Round($ColX + $TrueStepX, 0), Round($ColY + $TrueStepY, 0), 12, 12, $SS_Notify)
                $Label1[$CropNum] = GUICtrlCreateButton($CropNum, Round($ColX + $TrueStepX, 0), Round($ColY + $TrueStepY, 0), 12, 12, -1)
                
                ;IF THIS TEST SCRIPT SECTION DOESNT WORK. USE OLD SECTION BELOW
                INIWRITE("Crops.ini", $CropNum, "XY", Round($ColX + $TrueStepX, 0) & "," & Round($ColY + $TrueStepY, 0))
                ;INIWRITE("Crops.ini", $CropNum, "Y", Round($ColY + $TrueStepY, 0))
                ;END NEW SECTION - BEGIN OLD SECTION
                
                $i = $i + 1
                $CropNum = $CropNum + 1 ; This counts total amount of crops
        
        WEnd
        
    $ColX = $ColX - Round($3BStepX, 0)
    $ColY = $ColY - Round($3BStepY, 0)
    $Counting = $Counting + 1

    ;Until $Counting > $ColWidth
Wend
    ;Msgbox(0, "TEST", "Made it out of loop")
    ;GUISetState($PicMain, $GUI_FOCUS)
    While 1
    ;   sleep(100)
    $nMsg = GUIGetMsg()
        Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

      ; Case $Label1[0]
     ;       MsgBox(0,"", "You pushed the Button 0" & $Label1[0])
    ;GUICtrlSetBkColor($Label1[0], $GUI_BKCOLOR_TRANSPARENT)
    ;   GUICtrlSetColor ( $Label1[0], 0xFF0000)
            Case $Label1[1]
            MsgBox(0,"", "You pushed the Button 1" & $Label1[1])
            GUICtrlSetBkColor($Label1[1], $GUI_BKCOLOR_TRANSPARENT)
            GUICtrlSetColor ( $Label1[1], 0x00ff00)
            Case $Label1[2]
            MsgBox(0,"", "You pushed the Button 2" & $Label1[2])
            GUICtrlSetBkColor($Label1[2], $GUI_BKCOLOR_TRANSPARENT)
            GUICtrlSetColor ( $Label1[2], 0x00ff00)
            Case $Label1[3]
            MsgBox(0,"", "You pushed the Button 3" & $Label1[3])
            GUICtrlSetBkColor($Label1[3], $GUI_BKCOLOR_TRANSPARENT)
            GUICtrlSetColor ( $Label1[3], 0x00ff00)
            Case $Label1[4]
            MsgBox(0,"", "You pushed the Button 4" & $Label1[4])
            GUICtrlSetBkColor($Label1[4], $GUI_BKCOLOR_TRANSPARENT)
            GUICtrlSetColor ( $Label1[4], 0x00ff00)
;       
    EndSwitch
WEnd
        
    EndFunc
Link to comment
Share on other sites

Ok, figured it out. You forgot to disable the background picture. Two controls can't overlap or they negate each other. So immediately after this line

GLOBAL $ImgForm = GUICtrlCreatePic("map.JPG", 0, 0, 1024, 768); places picture in new window

add this line

GuiCtrlSetState(-1,$GUI_DISABLE)
Edited by picea892
Link to comment
Share on other sites

Wow, thanks! I didn't realize i had to disable the image control, ive been playing with the loops and case statements all day and never thought about the image control being the problem. thanks a bunch! In case you didn't realize. Your solution worked exactly as expected. Thanks again.

Link to comment
Share on other sites

Glad I could help. I'm sure all your messing around today won't go to waste, you've probably learned a great deal.

Another couple of points for the future

1) you'll get better help if you post working code. I had to mess around getting it to work with includes, a picture etc. before I could look at the code.

2) Instead of using messageboxs to troubleshoot you can run the code in scite by pressing f5. Then use consolewrite to write text to the console. Or you could use tooltips. Both of these methods have the benefit of not stopping the code.

Good luck to you.

Picea

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