i cancelled all the old plans and followed snappy's advice.
i created three different programs
(clickers
), each one does a different function.
one for play toggle
one for rewind one minute
one for rewind ten seconds
then i used henri's j7xxkeys and linked the external keys to my three progs. everything is working smoothly now.
here's the code of rewind one minute:
--------------------------------------------
Option Explicit
' declarations for the mouse events
Public Declare Sub mouse_event Lib "coredll"
(ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal dwData As Long, ByVal dwExtraInfo As Long
)
Const MOUSEEVENTF_MOVE = &H1 ' mouse move
Const MOUSEEVENTF_LEFTDOWN = &H2 ' left button down
Const MOUSEEVENTF_LEFTUP = &H4 ' left button up
Const MOUSEEVENTF_RIGHTDOWN = &H8 ' right button down
Const MOUSEEVENTF_RIGHTUP = &H10 ' right button up
Const MOUSEEVENTF_MIDDLEDOWN = &H20 ' middle button down
Const MOUSEEVENTF_MIDDLEUP = &H40 ' middle button up
Const MOUSEEVENTF_WHEEL = &H800 ' wheel button rolled
Const MOUSEEVENTF_ABSOLUTE = &H8000 ' absolute move
Public Declare Function Sleep Lib "coredll"
(ByVal lmsecs As Long
) As Long
Sub Main
(
)
RewindOneMinute
End Sub
' A left-button mouse click at pixel coords X and Y
Public Sub PerformMouseClick
(ByVal X As Long, ByVal Y As Long
)
Dim lFlags As Long
Dim MX As Long, MY As Long
lFlags = MOUSEEVENTF_ABSOLUTE Or MOUSEEVENTF_LEFTDOWN
' Mickey coordinates needed for mouse_event range from 0 through 65535
MX = Int
(
(65536 / 640
) * X
)
MY = Int
(
(65536 / 240
) * Y
)
mouse_event lFlags, MX, MY, 0, 0
lFlags = MOUSEEVENTF_LEFTUP
mouse_event lFlags, 0, 0, 0, 0
End Sub
Public Sub PlayToggle
(
)
PerformMouseClick 120, 10
Sleep 500
PerformMouseClick 120, 20
End Sub
Public Sub RewindOneMinute
(
)
PerformMouseClick 120, 10
Sleep 500
PerformMouseClick 120, 160
Sleep 500
PlayToggle
End Sub
-------------------------------------------------
the application is formless. it runs and exits automatically once all lines have been executed.
very easy solution
thanks snappy! and everyone for the tips and help.
msafi,