problema Visual Basic, ayuda por favor

17/07/2003 - 12:41 por Mikel | Informe spam
Nos estamos volviendo locos buscando la forma de hacer una
cosa que no sabemos si se puede hacer.
Queremos manejar el ratón através del teclado en todo el
entorno windows para personas con discapacidades físicas.
Tenemos todas las funciones hechas de prueba en un
formulario y queremos que funcione en modo "residente". No
sabemos si tenemos que hacer una dll. En definitiva
queremos tener el control del teclado sin formularios, asi
nos evitamos problemas con el control del foco.
gracias por prestar atención. Saludos

Preguntas similare

Leer las respuestas

#1 Tomás
17/07/2003 - 13:59 | Informe spam
Solución 1: Puedes usar una pantalla táctil. Son muy baratas ahora pero no
en el sector informático. Si quieres precios envíame un mail ;)

Solución 2: Apis.

Declare Function SetCursorPos Lib "user32" Alias "SetCursorPos" (ByVal x As
Long, ByVal y As Long) As Long

Definicion :

The SetCursorPos function moves the cursor to the specified screen
coordinates. If the new coordinates are not within the screen rectangle set
by the most recent ClipCursor function, Windows automatically adjusts the
coordinates so that the cursor stays within the rectangle.

Ejemplo extraído del api-guide

'This project needs

'a Form, called 'Form1'

'a Picture Box, called 'ExplButton' (50x50 pixels)

'a Picture Box with an icon in it, called 'picIcon'

'two timers (Timer1 and Timer2), both with interval 100

'Button, called 'Command1'

'In general section

Private Type RECT

Left As Long

Top As Long

Right As Long

Bottom As Long

End Type

Private Type POINTAPI

X As Long

Y As Long

End Type

'Declare the API-Functions

Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As
Long

Private Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y
As Long) As Long

Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long,
lpRect As RECT) As Long

Sub DrawButton(Pushed As Boolean)

Dim Clr1 As Long, Clr2 As Long

If Pushed = True Then

'If Pushed=True then clr1=Dark Gray

Clr1 = &H808080

'If Pushed=True then clr1=White

Clr2 = &HFFFFFF

ElseIf Pushed = False Then

'If Pushed=True then clr1=White

Clr1 = &HFFFFFF

'If Pushed=True then clr1=Dark Gray

Clr2 = &H808080

End If

With Form1.ExplButton

' Draw the button

Form1.ExplButton.Line (0, 0)-(.ScaleWidth, 0), Clr1

Form1.ExplButton.Line (0, 0)-(0, .ScaleHeight), Clr1

Form1.ExplButton.Line (.ScaleWidth - 1, .ScaleHeight - 1)-(.ScaleWidth - 1,
0), Clr2

Form1.ExplButton.Line (.ScaleWidth - 1, .ScaleHeight - 1)-(0, .ScaleHeight -
1), Clr2

End With

End Sub

Private Sub Command1_Click()

Dim Rec As RECT

'Get Left, Right, Top and Bottom of Form1

GetWindowRect Form1.hwnd, Rec

'Set Cursor position on X

SetCursorPos Rec.Right - 15, Rec.Top + 15

End Sub

Private Sub ExplButton_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)

DrawButton True

End Sub

Private Sub ExplButton_MouseMove(Button As Integer, Shift As Integer, X As
Single, Y As Single)

DrawButton False

End Sub

Private Sub ExplButton_MouseUp(Button As Integer, Shift As Integer, X As
Single, Y As Single)

DrawButton False

End Sub

Private Sub Form_Load()

'KPD-Team 1998

'URL: http://www.allapi.net/

'E-Mail:

Dim Stretched As Boolean

'picIcon.Visible = False

'API uses pixels

picIcon.ScaleMode = vbPixels

'No border

ExplButton.BorderStyle = 0

'API uses pixels

ExplButton.ScaleMode = vbPixels

'Set graphic mode te 'persistent graphic'

ExplButton.AutoRedraw = True

'API uses pixels

Me.ScaleMode = vbPixels

'Set the button's caption

Command1.Caption = "Set Mousecursor on X"

' If you set Stretched to true then stretch the icon to te Height and Width
of the button

' If Stretched=False, the icon will be centered

Stretched = False

If Stretched = True Then

