Image Search on different Resolutions Topic is solved

Ask gaming related questions
Tobgun1
Posts: 123
Joined: 23 Feb 2023, 07:28

Image Search on different Resolutions

Post by Tobgun1 » 03 Mar 2023, 08:48

Hello there;
new Day new Task do be done! :D

i have a really smooth and well working "Auto Skipper" Script for anoying Buttons inside my Game.
so my m8 dont got to wait for uneccessary Timers while i am on Toilett or Phone etc.

i made it for 1920 x 1080 on my 17! Gaming Laptop.

it operates incredible smoot since i put in the *50 variables (cuse Buttons been with Transparent background)

now i search ideas and solutions for different Resolutions because my m8 ones doesnt work.
he s playing on something like 3.840 x 2.160 Pixel , must be UHD, so is the Monitor size mattering? i guess no?
only the resolution if i am right , so how many resolutions can be up there?
i got https://www.touchandscreen.de/bildschirmaufloesungen a hundreds

but on PC arent we usually using HD Ready, HD and UHD? inside the Game itself?

what are my posibilitys? i got the idea to let my m8 scrap the screenshots himself rename em and hope they´r working
PixelSearch? TextSearch? what are your thoughts?

or is there a solution with the search rectangle or the variation to make it fit different resolutions?

i would welcome ideas for it

Thanks Tobgun1 :)

Code: Select all

#Requires AutoHotkey v2.0 ; Script uses AutoHotkey V2 to Work
#SingleInstance Force ; allows only one script at the same time
InstallMouseHook ; Installs MouseCommands to ensure it is On
SetKeyDelay(1000) ; 2 Sec. command for waiting time of each Key
Loop {
    SendMode("Event")
    if A_TimeIdle > 15000 ; 15 Sec. Timer for - "Action" if User was inactive for x Sec. - Anti-AFK-Timer Main idea
    { 
        MouseMove Random(-800,800), Random(-800,800), Random(100), "R" ; "Action"-> random MouseMove across of "800" Pixel
    }
}
F8:: { ; F8 to Activate Script
    Static on := False
    If on := !on 
    {
        ComObject("SAPI.SpVoice").Speak("Script Activated", ) ; Sound for F8 when u activate the Script "Script Activated"
        SetTimer(ImgScan, 1000) ; 1 Sec. Timer for the Image-Search
        SetTimer(Activ, 0) ; (Off) 0 Sec. Timer for the repeating Sound while Script is running "Script is Running" (check down below)
    } 
    Else 
    {
        ComObject("SAPI.SpVoice").Speak("Script Paused") ; Sound for F8 Script Pause "Script Paused"
        SetTimer(ImgScan, 0)
        SetTimer(Activ, 0)
    }
}
F10:: { ; F10 for Script ShutDown
    ComObject("SAPI.SpVoice").Speak("Script ShutDown") ; Sound when Script gets ShutDown "Script ShutDown"
    ExitApp
}
Activ() { ;UDF for the Sound
    ComObject("SAPI.SpVoice").Speak("Script is running") ; repeating Sound while Script is runnning (every x Seconds check Timer above - SetTimer(Activ, xxx) )
}
Skip() { ;UDF Label for the Skip-Combo ("Skip")
    Send("{Esc 3}{f 3}") ; "Skip-Combo" command - 3 Times Esc + 3 Times f
}
ImgScan() {
    CoordMode "Pixel"
        if ImageSearch(&X, &Y, 0, 0, A_ScreenWidth, A_ScreenHeight, "*50 " A_ScriptDir "\Skip.png") ; Search Image and do following Action -> working
        { 
            ComObject("SAPI.SpVoice").Speak("Skip-Combo") ; Sound
            Skip ; UDF for the Skip-Combo ["Skip()" see above]
        }
        if ImageSearch(&X, &Y, 0, 0, A_ScreenWidth, A_ScreenHeight, "*50 " A_ScriptDir "\Mission Success.png") ; working
        { 
            ComObject("SAPI.SpVoice").Speak("Success")
            Skip
        }
        if ImageSearch(&X, &Y, 0, 0, A_ScreenWidth, A_ScreenHeight, "*50 " A_ScriptDir "\Continue.png") ; working
        { 
            ComObject("SAPI.SpVoice").Speak("Continue")
            Send("{f 2}")
        }
        if ImageSearch(&X, &Y, 0, 0, A_ScreenWidth, A_ScreenHeight, "*50 " A_ScriptDir "\Mission Completed.png") ; working
        { 
            ComObject("SAPI.SpVoice").Speak("Mission Completed")
            Send("{f 2}")
        }
        if ImageSearch(&X, &Y, 0, 0, A_ScreenWidth, A_ScreenHeight, "*50 " A_ScriptDir "\Ready.png") ; working
        { 
            ComObject("SAPI.SpVoice").Speak("Ready")
            Sleep (4000)
            Send("{x}{f}")
        }
        if ImageSearch(&X, &Y, 0, 0, A_ScreenWidth, A_ScreenHeight, "*50 " A_ScriptDir "\Contracts.png") ; working
        { 
            Sleep (1000)
            ComObject("SAPI.SpVoice").Speak("Letz Go")
            Sleep (3000)
            Send("{f}")
        }
        if ImageSearch(&X, &Y, 0, 0, A_ScreenWidth, A_ScreenHeight, "*50 " A_ScriptDir "\Crack Continue.png") ; working
        { 
            ComObject("SAPI.SpVoice").Speak("Continue Crack")
            Sleep (4000)
            Send("{f}")
        }
}
    ; as for now, i want to dedicate this Final Version and all further Script Versions to my AMAZING AutoHotKey Teacher "DuckingQuack".
    ; Thanks a lot for Teaching me AHK, Improve my Skills with new commands , searching for new ideas AND solving Problems i wouldnt found alone!
    ; Was an Amazing Step-by-Step learning by doing and felt Incredible! Thank you very much!

