Attention:

Welcome to the old forum. While it is no longer updated, there is a wealth of information here that you may search and learn from.

To partake in the current forum discussion, please visit https://forums.presonus.com

Notion touchscreen assistant (AHK script)

A Forum to Discuss NOTION

Notion touchscreen assistant (AHK script)

Postby elerouxx » Fri Sep 06, 2013 10:03 pm

Since Notion doesn't support -yet- some essencial features on a touchscreen (right clicking, highlighting and selecting...) I coded a little script in Autohotkey - a floating window with some buttons to make Notion more usable on a device such as mine. I have an Asus Vivotab, which has touch support but no digitizer stylus.

notion_hud.png
notion_hud.png (135.74 KiB) Viewed 2917 times


The window/palette stays on top of Notion and contains the following controls:

ESC - same as the ESC key - deselects anything, cancels other buttons and goes back to the Selection tool

SEL - after clicking this button, touch at two different spots on the score and the GUI will draw a selection box between them.

CTRL - holds down the CTRL key

SHIFT - holds down the SHIFT key (allows selecting several notes by touch)

Up/Down - same as the arrow keys. May be used in combination with CTRL and/or SHIFT buttons, to quickly transpose selected notes by octaves (ctrl+shift), or chromatically (shift).

Equal - Same as the equal ("=") key. May be hit twice to clear articulation of the selected notes, or may be hit once before selecting a note in the notes dropdown list (see next control:)

Note value drop down list: Can be used to select a note value shortcut (w, h, q, e, t, s, j), which is the same as selecting the note value from Notion palette. But, when used right after hitting the '=' button, it converts the selected notes to this value (i.e. select a group of half notes, hit '=' and choose 'q' from the dropdown list, and all selected notes will be converted to quarter notes).

Dot - Add dot to the selected value. Can also add a dot to converted notes after hitting '=' (i.e. select notes in the score, hit '=', select 'e' from the drop down list and then hit the 'Dot' button, and notes will be converted to dotted eight notes).

UNDO - same as CTRL Z

RMB - Right Mouse Button! this button performs a RIGHT CLICK on the last spot that was touched or selected in the score. No need to worry about how to use it, it always right-clicks the right spot.

I can't add a .AHK file to the post, but you can just paste the text below into a text file (i.e. notepad) and savie it as "notion_hud.ahk" or whatever other name with the .ahk extension. It will then open by double-clicking on it, provided that last version of AUTOHOTKEY is installed (free, google it).

I am new to Autohotkey scripting, so feel free to modify the code to make it less crappy. It costed me some braincells, and I just added the tools I miss more. Ask me if you want some button added.


Code: Select all
;GUI for Notion 4 in touchscreen mode
;By Emilio Le Roux (2013)


#SingleInstance force
;Sendmode Input

Gui, Font, s8 norm, Tahoma
Gui, Add, Button, x2 y0 w40 h30 , ESC
Gui, Add, Button, vSelect x42 y0 w40 h30 , SEL
Gui, Add, Button, vCtrldown x82 y0 w40 h30 , CTRL
Gui, Add, Button, vShiftdown x122 y0 w40 h30 , SHIFT
Gui, Add, Button, x162 y0 w40 h30 , Up
Gui, Add, Button, x202 y0 w40 h30 , Down
Gui, Add, DropDownList, vChoice gNotes x282 y6 w40 r7 , w|h|q||e|s|t|j
Gui, Add, Button, x322 y0 w40 h30 , Dot
Gui, Add, Button, x242 y0 w40 h30 , =
Gui, Add, Button, x362 y0 w40 h30, UNDO
Gui, Add, Button, x402 y0 w40 h30 , RMB

; Generated using SmartGUI Creator 4.0

Gui  +AlwaysOnTop +ToolWindow
Gui, Show, x195 y212 h34 w446, Notion 4 Touchscreen Assistant

#Persistent
CoordMode, Mouse, Screen
SetTimer, TrackTouch, 50

touchX :=1
touchY :=1

tapX :=1
tapY :=1

cancelSelect := 0

return


TrackTouch:

   MouseGetPos, currentX, currentY, wid, control
   if (control = "TTkScoreView1")
   {
      touchX := currentX
      touchY := currentY
   }
         
return



WaitForTap:

jumped := 0
beforeX := touchX
beforeY := touchY
while (!jumped)
{
   sleep 50   
   if cancelSelect
      break
   MouseGetPos, afterX, afterY, wid, control
   if (control = "TTkScoreView1")
   {
      if (Abs(afterX - beforeX) >20 or Abs(afterY - beforeY) >20 )
      {
         ;jump detected
         jumped := 1
         tapX := afterX
         tapY := afterY
         
      }
      beforeX := afterX
      beforeY := afterY
   
   }
}
   
return



resetButtons:
   ;reset all modifier/active buttons

   Gui, Font, s8 norm, Tahoma
       GuiControl, Font, Shiftdown
   GuiControl, Font, Ctrldown
   GuiControl, Font, Select
   WinActivate, ahk_class TTkScoreWindow
   ;sleep 50   
   Send {Shift Up}
   Send {Ctrl Up}
   

return



Notes:
   GuiControlGet, notevalue,,Choice
   ;sleep 50
   WinActivate, ahk_class TTkScoreWindow
   sleep 100
   Send {%notevalue%}
   
return

button=:
   WinActivate, ahk_class TTkScoreWindow
   ;sleep 50
   Send {=}
return

buttonDot:
   WinActivate, ahk_class TTkScoreWindow
   ;sleep 50
   Send d
return

   
buttonSHIFT:
   cancelSelect := 1
   GetKeyState, state, Shift
   if state = D
   {
      Gui, Font, s8 norm, Tahoma
          GuiControl, Font, Shiftdown
         WinActivate, ahk_class TTkScoreWindow
      ;sleep 50
      Send {Shift Up}
   }
   else
   {
      Gui, Font, s8 bold, Tahoma
          GuiControl, Font, Shiftdown
         WinActivate, ahk_class TTkScoreWindow   
      ;sleep 50
         Send {Shift Down}
   }
return


buttonCTRL:
   cancelSelect := 1
   GetKeyState, state, Ctrl
   if state = D
   {
      Gui, Font, s8 norm, Tahoma
          GuiControl, Font, Ctrldown
          Send {Ctrl Up}
        ;sleep 50
          WinActivate, ahk_class TTkScoreWindow
   }
   else
   {
      Gui, Font, s8 bold, Tahoma
          GuiControl, Font, Ctrldown
          WinActivate, ahk_class TTkScoreWindow
      ;sleep 50   
          Send {Ctrl Down}
   }
return


buttonUp:
   WinActivate, ahk_class TTkScoreWindow
   sleep 100
   Send {up}
return


buttonDown:
   WinActivate, ahk_class TTkScoreWindow
   sleep 100
   Send {down}
return



buttonSEL:
   Gosub, resetButtons
   cancelSelect := 0
   WinActivate, ahk_class TTkScoreWindow
   ;sleep 50
   send {Esc}

   ;sleep 50
   
   Gui, Font, s8 bold, Tahoma
   GuiControl, Font, Select

   Gosub, WaitForTap
   
         
   fromX := tapX
   fromY := tapY
   
   
   if cancelSelect
   {
      Gui, Font, s8 norm, Tahoma
      GuiControl, Font, Select
      exit
   }

   soundbeep 440,30
   
   Gosub, WaitForTap
   
   toX := tapX
   toY := tapY
   
   if cancelSelect
   {
      Gui, Font, s8 norm, Tahoma
      GuiControl, Font, Select
      exit
   }

   soundbeep 550,30
   
   Gosub, resetButtons

   WinActivate, ahk_class TTkScoreWindow
   ;sleep 50
   send {Esc}
   
   ; a margin for accuracy, so user can be sure the notes at the borders of selection are included
   if toX > fromX
      offsetX := -10
   else
      offsetX := 10

   MouseClickDrag, L,fromX-offsetX, fromY, toX+offsetX, toY
return


buttonRMB:
   cancelSelect := 1
   Gosub, resetButtons
   WinActivate, ahk_class TTkScoreWindow   
   ;sleep 50
   MouseClick, Right, touchX, touchY
return


buttonESC:
   cancelSelect := 1
   Gosub,resetButtons
   WinActivate, ahk_class TTkScoreWindow
   ;sleep 50
   send {Esc}
return

buttonUNDO:
   WinActivate, ahk_class TTkScoreWindow
   send ^z
return

GuiClose:
ExitApp

elerouxx
 
Posts: 328
Joined: Thu Jun 16, 2011 6:45 pm

Return to NOTION

Who is online

Users browsing this forum: No registered users and 19 guests