vivec45 Posted April 23, 2008 Share Posted April 23, 2008 (edited) Is it possible to create a script that does the following? I want this script to be like this: while 1 If(color of pixel under mouse = red) Then MouseClick("left") sleep(500) wend while 1 sleep(1) wend (Yes, I am aware the If statement is rubbish, thats just what I want it to do lol) Keep in mind, I only want to check a very small area around the mouse, this script is for Counter-Strike:Source Thank you, Vivec45 Edited April 23, 2008 by vivec45 Link to comment Share on other sites More sharing options...
mafioso Posted April 23, 2008 Share Posted April 23, 2008 (edited) Is it possible to create a script that does the following? I want this script to be like this: while 1 If(color of pixel under mouse = red) Then MouseClick("left") sleep(500) wend while 1 sleep(1) wend (Yes, I am aware the If statement is rubbish, thats just what I want it to do lol) Keep in mind, I only want to check a very small area around the mouse, this script is for Counter-Strike:Source Thank you, Vivec45 While 1 $pos = MouseGetPos() $pixel = PixelGetColor ($pos[0], $pos[1]) If $pixel = redcolor (you need to find it =)) Then MouseClick ("Left", $pos[0], $pos[1]) EndIf WEnd Add a few sleeps in the code so it doesn't use all CPU Edited April 23, 2008 by mafioso Link to comment Share on other sites More sharing options...
vivec45 Posted April 23, 2008 Author Share Posted April 23, 2008 (edited) While 1 $pos = MouseGetPos() $pixel = PixelGetColor ($pos[0], $pos[1]) If $pixel = redcolor (you need to find it =)) Then MouseClick ("Left", $pos[0], $pos[1]) EndIf WEnd Add a few sleeps in the code so it doesn't use all CPU This is my original code, seems to be very similar yours, yet does not work: expandcollapse popupGlobal $Paused HotKeySet("{F1}", "Stop") HotKeySet("{F2}", "Quit") ;Pause on start Stop() ;Pixel Search Color ;$left = "1" ;$top = "1" ;$right = "1" ;$bottom = "1" ;$shadevar = "1" ;$step = "1" $color = "0xff0000" $delay = "250" $pos = MouseGetPos() $curcolor = PixelGetColor($pos[0], $pos[1]) While 1 If $curcolor = $color Then MouseClick("left", $pos[0], $pos[1], "", "") Sleep($delay) EndIf WEnd Func Stop() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Stopped',0,0) WEnd ToolTip("") EndFunc Func Quit() Exit EndFunc The script is supposed to check if the pixel under the mouse is red, triggering left clicks until it isn't red any more. Anybody know why it's not working? (I do unpause it first) Edited April 23, 2008 by vivec45 Link to comment Share on other sites More sharing options...
Xenobiologist Posted April 23, 2008 Share Posted April 23, 2008 HI, Global $Paused HotKeySet("{F1}", "Stop") HotKeySet("{F2}", "Quit") $color = 0xE26200; change THIS!!! $delay = 25 While 1 $pos = MouseGetPos() $search = PixelGetColor($pos[0], $pos[1]) If $search = $color Then ;~ MouseClick("left", $pos[0], $pos[1], "", "") ConsoleWrite("FOUND" & @CRLF) Sleep($delay) EndIf ConsoleWrite($search & " " & $color & @CRLF) WEnd Func Stop() $Paused = Not $Paused While $Paused Sleep(100) ToolTip('Stopped', 0, 0) WEnd ToolTip("") EndFunc ;==>Stop Func Quit() Exit EndFunc ;==>Quit Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now