User avatar
boiler
Posts: 17333
Joined: 21 Dec 2014, 02:44

Re: Image Search on different Resolutions  Topic is solved

Post by boiler » 03 Mar 2023, 09:05

It's totally dependent on how things are rendered in your game. If the images are scaled to fill the screen and look relatively the same on different resolutions, then your reference images will never be able to be found on the other resolutions because they're actually drawn in a totally different number of pixels with totally different color values in each pixel. It may just be that you need to capture a whole new set of reference images from the game when they're rendered in the other resolution, as you mentioned as one of the possibilities.

Tobgun1
Posts: 123
Joined: 23 Feb 2023, 07:28

Re: Image Search on different Resolutions

Post by Tobgun1 » 03 Mar 2023, 19:32

okay, hmm thats sad, do you maybe got some ideas for us?
i am still discoveringfunctions and possibilitys :)

User avatar
boiler
Posts: 17333
Joined: 21 Dec 2014, 02:44

Re: Image Search on different Resolutions

Post by boiler » 03 Mar 2023, 20:39

Just like I said, capture the images on the other computer with the different resolution and see if that works.

Tobgun1
Posts: 123
Joined: 23 Feb 2023, 07:28

Re: Image Search on different Resolutions

Post by Tobgun1 » 05 Mar 2023, 08:11

@boiler
Hello boiler

I have a idle trigger inside my script, so it moves the mouse after 15 seconds inactivity.
Works fine for me. But for my mate it doesn't works.

Do you got any idea how I can fix that?
Or check why he s idle doesn't gets recognized by the script?
I did the "install mouse hook" on the top so I thought this ensures stuff like that.

Is there any way why it doesn't works with ahkv2?

I got visual studio code with ahk v2 language to code the script. Is there any difference or driver installed with it?

Thanks if you got some help 😊👍

User avatar
boiler
Posts: 17333
Joined: 21 Dec 2014, 02:44

Re: Image Search on different Resolutions

Post by boiler » 05 Mar 2023, 08:36

Generally, when you have a new topic, create a new thread. No single thread should just become a place to ask various questions.
Tobgun1 wrote:
05 Mar 2023, 08:11
I have a idle trigger inside my script, so it moves the mouse after 15 seconds inactivity.
Works fine for me. But for my mate it doesn't works.

Do you got any idea how I can fix that?
Or check why he s idle doesn't gets recognized by the script?
I did the "install mouse hook" on the top so I thought this ensures stuff like that.
I have no idea. This is a good example of why you should just start a new thread. It would also help if you post the script. Otherwise, we’re just guessing.

Tobgun1 wrote:
05 Mar 2023, 08:11
Is there any way why it doesn't works with ahkv2?
Again, hard to know without seeing the script. Did you write it for v2? And that one works on your computer but not the other one?

