Need help with this code plz

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
phoenixL337
Posts: 12
Joined: 17 Oct 2021, 04:30

Need help with this code plz

27 Oct 2021, 05:18

I need some help with this code
Idk if im just being stupid af but this code

Code: Select all

#SingleInstance, force
#NoEnv
#Include Gdip_All.ahk
SendMode Input
SetTitleMatchMode, 3
setbatchlines, -1
WinSetTitle, Minecraft 1.8.9,, Mine1

sleep, 10000
ControlSend, , {1}, %win_title%

global win_title:="Mine1"
pToken := Gdip_Startup()

Lobby()
{
SetKeyDelay, 0, 50
sleep, 500
ControlSend, , t, %win_title%
Sleep, 30
ControlSend, , /, %win_title%
Sleep, 30
ControlSend, , s, %win_title%
Sleep, 30
ControlSend, , k, %win_title%
Sleep, 30
ControlSend, , y, %win_title%
Sleep, 30
ControlSend, , b, %win_title%
Sleep, 30
ControlSend, , l, %win_title%
Sleep, 30
ControlSend, , o, %win_title%
Sleep, 30
ControlSend, , c, %win_title%
sleep, 30
ControlSend, , k, %win_title%
sleep, 30
ControlSend, , {enter}, %win_title%
Sleep, 5000
ControlSend, , t, %win_title%
Sleep, 30
ControlSend, , /, %win_title%
Sleep, 30
ControlSend, , i, %win_title%
Sleep, 30
ControlSend, , s, %win_title%
sleep, 30
ControlSend, , {enter}, %win_title%
sleep, 5000
Gdip_DisposeImage(pBitmap)
reload
}

loop
{
Loop, 16
{
SetKeyDelay, 50, 50
ControlClick, , %win_title%,, Left, , Down, NA
sleep, 100
ControlSend, , {s up}, %win_title%
sleep, 100
ControlSend, , {a up}, %win_title%
sleep, 100
ControlSend, , {w down}, %win_title%
sleep, 100
ControlSend, , {d down}, %win_title%
sleep, 33650
ControlClick, , %win_title%,, Left, , Up, NA
ControlSend, , {w up}, %win_title%
ControlSend, , {d up}, %win_title%
ControlSend, , {a up}, %win_title%
pBitmap := Gdip_BitmapFromHWND(WinExist(win_title))
x:=9 , y:=37 ,w:=1899 ,h:=841
area_bitmap:=Gdip_CloneBitmapArea(pBitmap, x, y, w, h)
argb:=0xFF0000
if !Gdip_PixelSearch(pBitmap, ARGB, x, y, 3)
{
Lobby()
}
Gdip_DisposeImage(pBitmap)

sleep,100
SetKeyDelay, 50, 50
ControlClick, , %win_title%,, Left, , Down, NA
sleep, 100
ControlSend, , {w up}, %win_title%
sleep, 100
ControlSend, , {d up}, %win_title%
sleep, 100
ControlSend, , {w down}, %win_title%
sleep, 100
ControlSend, , {a down}, %win_title%
sleep, 33650
ControlClick, , %win_title%,, Left, , Up, NA
ControlSend, , {w up}, %win_title%
ControlSend, , {d up}, %win_title%
ControlSend, , {a up}, %win_title%
pBitmap := Gdip_BitmapFromHWND(WinExist(win_title))
x:=9 , y:=37 ,w:=1899 ,h:=841
area_bitmap:=Gdip_CloneBitmapArea(pBitmap, x, y, w, h)
argb:=0xFF0000
if !Gdip_PixelSearch(pBitmap, ARGB, x, y, 3)
{
Lobby()
}
Gdip_DisposeImage(pBitmap)
}

sleep, 100
Loop, 16
{
SetKeyDelay, 50, 50
ControlClick, , %win_title%,, Left, , Down, NA
sleep, 100
ControlSend, , {w up}, %win_title%
sleep, 100
ControlSend, , {a up}, %win_title%
sleep, 100
ControlSend, , {s down}, %win_title%
sleep, 100
ControlSend, , {d down}, %win_title%
sleep, 33650
ControlClick, , %win_title%,, Left, , Up, NA
ControlSend, , {s up}, %win_title%
ControlSend, , {d up}, %win_title%
ControlSend, , {a up}, %win_title%
pBitmap := Gdip_BitmapFromHWND(WinExist(win_title))
x:=9 , y:=37 ,w:=1899 ,h:=841
area_bitmap:=Gdip_CloneBitmapArea(pBitmap, x, y, w, h)
argb:=0xFF0000
if !Gdip_PixelSearch(pBitmap, ARGB, x, y, 3)
{
Lobby()
}
Gdip_DisposeImage(pBitmap)

sleep, 100
SetKeyDelay, 50, 50
ControlClick, , %win_title%,, Left, , Down, NA
sleep, 100
ControlSend, , {d up}, %win_title%
sleep, 100
ControlSend, , {s down}, %win_title%
sleep, 100
ControlSend, , {a down}, %win_title%
sleep, 33650
ControlClick, , %win_title%,, Left, , Up, NA
ControlSend, , {s up}, %win_title%
ControlSend, , {d up}, %win_title%
ControlSend, , {a up}, %win_title%
pBitmap := Gdip_BitmapFromHWND(WinExist(win_title))
x:=9 , y:=37 ,w:=1899 ,h:=841
area_bitmap:=Gdip_CloneBitmapArea(pBitmap, x, y, w, h)
argb:=0xFF0000
if !Gdip_PixelSearch(pBitmap, ARGB, x, y, 3)
{
Lobby()
}
Gdip_DisposeImage(pBitmap)
}
}

