Jump to content

Right button Clic on the eny Ctrl and exec UDF


novi
 Share

Recommended Posts

Hola, Perdonen que hable en mi lenguaje nativo. Pueden utilizar Google como yo para traducir el mensaje

:)

Como ha habido tanta demanda por un script que pueda ejecutar una UDF asociada al evento Clic derecho del mouse, entre los cuales me encontraba yo también, me decidí a realizar un script simple que pueda dar respuesta a esto. El código puede mejorarse y no le añadí control de errores. Solo es la idea. A ustedes les toca perfeccionarlo. Disfrútenlo!

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Global $posMouse
Global $ArrayIDControl[1]
Opt("GUIOnEventMode", 1)
Opt("MouseCoordMode",0)
Opt("GUICoordMode",1)
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("My GUI Right Button Command Event", 410, 234, 197, 143)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form2Close")
$Button1 = GUICtrlCreateButton("Button1", 16, 72, 89, 25, 0)
_GUICtrlStoreDatos(-1,"_Yor")
$Label1 = GUICtrlCreateLabel("Label1", 40, 120, 36, 17)
_GUICtrlStoreDatos(-1,"_Yor2")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


While 1
    Sleep(100)
    $posMouse = GUIGetCursorInfo ($Form1)
    If $posMouse[3] = 1 Then
    CheckControlList($posMouse[4])
    EndIf
WEnd

func Form2Close()
Exit    
EndFunc


func _Yor()
MsgBox(0,"","Yea!") 
EndFunc

func _Yor2()
MsgBox(0,"","Yea! another") 
EndFunc


;Store the ID of controls and Function Name
;$IDControl = Id del control (-1 también es posible)
;$Function = funcionName
func _GUICtrlStoreDatos($IDControl,$Function)
Local $Pos,$Funct
;estableciendo el ID de control para -1
If $IDControl = -1 Then $IDControl = _GUIGetLastCtrlID()
redim $ArrayIDControl[UBound($ArrayIDControl)+1]
$ArrayIDControl[UBound($ArrayIDControl)-1] = $IDControl&@TAB&$Function
$ArrayIDControl[0] += 1
EndFunc

;Get the ControlID for last Control Created
Func _GUIGetLastCtrlID()

    Local $aRet = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", GUICtrlGetHandle(-1))
    Return $aRet[0]

EndFunc ;==>_GUIGetLastCtrlID



;Chequea si el control está en la lista y ejecuta la función asociada.
func CheckControlList($IDControl)
Local $i,$datos
for $i = 1 to $ArrayIDControl[0]
$datos = StringSplit($ArrayIDControl[$i],@TAB,1);separando el id del FuncName
if $datos[1] = $IDControl then 
    call($datos[2])
    ExitLoop
EndIf
Next
EndFunc
Edited by novi

[COLOR=green]

Link to comment
Share on other sites

Hola, Perdonen que hable en mi lenguaje nativo. Pueden utilizar Google como yo para traducir el mensaje

:)

Como ha habido tanta demanda por un script que pueda ejecutar una UDF asociada al evento Clic derecho del mouse, entre los cuales me encontraba yo también, me decidí a realizar un script simple que pueda dar respuesta a esto. El código puede mejorarse y no le añadí control de errores. Solo es la idea. A ustedes les toca perfeccionarlo. Disfrútenlo!

bien hecho, muy útil

very useful script, worked well for me.

[u]You can download my projects at:[/u] Pulsar Software
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...