Guest User

Untitled

a guest
Jul 16th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. var x = sf.ui.cubase.getWindowWithTitleStartingWith('Cubase Pro').position.x + 1303; //set the x relative position of subject
  2. var y = sf.ui.cubase.getWindowWithTitleStartingWith('Cubase Pro').position.y + 117; //set the y relative position of subject
  3. var flexPosX = 25; // set a number the mouse can be move within after being placed at position x,y
  4. var flexPosY = 25; // set a number the mouse can be move within after being placed at position x,y
  5. var moved = globalState.mouseToAudioTranspose; // set name of globalState Function.
  6.  
  7. sf.ui.cubase.appActivateMainWindow(); // activates Cubase / puts cubase in front.
  8.  
  9. if (!sf.ui.cubase.getMenuItem('Audio', 'Open Sample Editor').isEnabled) { log('Audio Not Selected'); return; }
  10.  
  11. moved = !moved;
  12.  
  13. if (moved) {
  14. globalState.posX = Math.floor((sf.mouse.getPosition().position.x));
  15. globalState.posY = Math.floor((sf.mouse.getPosition().position.y));
  16. sf.mouse.setPosition({ position: { x: x, y: y } });
  17. }
  18.  
  19. if (!moved) {
  20. let xNow = Math.floor(sf.mouse.getPosition().position.x)
  21. let yNow = Math.floor(sf.mouse.getPosition().position.y)
  22. if (xNow < x + flexPosX && xNow > x - flexPosX && yNow < y + flexPosY && yNow > y - flexPosY) {
  23. sf.mouse.setPosition({ position: { x: globalState.posX, y: globalState.posY } });
  24. }
  25. else {
  26. globalState.posX = Math.floor((sf.mouse.getPosition().position.x));
  27. globalState.posY = Math.floor((sf.mouse.getPosition().position.y));
  28. sf.mouse.setPosition({ position: { x: x, y: y } });
  29. !moved;
  30. }
  31. };
Add Comment
Please, Sign In to add comment