' Stretch the Icon

ExplButton.PaintPicture picIcon.Picture, 1, 1, ExplButton.ScaleWidth - 2,
ExplButton.ScaleHeight - 2

ElseIf Stretched = False Then

' Center the picture of the icon

ExplButton.PaintPicture picIcon.Picture, (ExplButton.ScaleWidth -
picIcon.ScaleWidth) / 2, (ExplButton.ScaleHeight - picIcon.ScaleHeight) / 2

End If

' Set icon as picture

ExplButton.Picture = ExplButton.Image

End Sub

Private Sub Timer1_Timer()

Dim Rec As RECT, Point As POINTAPI

' Get Left, Right, Top and Bottom of Form1

GetWindowRect Me.hwnd, Rec

' Get the position of the cursor

GetCursorPos Point

' If the cursor is located above the form then

If Point.X >= Rec.Left And Point.X <= Rec.Right And Point.Y >= Rec.Top And
Point.Y <= Rec.Bottom Then

Me.Caption = "MouseCursor is on form."

Else

' The cursor is not located above the form

Me.Caption = "MouseCursor is not on form."

End If

End Sub

Private Sub Timer2_Timer()

Dim Rec As RECT, Point As POINTAPI

' Get Left, Right, Top and Bottom of ExplButton

GetWindowRect ExplButton.hwnd, Rec

' Get the position of the cursor

GetCursorPos Point

' If the cursor isn't located above ExplButton then

If Point.X < Rec.Left Or Point.X > Rec.Right Or Point.Y < Rec.Top Or Point.Y
Rec.Bottom Then ExplButton.Cls



End Sub
Respuesta Responder a este mensaje
#2 Mikel
17/07/2003 - 14:18 | Informe spam
Gracias por contestar Tomás. Ya estamos utilizando
bastantes funciones API incluida SetCursorPos pero ese no
es el problema. Queremos que el programa se ejecute
digamos en "background"
para evitarnos problemas con el foco. Tambien dudamos si
decantarnos por un ejecutable o por una dll. Muchas
gracias de nuevo.



Solución 1: Puedes usar una pantalla táctil. Son muy


baratas ahora pero no
en el sector informático. Si quieres precios envíame un


mail ;)

Solución 2: Apis.

Declare Function SetCursorPos Lib "user32"


Alias "SetCursorPos" (ByVal x As
Long, ByVal y As Long) As Long

Definicion :

The SetCursorPos function moves the cursor to the


specified screen
coordinates. If the new coordinates are not within the


screen rectangle set
by the most recent ClipCursor function, Windows


automatically adjusts the
coordinates so that the cursor stays within the rectangle.

Ejemplo extraído del api-guide

'This project needs

'a Form, called 'Form1'

'a Picture Box, called 'ExplButton' (50x50 pixels)

'a Picture Box with an icon in it, called 'picIcon'

'two timers (Timer1 and Timer2), both with interval 100

'Button, called 'Command1'

'In general section

Private Type RECT

Left As Long

Top As Long

Right As Long

Bottom As Long

End Type

Private Type POINTAPI

X As Long

Y As Long

End Type

'Declare the API-Functions

Private Declare Function GetCursorPos Lib "user32"


(lpPoint As POINTAPI) As
Long

Private Declare Function SetCursorPos Lib "user32" (ByVal


X As Long, ByVal Y
As Long) As Long

Private Declare Function GetWindowRect Lib "user32"


(ByVal hwnd As Long,
lpRect As RECT) As Long

Sub DrawButton(Pushed As Boolean)

Dim Clr1 As Long, Clr2 As Long

If Pushed = True Then

'If Pushed=True then clr1=Dark Gray

Clr1 = &H808080

'If Pushed=True then clr1=White

Clr2 = &HFFFFFF

ElseIf Pushed = False Then

'If Pushed=True then clr1=White

Clr1 = &HFFFFFF

'If Pushed=True then clr1=Dark Gray

Clr2 = &H808080

End If

With Form1.ExplButton

' Draw the button

Form1.ExplButton.Line (0, 0)-(.ScaleWidth, 0), Clr1

Form1.ExplButton.Line (0, 0)-(0, .ScaleHeight), Clr1

Form1.ExplButton.Line (.ScaleWidth - 1, .ScaleHeight - 1)-


