Question

I am using Autoit for a bot that I am making and trying to detect the clients screen resolution first before launching the game. I am making the bot to run at a specific screen size so I want to make sure the client runs it at that size before launching my bot. I have so far

; Retrieve the client area of the window.
  $aClientSize = WinGetClientSize("clientWindow")
  If Not ($aClientSize[0] = 1024 & $aClientSize[1] = 768) Then
     WinClose("clientWindow")
     MsgBox(0,"Resolution","Please change your screen resolution in game to 1024x768 in order for this bot to work. Go To Game Menu > Options > Graphics and change it to 1024x768 Then run it again.")
     Exit
  EndIf

But no matter what it executes this script so whether it is set at the right resolution or not. Am I running my If Statement incorrectly?

Was it helpful?

Solution

If you are looking for the desktop resolution then there are macros for that purpose: @DesktopWidth and @DesktopHeight.

However, your code is not working because of a syntax error. Look again at what you are doing with the If test - the & operator is for string concatenation! You were looking for And.

That means your code is being evaluated something like $a[0] = ((1024 & $a[1]) = 768), so whatever the case, you are comparing $a[0] to a boolean, which has to be false (there is no string such that "1024" & string = "768").

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top