stutter
Joined: 13 Feb 2008 Posts: 11
|
Posted: Wed Jul 16, 2008 10:18 pm Post subject: Midi In and SetTimer help |
|
|
Hi,
I have a script which takes advantage of the midi input .dll and .lib here.
I have a single midi knob which sends out cc122, 1 when turned left, cc123, 65 when turned right - I am effectively trying to translate this into a mouseclickdrag, so that when I turn the knob to the right the mouse clicks down, moves diagonally up and right, and is then released. Vice versa when moved to the left.
Using mouseclickdrag I get a series of down, drag, up messages for each "degree" I turn the knob. I want to set some kind of timers, so that when I start to turn the knob I get a click down, and when i stop moving the knob I get a click up.
Here's what I have
| Code: | #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%
OnExit, sub_exit
;midi_in_Start()
if (midi_in_Open(10))
ExitApp
Bstate = 0
;-------------------- Midi "hotkey" mappings -----------------------
listenCC(122, "DialL", 16)
listenCC(123, "DialR", 16)
return
;----------------------End of auto execute section--------------------
sub_exit:
midi_in_Stop()
midi_in_Close()
ExitApp
;-------------------------Miscellaneous hotkeys-----------------------
^Esc::ExitApp
;-------------------------Midi "hotkey" functions---------------------
DialL(Note,Vel)
{
if (1)
GoSub TurnLeft
}
return
DialR(Note,Vel)
{
if (65)
GoSub TurnRight
}
return
;------------------------- Midi input library ----------------------
#include midi_in_lib.ahk
;------------------------- Subs ----------------------
TurnLeft:
{
GetKeyState, state, LButton
if state = d
{
Mousemove, -2, 2, 1, r
}
else
{
Click down
Mousemove, -2, 2, 1, r
}
}
return
TurnRight:
{
GetKeyState, state, LButton
if state = d
{
Mousemove, 2, -2, 1, r
}
else
{
Click down
Mousemove, 2, -2, 1, r
}
}
return
NoInput:
{
Click up
Mousemove, xpos, ypos
}
return |
Since I could not understand how to successfully do this with mouseclickdrag, I have set up subroutines for click down and mousemove when turning the knob left or right. I have a subroutine called NoInput I would like to execute when the knob stops moving. I have never used SetTimer before, and I cannot understand from the examples where in my script I would need to use it... I guess somewhere in the "DialL/R" parts, with some increment - but I tried and failed, and then deleted my attempts. The code as it stands will click down and drag as required, but will not click up, since it does not recognise when I have stopped moving the knob. |
|