;#####################################################################################

Gdip_PixelSearch(pBitmap, ARGB, ByRef x, ByRef y, variation)
{
	static MCode_PixelSearch
	if !MCode_PixelSearch
           MCode_PixelSearch := MCode("2,x86:VVdWU4PsEItMJDCLRCQ0i3QkOIXJjVEDD0nRi0wkLMH6AoXJD46RAAAAicEPtvzHRCQIAAAAAA+26MH5EIk8JA+2+Yl8JASNPJUAAAAAiXwkDIt8JCSLRCQoMcmFwH5IixSPD7bCKeiJw8H7HzHYKdg58H8qD7bGKwQkicPB+x8x2CnYOfB/F8HqEA+20itUJASJ0MH4HzHCKcI58n5Bg8EBOUwkKHW4g0QkCAEDfCQMi0QkCDlEJCx1m4tEJDzHAP////+LRCRAxwD/////g8QQuP////9bXl9dw410JgCLRCQ8i3wkCIkIi0QkQIk4g8QQMcBbXl9dww==,x64:QVdBVkFVQVRVV1ZTSIPsGESLlCSIAAAARYXJQY1BA0GJ1UmJzEQPSMiLlCSAAAAARYnGQcH5AkSJTCQMRYXAD46KAAAAidcPtvZFMf8x7cH/EEQPttpJY91AD7b/RYXtfmBJY8cxyU2NDIQPH0QAAEGLFIkPtsJEKdhBicBBwfgfRDHARCnARDnQfy0PtsYp8EGJwEHB+B9EMcBEKcBEOdB/FsHqEA+20in6idDB+B8xwinCRDnSfj9Ig8EBSDnLda6DxQFEA3wkDEE57nWOSIuEJJAAAADHAP////9Ii4QkmAAAAMcA/////7j/////6xxmDx9EAABIi4QkkAAAAIkISIuEJJgAAACJKDHASIPEGFteX11BXEFdQV5BX8M=")
	Gdip_GetImageDimensions(pBitmap, Width, Height)
	if !(Width && Height)
		return -1

	if (E1 := Gdip_LockBits(pBitmap, 0, 0, Width, Height, Stride1, Scan01, BitmapData1))
		return -2

	x := y := 0
	E := DllCall(MCode_PixelSearch, "ptr", Scan01, "int", Width, "int", Height, "int", Stride1, "uint", ARGB, "int", variation, "int*", x, "int*", y)
	Gdip_UnlockBits(pBitmap, BitmapData1)
	return (E = "") ? -3 : E
}

