title: Dual monitor help needed [AutoHotkey]
body: <p>I'm having trouble getting my script to work on multiple monitors, having searched and found some posts regarding the use of multiple monitors I''m still not sure where I am going wrong and how to fix it.</p>
  
  <p>I am currently using a laptop with an external monitor connected, but I will be sharing this with colleagues who may not have additional monitors. When I run on an application on the main screen (Laptop screen) everything seems to work as expected but when I run it on an application on the additional monitor the coordinates seem to be off.</p>
  
  <p>Please see my code below, I know this may be a mess and could be cleaned up but I'm not quite that knowledgable yet.</p>
  
  <pre><code>#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
  #Warn  ; Enable warnings to assist with detecting common errors.
  SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
  SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
  
  CoordMode, Pixel, Screen    
  CoordMode, Mouse, Screen
  
  If !FileExist( "Settings.ini" ) {
  If ( WinExist("Amazon WorkSpaces") )
  {
  WinActivate
  
  } Else
  {
  MsgBox, 48, Auto Clicker, Open AWS!
  }
  MsgBox Please  close this message and click Start Tracing button
  KeyWait, LButton, Down
  MouseGetPos, tracingx, tracingy
  
  KeyWait, LButton, Up
  MouseGetPos, tracingendx, tracingendy
  
  AHKCommand = %tracingx%, %tracingy%
  IniWrite, %tracingx%, Settings.ini, tracing, xcoord
  IniWrite, %tracingy%, Settings.ini, tracing, ycoord
  
  MsgBox Please close this message and click Back to consignment list button
  KeyWait, LButton, Down
  MouseGetPos, backx, backy
  
  KeyWait, LButton, Up
  MouseGetPos, backendx, backendy
  
  AHKCommand2 = %backx%, %backy%
  IniWrite, %backx%, Settings.ini, back, xcoord
  IniWrite, %backy%, Settings.ini, back, ycoord
  
  InputBox, minrefresh, Minimum Refresh, Enter Minimum refresh time in milliseconds (1 min = 60000 milliseconds), , , , , , , , 180000
  IniWrite, %minrefresh%, Settings.ini, refresh rates, min
  
  InputBox, maxrefresh, Maximum Refresh, Enter Maximum refresh time in milliseconds (1 min = 60000 milliseconds), , , , , , , , 300000
  IniWrite, %maxrefresh%, Settings.ini, refresh rates, max
  Return ; This stops the script or returns from the above subroutine.
  ; ExitApp ; This exits the script entirely
  ; GoSub, Start ; This jumps to the label start in the script.
  ; Use non of these to continue the script
  }
  
  InputBox, minrefresh, Minimum Refresh, Enter Minimum refresh time in milliseconds (1 min = 60000 milliseconds), , , , , , , , 60000
  IniWrite, %minrefresh%, Settings.ini, refresh rates, min
  
  InputBox, maxrefresh, Maximum Refresh, Enter Maximum refresh time in milliseconds (1 min = 60000 milliseconds), , , , , , , , 180000
  IniWrite, %maxrefresh%, Settings.ini, refresh rates, max
  
  ^+z::  ; Control+Shift+Z hotkey.
  
  
  IniRead, tracingx, Settings.ini, tracing, xcoord
  IniRead, tracingy, Settings.ini, tracing, ycoord
  IniRead, backx, Settings.ini, back, xcoord
  IniRead, backy, Settings.ini, back, ycoord
  AHKCommand = %tracingx%, %tracingy%
  AHKCommand2 = %backx%, %backy%
  Random, rand, %minrefresh%, %maxrefresh%
  
  
  Loop {
  If ( WinExist("Amazon WorkSpaces") )
  {
  WinActivate
  PixelGetColor, color, %tracingx%, %tracingy%
  If (color = 0xEFEFEF) {
  Click %AHKCommand%
  Sleep, 2000
  PixelGetColor, color, %backx%, %backy%
  If (color = 0xF5F5F5) {
  Click %AHKCommand2%
  Sleep, 2000
  
  } Else 
  {
  MsgBox, , Auto Clicker, You have a call!
  }
  
  } Else 
  {
  MsgBox, 48, Auto Clicker, Check Settings!]
  }
  } Else
  {
  MsgBox, 48, Auto Clicker, Open AWS!
  }
  Sleep, %rand%
  }
  </code></pre>
  
  <p>What I hope to happen is on starting the script it checks for settings and if it doesn't find them it will ask you for the information. once this check is done it will click a set location from the data you provided at an interval set by yourself and check it matches the specific colour (button present/not present) then displays errors or messages as required. Pretty simple so far?</p>
  
  <p>The problem comes when I have the application on the additional monitor. At first, I thought nothing was happening, but with a msgbox here and there I can now see that the coordinates I selected during setup are correct but when the script is running the coordinates seem to be off by a varying amount (Currently between 105 &amp; 120px on the x-axis and between 145 &amp; 147px on the y-axis.</p>
  
  <p>Is this going to work, or should I give up and get everyone using it on the main laptop screen?</p>