title: How to get mouse position properly on keypress with autohotkey Invalid Hotkey Error
body: <p><em><strong>For those who find this later, for google reasons or anything, while the comments helped, I largely had to re-do the code from scratch. If you want the CSP equivalent of a private layer in Procreate, or if you want to use CSPs recording features without your reference layers showing up, download autohotkey and this script, then set the following settings.</strong></em></p>
  <ol>
  <li>CTRL and Numpad+ to zoom in</li>
  <li>CTRL and Numpad- to zoom out</li>
  <li>Middle Mouse button to pan.</li>
  </ol>
  <p><em><strong>Then do the following, put a reference of some sort on both pages, a large checkerboard, a dot with a few lines through it, whatever. Then line up both windows so that they're showing exactly same thing, only use middle mouse button to pan, and CTRL+ and CTRL- to zoom in and out.</strong></em></p>
  <p>This is my first autohotkey script, and I'm trying to link up two different windows of an art program, so that when I pan one canvas, it pans the other. I would like it to be as pixel precise as possible, but I'm getting an error on Line 1 that says it's an invalid hotkey, I've tried removing the variables, and moving the commas around, but I'm not sure what I'm doing wrong.</p>
  <p>Here is my code. for purposes, I'll explain the button combinations.</p>
  <p>Space + L Mouse Button together lets me pan the canvas, I need to know where the cursor is when I release one or the other.</p>
  <p>LCtrl + Numpad5 disables click through on WindowTop which I use to overlay with transparency one window over the other.</p>
  <p>LCtrl + Tab switches between the two canvasses in the app</p>
  <pre><code>#IfWinActive ahk_exe CLIPStudioPaint.exe
  
  ; coordmode 
  Coordmode, Mouse, Screen 
  t := 0
  
  ;Below line starts script, and declares The Starting Coordinates
  
  WinTitle = 3DLayer
  SetTitleMatchMode, 2
  
  ^F9::
  WinSet,Transparent, Off
  
  ^F11::
  WinSet, ExStyle, -0x20, % WinTitle
  return
  
  ^F10::
  WinSet, ExStyle, +0x20, % WinTitle
  WinSet, Transparent, 128, % WinTitle
  return
  
  ~MButton::
   if (t = 0)
  {
      MouseGetPos, MouseStartX, MouseStartY
      t := 1
  }
  
  return
  
  ~MButton up:: 
  
  ;When MButton is released, records mouse ending positions
      MouseGetpos, MouseEndX, MouseEndY
  ;Blocks input in case I move mouse or touch keyboard while it's running
      BlockInput, On
  ; switches canvas
      Send ^{TAB} 
  ; set window for click through
      WinTitle = 3DLayer
      SetTitleMatchMode, 2
  ; Disables Click Through
      WinSet, ExStyle, -0x20, % WinTitle
          ; drag 
      MouseClickDrag, M, MouseStartX, MouseStartY, MouseEndX, MouseEndY
  ;Re-enables Click Through
      WinSet, ExStyle, +0x20, % WinTitle
      Winset, Transparent, 150, % WinTitle
  ;Turns inputs back on, so that I can resume using the art program
      Send ^{TAB}
      BlockInput, Off
      t := 0
  return
  
  ~^NumpadAdd::
      BlockInput, On
  ; Get Mouse Position
      MouseGetPos, ScrollX, ScrollY
  
  ;Block input, then switch canvases
      
      Send ^{Tab}
  sleep 50
  ; Disables Click Through
      WinSet, ExStyle, -0x20, % WinTitle
  ; Move Mouse where it needs to be then scroll
      MouseMove, ScrollX, ScrollY
      Send ^{NumpadAdd}
  ;Re-enables Click Through
      WinSet, ExStyle, +0x20, % WinTitle
      Winset, Transparent, 150, % WinTitle
  ;Turns inputs back on, so that I can resume using the art program
      Send ^{TAB}
      BlockInput, Off
  return
  
  ~^NumpadSub::
      BlockInput, On
  ; Get Mouse Position
      MouseGetPos, ScrollX, ScrollY
  
  ;Block input, then switch canvases
      
      Send ^{Tab}
  sleep 50
  ; Disables Click Through
      WinSet, ExStyle, -0x20, % WinTitle
  ; Move Mouse where it needs to be then scroll
      MouseMove, ScrollX, ScrollY
      Send ^{NumpadSub}
  ;Re-enables Click Through
      WinSet, ExStyle, +0x20, % WinTitle
      Winset, Transparent, 150, % WinTitle
  ;Turns inputs back on, so that I can resume using the art program
      Send ^{TAB}
      BlockInput, Off
  return
  </code></pre>