MCode(mcode)
{
  static e := {1:4, 2:1}, c := (A_PtrSize=8) ? "x64" : "x86"
  if (!regexmatch(mcode, "^([0-9]+),(" c ":|.*?," c ":)([^,]+)", m))
    return
  if (!DllCall("crypt32\CryptStringToBinary", "str", m3, "uint", 0, "uint", e[m1], "ptr", 0, "uint*", s, "ptr", 0, "ptr", 0))
    return
  p := DllCall("GlobalAlloc", "uint", 0, "ptr", s, "ptr")
  if (c="x64")
    DllCall("VirtualProtect", "ptr", p, "ptr", s, "uint", 0x40, "uint*", op)
  if (DllCall("crypt32\CryptStringToBinary", "str", m3, "uint", 0, "uint", e[m1], "ptr", p, "uint*", s, "ptr", 0, "ptr", 0))
    return p
  DllCall("GlobalFree", "ptr", p)
}
^h::Exitapp
^k::Pause
tabs me into my game whereas



this code

Code: Select all

#SingleInstance, force
#NoEnv
#Include Gdip_All.ahk
SendMode Input
SetTitleMatchMode, 3
setbatchlines, -1
WinSetTitle, Minecraft 1.8.9,, Mine1

sleep, 10000
ControlSend, , {1}, %win_title%

global win_title:="Mine1"
pToken := Gdip_Startup()
pBitmap := Gdip_BitmapFromHWND(WinExist(win_title))
x:=798 , y:=392 ,w:=1539 ,h:=845
area_bitmap:=Gdip_CloneBitmapArea(pBitmap, x, y, w, h)
argb:=0xFF0000  
 
Lobby()
{
SetKeyDelay, 0, 50
sleep, 500
ControlSend, , t, %win_title%
Sleep, 30
ControlSend, , /, %win_title%
Sleep, 30
ControlSend, , s, %win_title%
Sleep, 30
ControlSend, , k, %win_title%
Sleep, 30
ControlSend, , y, %win_title%
Sleep, 30
ControlSend, , b, %win_title%
Sleep, 30
ControlSend, , l, %win_title%
Sleep, 30
ControlSend, , o, %win_title%
Sleep, 30
ControlSend, , c, %win_title%
sleep, 30
ControlSend, , k, %win_title%
sleep, 30
ControlSend, , {enter}, %win_title%
Sleep, 5000
ControlSend, , t, %win_title%
Sleep, 30
ControlSend, , /, %win_title%
Sleep, 30
ControlSend, , i, %win_title%
Sleep, 30
ControlSend, , s, %win_title%
sleep, 30
ControlSend, , {enter}, %win_title%
sleep, 5000
Gdip_DisposeImage(pBitmap)
Gdip_Shutdown(pToken)
reload
}

loop
{
Loop, 16
{
SetKeyDelay, 50, 50
SetMouseDelay, 50
ControlClick, , %win_title%,, Left, , Down NA
sleep, 100
ControlSend, , {s up}, %win_title%
sleep, 100
ControlSend, , {a up}, %win_title%
sleep, 100
ControlSend, , {w down}, %win_title%
sleep, 100
ControlSend, , {d down}, %win_title%
sleep, 33650
ControlClick, , Minecraft2,, Left, , Up NA
ControlSend, , {w up}, %win_title%
ControlSend, , {d up}, %win_title%
ControlSend, , {a up}, %win_title%
sleep, 100
if !Gdip_PixelSearch(pBitmap, ARGB, x, y, 3)
{
Lobby()
}

sleep,100
SetKeyDelay, 50, 50
ControlClick, , %win_title%,, Left, , Down NA
sleep, 100
ControlSend, , {w up}, %win_title%
sleep, 100
ControlSend, , {d up}, %win_title%
sleep, 100
ControlSend, , {w down}, %win_title%
sleep, 100
ControlSend, , {a down}, %win_title%
sleep, 33650
ControlClick, , Minecraft2,, Left, , Up NA
ControlSend, , {w up}, %win_title%
ControlSend, , {d up}, %win_title%
ControlSend, , {a up}, %win_title%
sleep, 100
if !Gdip_PixelSearch(pBitmap, ARGB, x, y, 3)
{
Lobby()
}
}

sleep, 100
Loop, 16
{
SetKeyDelay, 50, 50
ControlClick, , %win_title%,, Left, , Down NA
sleep, 100
ControlSend, , {w up}, %win_title%
sleep, 100
ControlSend, , {a up}, %win_title%
sleep, 100
ControlSend, , {s down}, %win_title%
sleep, 100
ControlSend, , {d down}, %win_title%
sleep, 33650
ControlClick, , %win_title%,, Left, , Up NA
ControlSend, , {s up}, %win_title%
ControlSend, , {d up}, %win_title%
ControlSend, , {a up}, %win_title%
sleep, 100
if !Gdip_PixelSearch(pBitmap, ARGB, x, y, 3)
{
Lobby()
}

sleep, 100
SetKeyDelay, 50, 50
ControlClick, , %win_title%,, Left, , Down NA
sleep, 100
ControlSend, , {d up}, %win_title%
sleep, 100
ControlSend, , {s down}, %win_title%
sleep, 100
ControlSend, , {a down}, %win_title%
sleep, 33650
ControlClick, , %win_title%,, Left, , Up NA
ControlSend, , {s up}, %win_title%
ControlSend, , {d up}, %win_title%
ControlSend, , {a up}, %win_title%
sleep, 100
if !Gdip_PixelSearch(pBitmap, ARGB, x, y, 3)
{
Lobby()
}
}
}