(.ScaleWidth - 1,
0), Clr2

Form1.ExplButton.Line (.ScaleWidth - 1, .ScaleHeight - 1)-


(0, .ScaleHeight -
1), Clr2

End With

End Sub

Private Sub Command1_Click()

Dim Rec As RECT

'Get Left, Right, Top and Bottom of Form1

GetWindowRect Form1.hwnd, Rec

'Set Cursor position on X

SetCursorPos Rec.Right - 15, Rec.Top + 15

End Sub

Private Sub ExplButton_MouseDown(Button As Integer, Shift


As Integer, X As
Single, Y As Single)

DrawButton True

End Sub

Private Sub ExplButton_MouseMove(Button As Integer, Shift


As Integer, X As
Single, Y As Single)

DrawButton False

End Sub

Private Sub ExplButton_MouseUp(Button As Integer, Shift


As Integer, X As
Single, Y As Single)

DrawButton False

End Sub

Private Sub Form_Load()

'KPD-Team 1998

'URL: http://www.allapi.net/

'E-Mail:

Dim Stretched As Boolean

'picIcon.Visible = False

'API uses pixels

picIcon.ScaleMode = vbPixels

'No border

ExplButton.BorderStyle = 0

'API uses pixels

ExplButton.ScaleMode = vbPixels

'Set graphic mode te 'persistent graphic'

ExplButton.AutoRedraw = True

'API uses pixels

Me.ScaleMode = vbPixels

'Set the button's caption

Command1.Caption = "Set Mousecursor on X"

' If you set Stretched to true then stretch the icon to


te Height and Width
of the button

' If Stretched=False, the icon will be centered

Stretched = False

If Stretched = True Then

' Stretch the Icon

ExplButton.PaintPicture picIcon.Picture, 1, 1,


ExplButton.ScaleWidth - 2,
ExplButton.ScaleHeight - 2

ElseIf Stretched = False Then

' Center the picture of the icon

ExplButton.PaintPicture picIcon.Picture,


(ExplButton.ScaleWidth -
picIcon.ScaleWidth) / 2, (ExplButton.ScaleHeight -


picIcon.ScaleHeight) / 2

End If

' Set icon as picture

ExplButton.Picture = ExplButton.Image

End Sub

Private Sub Timer1_Timer()

Dim Rec As RECT, Point As POINTAPI

' Get Left, Right, Top and Bottom of Form1

GetWindowRect Me.hwnd, Rec

' Get the position of the cursor

GetCursorPos Point

' If the cursor is located above the form then

If Point.X >= Rec.Left And Point.X <= Rec.Right And


Point.Y >= Rec.Top And
Point.Y <= Rec.Bottom Then

Me.Caption = "MouseCursor is on form."

Else

' The cursor is not located above the form

Me.Caption = "MouseCursor is not on form."

End If

End Sub

Private Sub Timer2_Timer()

Dim Rec As RECT, Point As POINTAPI

' Get Left, Right, Top and Bottom of ExplButton

GetWindowRect ExplButton.hwnd, Rec

' Get the position of the cursor

GetCursorPos Point

' If the cursor isn't located above ExplButton then

If Point.X < Rec.Left Or Point.X > Rec.Right Or Point.Y <


Rec.Top Or Point.Y
Rec.Bottom Then ExplButton.Cls



End Sub



.

Respuesta Responder a este mensaje
#3 Manuel Romero
17/07/2003 - 18:57 | Informe spam
Tengo entendido que Windows ya hace eso con las herramientas de
accesibilidad

"Mikel" escribió en el mensaje
news:081b01c34c4f$eb5f13f0$
Nos estamos volviendo locos buscando la forma de hacer una
cosa que no sabemos si se puede hacer.
Queremos manejar el ratón através del teclado en todo el
entorno windows para personas con discapacidades físicas.
Tenemos todas las funciones hechas de prueba en un
formulario y queremos que funcione en modo "residente". No
sabemos si tenemos que hacer una dll. En definitiva
queremos tener el control del teclado sin formularios, asi
nos evitamos problemas con el control del foco.
gracias por prestar atención. Saludos
email Siga el debate Respuesta Responder a este mensaje
Ads by Google
Help Hacer una preguntaRespuesta Tengo una respuesta
Search Busqueda sugerida