Not exactly sure what is not working. Looks good to me.
I do not know where you got this code, but it seems kind of oldish. No offense. Here a streamlined version :
#include <GUIConstants.au3>
#include <Constants.au3>
#include <WinAPISysWin.au3>
#include <GuiMenu.au3>
#NoTrayIcon
Opt("MustDeclareVars", True)
Prin()
Func Prin()
Local $hGUI = GUICreate("Ingreso", 601, 201, IniRead("coord.ini", "Position", "X-Pos", 0), IniRead("coord.ini", "Position", "Y-Pos", 0))
GUISetBkColor(0xFFFFFF)
GUICtrlSetFont(-1, 12, 800, 0, "Times New Roman")
Local $Button2 = GUICtrlCreateButton("Ingreso", 24, 152, 161, 33)
GUICtrlSetFont(-1, 12, 400, 2, "Times New Roman")
GUICtrlSetCursor(-1, 0)
Local $ingreDummy = GUICtrlCreateDummy()
Local $ingreContext = GUICtrlCreateContextMenu($ingreDummy)
Local $PP = GUICtrlCreateMenuItem("He", $ingreContext)
Local $PT = GUICtrlCreateMenuItem("Hi", $ingreContext)
Local $Button3 = GUICtrlCreateButton("Ingreso d", 216, 152, 161, 33)
GUICtrlSetFont(-1, 12, 400, 2, "Times New Roman")
GUICtrlSetCursor(-1, 0)
Local $resulDummy = GUICtrlCreateDummy()
Local $resulContext = GUICtrlCreateContextMenu($resulDummy)
Local $RP = GUICtrlCreateMenuItem("lol", $resulContext)
Local $RT = GUICtrlCreateMenuItem("Cool", $resulContext)
Local $RA = GUICtrlCreateMenuItem("holl", $resulContext)
Local $Button4 = GUICtrlCreateButton("Busqueda", 410, 152, 161, 33)
GUICtrlSetFont(-1, 12, 400, 2, "Times New Roman")
GUICtrlSetCursor(-1, 0)
Local $busqueDummy = GUICtrlCreateDummy()
Local $busqueContext = GUICtrlCreateContextMenu($busqueDummy)
Local $BP = GUICtrlCreateMenuItem("cool", $busqueContext)
Local $BT = GUICtrlCreateMenuItem("roll", $busqueContext)
Local $BA = GUICtrlCreateMenuItem("jkl", $busqueContext)
GUISetState()
GUIRegisterMsg($WM_MOVE, WM_MOVE)
Local $nMsg
While True
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button2
ShowMenu($hGUI, $nMsg, $ingreContext)
Case $PP
ConsoleWrite("test" & @CRLF)
Case $PT
Case $Button3
ShowMenu($hGUI, $nMsg, $resulContext)
Case $RP
Case $RT
Case $RA
Case $Button4
ShowMenu($hGUI, $nMsg, $busqueContext)
Case $BP
Case $BT
Case $BA
EndSwitch
WEnd
EndFunc ;==>Prin
Func ShowMenu($hWnd, $idCtrl, $idContext)
Local $hMenu = GUICtrlGetHandle($idContext)
Local $aPos = ControlGetPos($hWnd, "", $idCtrl)
Local $tPoint = DllStructCreate($tagPOINT)
$tPoint.X = $aPos[0]
$tPoint.Y = $aPos[1] + $aPos[3]
_WinAPI_ClientToScreen($hWnd, $tPoint)
_GUICtrlMenu_TrackPopupMenu($hMenu, $hWnd, $tPoint.X, $tPoint.Y)
EndFunc ;==>ShowMenu
Func WM_MOVE($hWnd, $iMsg, $wParam, $lParam)
Local $aPos = WinGetPos($hWnd)
IniWrite("Coord.ini", "Position", "X-Pos", $aPos[0])
IniWrite("Coord.ini", "Position", "Y-Pos", $aPos[1])
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_MOVE