Tobgun1 wrote:
05 Mar 2023, 08:11
I got visual studio code with ahk v2 language to code the script. Is there any difference or driver installed with it?
What editor you use doesn’t have any effect on it unless you’re using a plugin to run it directly from the editor and you have it pointing to a specific AHK binary. Try just running it from File Explorer.

Tobgun1
Posts: 123
Joined: 23 Feb 2023, 07:28

Re: Image Search on different Resolutions

Post by Tobgun1 » 05 Mar 2023, 11:17

Hey boiler,
thanks on and on for your response,
i was on Mobile and was kinda bad to post it, the script is the version above. so i thought it is more likely to not do severall threats for the same script on and on :D

the image search works finde now

my 2 freinds are playing with controllers, i got a second "quiter" version down here

but they still somehow dont get the Anti-AFK function with the idle timer
i do a new Threat then next few minutes

Code: Select all

#Requires AutoHotkey v2.0 ; Script requires AutoHotkey V2
#SingleInstance Force ; When this script launches, if it was already running, it will close the previous one 
InstallMouseHook ; Installs MouseHook 
SetKeyDelay(1000, 100) ; x Sec. command for waiting time of each Key + x ms of KeyPressed
SendMode("Event") ; Changes the way the inputs are sent
Loop {
    if A_TimeIdle > 15000 { ; If no input to PC for 15 seconds, perform following action 
        MouseMove Random(-800,800), Random(-800,800), Random(100), "R" ; Causes a random mouse movement
    }
}
F8:: { ; F8 to Activate Script
    Static on := False ; Initializes the variable
    If on := !on { ; Performs the toggle action and checks the state of the variable
        ComObject("SAPI.SpVoice").Speak("Script Activated") ; Says "Script Activated"
        SetTimer(ImgScan, 1000) ; Starts a 1 second auto-repeating timer for running the ImageSearch
    } Else {
        ComObject("SAPI.SpVoice").Speak("Script Paused") ; Says "Script Paused"
        SetTimer(ImgScan, 0) ; Stops the auto-repeating timer
    }
}
F10:: { ; F10 for Script ShutDown
    ComObject("SAPI.SpVoice").Speak("Script ShutDown") ; Says "Script ShutDown"
    ExitApp ; Fully closes the script
}
ImgScan() {
    CoordMode "Pixel" ; Changes the way the ImageSearch references the coordinates
        if ImageSearch(&X, &Y, 0, 0, A_ScreenWidth, A_ScreenHeight, "*50 " A_ScriptDir "\Skip.png") ; If image is found, do the following actions
            Skip
        if ImageSearch(&X, &Y, 0, 0, A_ScreenWidth, A_ScreenHeight, "*50 " A_ScriptDir "\Mission Success.png")
            Skip
        if ImageSearch(&X, &Y, 0, 0, A_ScreenWidth, A_ScreenHeight, "*50 " A_ScriptDir "\Continue.png")
            ContinueAndCompleted
        if ImageSearch(&X, &Y, 0, 0, A_ScreenWidth, A_ScreenHeight, "*50 " A_ScriptDir "\Mission Completed.png")
            ContinueAndCompleted
        if ImageSearch(&X, &Y, 0, 0, A_ScreenWidth, A_ScreenHeight, "*50 " A_ScriptDir "\Contracts.png")
            ContractsAndCrack
        if ImageSearch(&X, &Y, 0, 0, A_ScreenWidth, A_ScreenHeight, "*50 " A_ScriptDir "\Crack Continue.png")
            ContractsAndCrack
        if ImageSearch(&X, &Y, 0, 0, A_ScreenWidth, A_ScreenHeight, "*50 " A_ScriptDir "\Ready.png") {
            Ready
        }
}
ContractsAndCrack() { ;UDF Label´s for different Commands
    Sleep(4000)
    Send("f")
}
Skip() { 
    Send("{Esc 3}{f 3}") ; 3 times Esc + 3 times f
}
ContinueAndCompleted() {
    Sleep(1000)
    Send("ff")
}
Ready() {
    Sleep(4000)
    Send("xf")
}
    ; as for now, i want to dedicate this Final Version and all further Script Versions to my AMAZING AutoHotKey Teacher "DuckingQuack".
    ; Thanks a lot for Teaching me AHK, Improve my Skills with new commands , searching for new ideas AND solving Problems i wouldnt found alone!
    ; Was an Amazing Step-by-Step learning by doing and felt Incredible! Thank you very much!

Post Reply

Return to “Gaming”