;#####################################################################################

Gdip_PixelSearch(pBitmap, ARGB, ByRef x, ByRef y, variation)
{
	static MCode_PixelSearch
	if !MCode_PixelSearch
           MCode_PixelSearch := MCode("2,x86:VVdWU4PsEItMJDCLRCQ0i3QkOIXJjVEDD0nRi0wkLMH6AoXJD46RAAAAicEPtvzHRCQIAAAAAA+26MH5EIk8JA+2+Yl8JASNPJUAAAAAiXwkDIt8JCSLRCQoMcmFwH5IixSPD7bCKeiJw8H7HzHYKdg58H8qD7bGKwQkicPB+x8x2CnYOfB/F8HqEA+20itUJASJ0MH4HzHCKcI58n5Bg8EBOUwkKHW4g0QkCAEDfCQMi0QkCDlEJCx1m4tEJDzHAP////+LRCRAxwD/////g8QQuP////9bXl9dw410JgCLRCQ8i3wkCIkIi0QkQIk4g8QQMcBbXl9dww==,x64:QVdBVkFVQVRVV1ZTSIPsGESLlCSIAAAARYXJQY1BA0GJ1UmJzEQPSMiLlCSAAAAARYnGQcH5AkSJTCQMRYXAD46KAAAAidcPtvZFMf8x7cH/EEQPttpJY91AD7b/RYXtfmBJY8cxyU2NDIQPH0QAAEGLFIkPtsJEKdhBicBBwfgfRDHARCnARDnQfy0PtsYp8EGJwEHB+B9EMcBEKcBEOdB/FsHqEA+20in6idDB+B8xwinCRDnSfj9Ig8EBSDnLda6DxQFEA3wkDEE57nWOSIuEJJAAAADHAP////9Ii4QkmAAAAMcA/////7j/////6xxmDx9EAABIi4QkkAAAAIkISIuEJJgAAACJKDHASIPEGFteX11BXEFdQV5BX8M=")
	Gdip_GetImageDimensions(pBitmap, Width, Height)
	if !(Width && Height)
		return -1

	if (E1 := Gdip_LockBits(pBitmap, 0, 0, Width, Height, Stride1, Scan01, BitmapData1))
		return -2

	x := y := 0
	E := DllCall(MCode_PixelSearch, "ptr", Scan01, "int", Width, "int", Height, "int", Stride1, "uint", ARGB, "int", variation, "int*", x, "int*", y)
	Gdip_UnlockBits(pBitmap, BitmapData1)
	return (E = "") ? -3 : E
}

