Kevitto Posted May 2, 2010 Posted May 2, 2010 Hey guys, I'm new. Been working with AutoIT for a while now, love it Anyways, been trying to develop a super simple game on it (somewhat simple) but I'm baffled by a problem that just arose... I use the code for clickable labels: Func _LabelClicked($sg_GUI, $sl_Label, $s_hexKey = '01', $st_Text = '', $v_dll = 'user32.dll') Local $Opt = Opt('MouseCoordMode', 2) Local $a_R = DllCall($v_dll, "int", "GetAsyncKeyState", "int", '0x' & $s_hexKey) If Not @Error And BitAND($a_R[0], 0x8000) = 0x8000 Then Local $lab_Pos = ControlGetPos($sg_GUI, $st_Text, $sl_Label) Local $lab_Mouse = MouseGetPos() Opt('MouseCoordMode', $Opt) If IsArray($lab_Mouse) And IsArray($lab_Pos) Then If $lab_Mouse[0] >= $lab_Pos[0] And $lab_Mouse[0] <= $lab_Pos[0] + $lab_Pos[2] And $lab_Mouse[1] >= $lab_Pos[1] _ And $lab_Mouse[1] <= $lab_Pos[1] + $lab_Pos[3] Then Return 1 EndIf EndIf Return 0 EndFunc I found online, but the labels are NOT created on launch, they are created dynamically and move. Now, with my selection code: expandcollapse popup$msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case _LabelClicked($GDRR, $Enemy[0]) If $Wpn_Charging = 100 Then EnemyHit($Enemy[0], 0) If $Enemy_HP1[0] < 1 Then EnemyKilled($Enemy[0], 0) EndIf $Wpn_Charging = 0 GUICtrlSetData($Wpn_Charge, $Wpn_Charging) EndIf Case _LabelClicked($GDRR, $Enemy[1]) If $Wpn_Charging = 100 Then EnemyHit($Enemy[1], 1) If $Enemy_HP1[1] < 1 Then EnemyKilled($Enemy[1], 1) EndIf $Wpn_Charging = 0 GUICtrlSetData($Wpn_Charge, $Wpn_Charging) EndIf Case _LabelClicked($GDRR, $Enemy[2]) If $Wpn_Charging = 100 Then EnemyHit($Enemy[2], 2) If $Enemy_HP1[2] < 1 Then EnemyKilled($Enemy[2], 2) EndIf $Wpn_Charging = 0 GUICtrlSetData($Wpn_Charge, $Wpn_Charging) EndIf Case _LabelClicked($GDRR, $Enemy[3]) If $Wpn_Charging = 100 Then EnemyHit($Enemy[3], 3) If $Enemy_HP1[3] < 1 Then EnemyKilled($Enemy[3], 3) EndIf $Wpn_Charging = 0 GUICtrlSetData($Wpn_Charge, $Wpn_Charging) EndIf Case _LabelClicked($GDRR, $Enemy[4]) If $Wpn_Charging = 100 Then EnemyHit($Enemy[4], 4) If $Enemy_HP1[4] < 1 Then EnemyKilled($Enemy[4], 4) EndIf $Wpn_Charging = 0 GUICtrlSetData($Wpn_Charge, $Wpn_Charging) EndIf Case _LabelClicked($GDRR, $Enemy[5]) If $Wpn_Charging = 100 Then EnemyHit($Enemy[5], 5) If $Enemy_HP1[5] < 1 Then EnemyKilled($Enemy[5], 5) EndIf $Wpn_Charging = 0 GUICtrlSetData($Wpn_Charge, $Wpn_Charging) EndIf Case _LabelClicked($GDRR, $Enemy[6]) If $Wpn_Charging = 100 Then EnemyHit($Enemy[6], 6) If $Enemy_HP1[6] < 1 Then EnemyKilled($Enemy[6], 6) EndIf $Wpn_Charging = 0 GUICtrlSetData($Wpn_Charge, $Wpn_Charging) EndIf Case _LabelClicked($GDRR, $Enemy[7]) If $Wpn_Charging = 100 Then EnemyHit($Enemy[7], 7) If $Enemy_HP1[7] < 1 Then EnemyKilled($Enemy[7], 7) EndIf $Wpn_Charging = 0 GUICtrlSetData($Wpn_Charge, $Wpn_Charging) EndIf Case $msg = $Wpn_1 $Wpn_Select = 1 $Wpn_Txt = "Equipped: " & $arrWpn[0] $Wpn_Dmg = $arrWpnDmg[0] * $arrWpnUp[0] GUICtrlSetData( $Wpn_Lbl, $Wpn_Txt) $Wpn_Speed = $arrWpnSpd[0] $Wpn_Charging = 0 GUICtrlSetData($Wpn_Charge, $Wpn_Charging) Case $msg = $Wpn_2 $Wpn_Select = 2 $Wpn_Txt = "Equipped: " & $arrWpn[1] $Wpn_Dmg = $arrWpnDmg[1] * $arrWpnUp[1] GUICtrlSetData( $Wpn_Lbl, $Wpn_Txt) $Wpn_Speed = $arrWpnSpd[1] $Wpn_Charging = 0 GUICtrlSetData($Wpn_Charge, $Wpn_Charging) Case $msg = $Wpn_3 $Wpn_Select = 3 $Wpn_Txt = "Equipped: " & $arrWpn[2] $Wpn_Dmg = $arrWpnDmg[2] * $arrWpnUp[2] GUICtrlSetData( $Wpn_Lbl, $Wpn_Txt) $Wpn_Speed = $arrWpnSpd[2] $Wpn_Charging = 0 GUICtrlSetData($Wpn_Charge, $Wpn_Charging) Case $msg = $Wpn_4 $Wpn_Select = 4 $Wpn_Txt = "Equipped: " & $arrWpn[3] $Wpn_Dmg = $arrWpnDmg[3] * $arrWpnUp[3] GUICtrlSetData( $Wpn_Lbl, $Wpn_Txt) $Wpn_Speed = $arrWpnSpd[3] $Wpn_Charging = 0 GUICtrlSetData($Wpn_Charge, $Wpn_Charging) Case $msg = $Wpn_5 $Wpn_Select = 5 $Wpn_Txt = "Equipped: " & $arrWpn[4] $Wpn_Dmg = $arrWpnDmg[4] * $arrWpnUp[4] GUICtrlSetData( $Wpn_Lbl, $Wpn_Txt) $Wpn_Speed = $arrWpnSpd[4] $Wpn_Charging = 0 GUICtrlSetData($Wpn_Charge, $Wpn_Charging) Case $msg = $Wave_Start WaveStart() GUICtrlSetState($Wave_Start, $GUI_DISABLE) $Wave_Active = 1 EndSelect It registers a click on the labels as SOON as I click any button that's NOT a label. I've scoured the net for hours trying to find something about that, to no avail. So I come to the experts! Thanks for your help in advance. (Yes, the WEnd is at the bottom there, I have more stuff at the bottom that was useless)
Kevitto Posted May 3, 2010 Author Posted May 3, 2010 Ok, well I guess writing in here gave me a little peace of mind because I found the problem. They don't exist. So I changed it so they're stored outside the GUI (-100,-100) and pre-created em all. Tested, working fine. Thanks tho!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now