AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Midi In and SetTimer help

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
stutter



Joined: 13 Feb 2008
Posts: 11

PostPosted: Wed Jul 16, 2008 10:18 pm    Post subject: Midi In and SetTimer help Reply with quote

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.
Back to top
View user's profile Send private message
Guest






PostPosted: Sun Oct 26, 2008 1:27 am    Post subject: Reply with quote

avoid mixturing functions with labels without global set for variables..
Back to top
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group