Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > AutoIt
You last visited: Today at 20:34

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Can someone assist with a script

Discussion on Can someone assist with a script within the AutoIt forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Jul 2012
Posts: 7
Received Thanks: 0
Can someone assist with a script

Can someone help me create a simple script. I would greatly appreciate it. I am pretty new to autoIT and it can make my head spin at times. I ALMOST had this working years ago and gave up on it.

I need it to do the following.

While left mouse button is held down
Pixel search in specific area (I can enter the location and color if u leave it blank).
If color is detected, release left click.

That's all I need it to do. Anyone make a script like that for me so I can adjust the coordinates and color?

Thanks guys.
kleankanteen is offline  
Old 06/22/2017, 08:59   #2
 
MrFifaUltimate's Avatar
 
elite*gold: 0
Join Date: Feb 2017
Posts: 169
Received Thanks: 28
Did not test the code.

Code:
#include <Misc.au3>

Func findPixel()
    If _IsPressed("01") == 1 Then
        Local $coords = PixelSearch(left, top, right, bottom, color)
        If Not @error Then
            MouseUp($MOUSE_CLICK_LEFT)
        Else
            findPixel()
        EndIf
    EndIf
EndFunc
MrFifaUltimate is offline  
Thanks
1 User
Old 06/22/2017, 09:25   #3
 
elite*gold: 0
Join Date: Jul 2012
Posts: 7
Received Thanks: 0
Quote:
Originally Posted by MrFifaUltimate View Post
Did not test the code.

Code:
#include <Misc.au3>

Func findPixel()
    If _IsPressed("01") == 1 Then
        Local $coords = PixelSearch(left, top, right, bottom, color)
        If Not @error Then
            MouseUp($MOUSE_CLICK_LEFT)
        Else
            findPixel()
        EndIf
    EndIf
EndFunc
Thanks for this. It is a good start and looks similar to what I was working with 4 years ago.

Couple questions to help me understand.

which part of the script is telling it to search for the color while left mouse is pressed down. And will it continuously search while they key is held?
kleankanteen is offline  
Old 06/22/2017, 09:33   #4
 
MrFifaUltimate's Avatar
 
elite*gold: 0
Join Date: Feb 2017
Posts: 169
Received Thanks: 28
The function checks if the left mouse button is pressed (_IsPressed("01") == 1).
PixelSearch set @error if its unsuccessfull.
If @error is not checked the function calls itself again (recursion).

=> As long as the left mouse button is held down and the Pixel is not found the script will continue searching.
MrFifaUltimate is offline  
Old 06/22/2017, 11:43   #5

 
Moneypulation's Avatar
 
elite*gold: 138
Join Date: Apr 2012
Posts: 3,494
Received Thanks: 1,769
PHP Code:
#include <Misc.au3>

HotKeySet("{ESC}","_exit")

Global 
$hDLL DllOpen("user32.dll")

Global 
$left 0
Global $top 0
Global $right 0
Global $bottom 0
Global $color 0
Global $shade 0

While True
    