MCode(mcode)
{
  static e := {1:4, 2:1}, c := (A_PtrSize=8) ? "x64" : "x86"
  if (!regexmatch(mcode, "^([0-9]+),(" c ":|.*?," c ":)([^,]+)", m))
    return
  if (!DllCall("crypt32\CryptStringToBinary", "str", m3, "uint", 0, "uint", e[m1], "ptr", 0, "uint*", s, "ptr", 0, "ptr", 0))
    return
  p := DllCall("GlobalAlloc", "uint", 0, "ptr", s, "ptr")
  if (c="x64")
    DllCall("VirtualProtect", "ptr", p, "ptr", s, "uint", 0x40, "uint*", op)
  if (DllCall("crypt32\CryptStringToBinary", "str", m3, "uint", 0, "uint", e[m1], "ptr", p, "uint*", s, "ptr", 0, "ptr", 0))
    return p
  DllCall("GlobalFree", "ptr", p)
}
^h::Exitapp
^n::Pause
does not tab me into my game
i would like to know why this happens
User avatar
mikeyww
Posts: 26590
Joined: 09 Sep 2014, 18:38

Re: Need help with this code plz

27 Oct 2021, 06:08

You can determine that by comparing the scripts, right? You can narrow down the problem by shortening the scripts and retesting iteratively.

I noticed that one script uses "Minecraft2", while the other does not.
phoenixL337
Posts: 12
Joined: 17 Oct 2021, 04:30

Re: Need help with this code plz

27 Oct 2021, 09:20

mikeyww wrote:
27 Oct 2021, 06:08
You can determine that by comparing the scripts, right? You can narrow down the problem by shortening the scripts and retesting iteratively.

I noticed that one script uses "Minecraft2", while the other does not.
i tried narrowing it down like 5 times already and still havent found the issue(so thats kinda why im here) and the minecraft2 is just a mistake i made lol mb
User avatar
mikeyww
Posts: 26590
Joined: 09 Sep 2014, 18:38

Re: Need help with this code plz

27 Oct 2021, 09:31

OK-- but since the differences between the scripts are clearly identifiable, then each of those differences is also readily testable. One approach is to start with the working script. Make a single change that you see in the other script. Re-test. If it works, repeat. That will pinpoint the problem quickly.
phoenixL337
Posts: 12
Joined: 17 Oct 2021, 04:30

Re: Need help with this code plz

27 Oct 2021, 10:40

mikeyww wrote:
27 Oct 2021, 09:31
OK-- but since the differences between the scripts are clearly identifiable, then each of those differences is also readily testable. One approach is to start with the working script. Make a single change that you see in the other script. Re-test. If it works, repeat. That will pinpoint the problem quickly.
the hard part about doing that is that they are identical
User avatar
mikeyww
Posts: 26590
Joined: 09 Sep 2014, 18:38

Re: Need help with this code plz

27 Oct 2021, 12:02

So you are saying that you have two identical scripts, and they yield different effects? And you compared the scripts line by line to see that they are exactly the same, right?
AndyK70
Posts: 4
Joined: 27 Oct 2021, 06:18

Re: Need help with this code plz

27 Oct 2021, 14:21

You missed some commas in the second script. Here is a short part of it to demonstrate:
grafik.png
grafik.png (129.37 KiB) Viewed 452 times
phoenixL337
Posts: 12
Joined: 17 Oct 2021, 04:30

Re: Need help with this code plz

28 Oct 2021, 15:44

AndyK70 wrote:
27 Oct 2021, 14:21
You missed some commas in the second script. Here is a short part of it to demonstrate:
grafik.png
Bruh i am actually blind
i would probally never have found especially when i was cheking it at 3am
TYSM for the help
phoenixL337
Posts: 12
Joined: 17 Oct 2021, 04:30

Re: Need help with this code plz

28 Oct 2021, 15:45

mikeyww wrote:
27 Oct 2021, 12:02
So you are saying that you have two identical scripts, and they yield different effects? And you compared the scripts line by line to see that they are exactly the same, right?
Thanks for help too, was kind of mad because i am blind af
User avatar
mikeyww
Posts: 26590
Joined: 09 Sep 2014, 18:38

Re: Need help with this code plz

28 Oct 2021, 18:43

Sorry; there is no way to know that from the initial post. If you say that you have two identical scripts, I assume that this means that you have a way to determine that. Otherwise, it's leading the reader (and you) to a wrong assumption. In any case, best wishes with the script. AndyK70 shows a method for comparing text, so perhaps this will help you in future rounds. I use these methods even when I can see, because it saves time and provides a visual indicator of the areas to inspect more closely. If you are completely blind, then I'm not sure what method would be best for comparing text.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bubo_Bubo, marypoppins_1, mikeyww, OrangeCat, RussF and 137 guests