Cant find the mistake Topic is solved

Ask gaming related questions (AHK v1.1 and older)
Qplshakyz
Posts: 35
Joined: 13 Apr 2021, 12:07

Cant find the mistake

Post by Qplshakyz » 18 Apr 2021, 13:50

I dont understand this. The Script itselfs works and also not sometimes instead of going down twice in a row it goes down 3 times and also sometimes it doesnt go down at all it just hits enter enter
are the sleeps inbetween to fast or does setkeydelay has something 2 do with it?

Code: Select all

CODE:
settitlematchmode, 2
SetBatchLines, 10ms
CoordMode, Pixel, Client
#NoEnv
SetKeyDelay, 0, 100



F9::

loop{
IfWinExist, Remote

                  
          send,{Enter down}
          sleep,100
          send,{Enter up}
          sleep,80
          send,{Down}
          sleep,60
          send,{Down up}
          sleep,80
          send,{Down}
          sleep,60
          send,{Down up}
          sleep,80
          send,{Enter Down}
          sleep,100
          send,{Enter up}
          sleep,100
          send,{Enter down}
          sleep,2600
          send,{Enter up}
          sleep,200
                  
                  
                   
PixelSearch, Px, Py, 988, 227, 990, 229, 0xB83031, 30, Fast RGB
if ErrorLevel
else
  break
return
User avatar
mikeyww
Posts: 26880
Joined: 09 Sep 2014, 18:38

Re: Cant find the mistake

Post by mikeyww » 18 Apr 2021, 15:17

An "If" statement applies to a block in braces. If no block exists, it will apply only to the single line that follows it. The same goes for Loop. When braces are used, both an opening and a closing brace are needed.

When you send a key without specifying "up" or "down", it sends both. Therefore, you would not typically Send {Down up} after Send {Down}, because the key is usually already up at that point.

Explained: If
Qplshakyz
Posts: 35
Joined: 13 Apr 2021, 12:07

Re: Cant find the mistake

Post by Qplshakyz » 18 Apr 2021, 15:50

So I fixed it kinda but could you tell me if let’s say Setkeydelay to 0, 50 is there a possibility that the script will send some buttons at the same time? At first setkeydelay was 0, 50 and I was running the Script for 1 hour and saw that sometimes like i said it will press down 3 times even if I want it to send it 2 times down

When I was doing it 0, 100 obv the script was running slower but after 1 hour there was no mistake it was going kinda flawless so but since the script runs now slower is there another way to speed up the process without getting into the state where it kinda fails ?

And btw so ur saying I don’t need to write the down or up comments at all ? Like I did now?

Code: Select all

 CODE:
settitlematchmode, 2
SetBatchLines, 10ms
CoordMode, Pixel, Client
#NoEnv
SetKeyDelay, 0, 100



F9::

loop{
IfWinExist, Remote

                  
          send,{Enter}
          sleep,100
          send,{Down}
          sleep,60
          send,{Down}
          sleep,80
          send,{Enter}
          sleep,80
          send,{Enter}
          sleep,2600
                  
                  
                   
PixelSearch, Px, Py, 988, 227, 990, 229, 0xB83031, 30, Fast RGB
if ErrorLevel
{
}
else
{
  break
 }
 }
return
User avatar
mikeyww
Posts: 26880
Joined: 09 Sep 2014, 18:38

Re: Cant find the mistake  Topic is solved

Post by mikeyww » 18 Apr 2021, 16:05

I doubt it, but I suspect that you have a bug and might instead want to do something like the following.

Code: Select all

F9::
SetTitleMatchMode, 2
SetKeyDelay, 0, 100
CoordMode, Pixel, Client
Loop {
 If WinExist("Remote") {
  Send {Enter}
  Sleep, 100
  Send {Down}
  Sleep, 60
  Send {Down}
  Sleep, 80
  Send {Enter}
  Sleep, 80
  Send {Enter}
  Sleep, 2600
 }
 PixelSearch,,, 988, 227, 990, 229, 0xB83031, 30, Fast RGB
} Until !ErrorLevel
Return
Send will send to whatever window is active at the time of the command. Test it in Notepad.

KeyHistory may also help you understand what is happening.
Last edited by mikeyww on 18 Apr 2021, 16:10, edited 1 time in total.
Qplshakyz
Posts: 35
Joined: 13 Apr 2021, 12:07

Re: Cant find the mistake

Post by Qplshakyz » 18 Apr 2021, 16:09

Okay Perfect I will try that out thanks for the feedback
Post Reply

Return to “Gaming Help (v1)”