If _IsPressed("01",$hDLLThen
        checkPixel
()
    EndIf
WEnd

Func checkPixel
()
    While 
True
        
If Not _IsPressed("01",$hDLLThen
            ExitLoop
        
Else
            
$ps PixelSearch($left,$top,$right,$bottom,$color,$shade)
            If 
IsArray($psThen
                MouseUp
("primary")
                
ExitLoop
            
EndIf
        EndIf
    
WEnd
EndFunc

Func _exit
()
    
DllClose($hDLL)
    Exit
EndFunc 
This should do. Enter your PixelSearch coords in the global variables at the top of the script. You can exit the script by pressing ESC or just replace it with your prefered hotkey.
Moneypulation is offline  
Old 06/23/2017, 09:25   #6
 
elite*gold: 0
Join Date: Jul 2012
Posts: 7
Received Thanks: 0
Quote:
Originally Posted by MrFifaUltimate View Post
Did not test the code.

Code:
#include <Misc.au3>

Func findPixel()
    If _IsPressed("01") == 1 Then
        Local $coords = PixelSearch(left, top, right, bottom, color)
        If Not @error Then
            MouseUp($MOUSE_CLICK_LEFT)
        Else
            findPixel()
        EndIf
    EndIf
EndFunc
Quote:
Originally Posted by Moneypulation View Post
PHP Code:
#include <Misc.au3>

HotKeySet("{ESC}","_exit")

Global 
$hDLL DllOpen("user32.dll")

Global 
$left 0
Global $top 0
Global $right 0
Global $bottom 0
Global $color 0
Global $shade 0

While True
    
If _IsPressed("01",$hDLLThen
        checkPixel
()
    EndIf
WEnd

Func checkPixel
()
    While 
True
        
If Not _IsPressed("01",$hDLLThen
            ExitLoop
        
Else
            
$ps PixelSearch($left,$top,$right,$bottom,$color,$shade)
            If 
IsArray($psThen
                MouseUp
("primary")
                
ExitLoop
            
EndIf
        EndIf
    
WEnd
EndFunc

Func _exit
()
    
DllClose($hDLL)
    Exit
EndFunc 
This should do. Enter your PixelSearch coords in the global variables at the top of the script. You can exit the script by pressing ESC or just replace it with your prefered hotkey.
I appreciate the help. I am having trouble with the color. It says there is an error. I am using 7D1918. Is that not a correct format for that line?
kleankanteen is offline  
Old 06/23/2017, 10:29   #7
 
MrFifaUltimate's Avatar
 
elite*gold: 0
Join Date: Feb 2017
Posts: 169
Received Thanks: 28
You have to use the Hex-Representation ().
=> #7d1918
MrFifaUltimate is offline  
Old 06/23/2017, 10:58   #8
 
elite*gold: 0
Join Date: Jul 2012
Posts: 7
Received Thanks: 0
Quote:
Originally Posted by MrFifaUltimate View Post
You have to use the Hex-Representation ().
=> #7d1918
ok this is what I have in both scripts.

Local $coords = PixelSearch(1051, 565, 1051, 569, #7d1918)

and for the other one

Global $color = #7d1918

and this is the error message I get when i try to run either of them.

Unable to parse line and there is a ^Error under the #7d1918 on both.

I used 0x7d1918 and i can get the script to run, it just doesnt seem to work yet. ill tweak the location a bit
kleankanteen is offline  
Old 06/23/2017, 11:30   #9
 
MrFifaUltimate's Avatar
 
elite*gold: 0
Join Date: Feb 2017
Posts: 169
Received Thanks: 28
Oh i was wrong. Its correct to use the Hex-Representation with '0x' instead of '#'. You can also use the Decimal-Representation (8198424).

There must be a difference between your searched color and the color-code.
MrFifaUltimate is offline  
Old 06/23/2017, 13:59   #10
 
elite*gold: 0
Join Date: Jul 2012
Posts: 7
Received Thanks: 0
Quote:
Originally Posted by MrFifaUltimate View Post
Oh i was wrong. Its correct to use the Hex-Representation with '0x' instead of '#'. You can also use the Decimal-Representation (8198424).

There must be a difference between your searched color and the color-code.
The script you gave me doesnt seem to run. I run it and nothing happens. The other scrip shows AH running on my pc.

Does AH have an issue with not working with games open unless you tell it to run in a certain exe program? Seems like AHK works better with games. Is this script convertible to AH?
kleankanteen is offline  
Old 06/24/2017, 01:49   #11
 
psydinger's Avatar
 
elite*gold: 0
Join Date: Apr 2017
Posts: 84
Received Thanks: 12
Quote:
Originally Posted by kleankanteen View Post
The script you gave me doesnt seem to run. I run it and nothing happens. The other scrip shows AH running on my pc.

Does AH have an issue with not working with games open unless you tell it to run in a certain exe program? Seems like AHK works better with games. Is this script convertible to AH?
You don't need to switch to AutoHotKey, you can achieve the same with AutoIt.

Have you tried running it with F5 within ScitE and see if there are any errors popping up before compiling it into an executable? Are you sure that you are using the right color and coordinate values?

Make something simple: try testing the script on an example image or enviroment. Make it pop-up a MsgBox() on sucess with the result values and see if it works.

Your best bet right now is trying to narrow down the problem one step at the time.
psydinger is offline  
Old 06/27/2017, 07:59   #12
 
elite*gold: 0
Join Date: Jul 2012
Posts: 7
Received Thanks: 0
I will spend some more time working on these. I am working a lot right now so I haven't had the time.
kleankanteen is offline  
Reply


Similar Threads Similar Threads
Could someone assist me on this please.
04/15/2015 - CO2 Private Server - 1 Replies
Hey guys im having a bit of a pickle xD i first tryed the 6020 source and the server started fine but client couldent connect, now im useing messiv10 and i have the same issue not sure whats causeing this i have tv could someone help?
Aoe assist mit lv 60 1o1 assist machen
08/27/2010 - Flyff - 1 Replies
Hallo wollte fragen ob man mit lv 60 oder höher seinen aoe assist auf 1o1 assist staten kann mit event reskill und lvlt man mit einem aoe assisten schneller auf lv 60 als mit einem 1o1? weil will einen neuen assisten anfangen weil ich denk das ich damit schneller auf 60 komme als mit meinem 1o1 lv 48 auf 60
PLEASE......CAN SOMEONE CAN GIVE ME AN ENGINE THAT CAN'T BE DETECTED...
12/30/2009 - Grand Chase Hacks, Bots, Cheats & Exploits - 3 Replies
...GIVE ME AN ENGINE THAT IS N0T DETECTED..... KAHIT NA PANG 5 DAYS LANG !^^...IF YOU ARE FINISH TO READ YOU CAN CLOSED THIS THREAD....>.<:):):):):)
Can someone assist me in getting my game and server up ?
02/06/2009 - EO PServer Hosting - 3 Replies
I downloaded the 1click server and db i have ran into a error that the private play.exe icon cant find the run.cmd ive tried to copy soul.exe and make it blacknull its not working either.if anyone knows what to do pm me please ill let you remote me.



All times are GMT +1. The time now is 20:35.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.