Liner Posted March 10, 2010 Posted March 10, 2010 Working on autoit and c++. My first autoit script is relatively simple, I'm trying to get it to: When Mouse1 is pressed, move to a different position. In this case, anything that is bright green in color. My script so far: Func _IsPressed($hexKey) ; $hexKey must be the value of one of the keys. ; _IsPressed will return 0 if the key is not pressed, 1 if it is. ; $hexKey should entered as a string, don't forget the quotes! ; (yeah, layer. This is for you) Local $aR, $bO $hexKey = '0x' & $hexKey $aR = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey) If Not @error And BitAND($aR[0], 0x8000) = 0x8000 Then $bO = 1 EndIf EndFunc ; I DID NOT WRITE THIS USERDEF. $Color = "0x48B748" $Search = PixelSearch (1000, 1000, 1000, 1000, $Color, 10) If _IsPressed('01') = 1 then sleep (50) Mouseclick ("left", $Search) IsPressed is a user defined function that I got from somewhere else. The function definition code I cannot vouch for, I don't know if it works, but from the research I've done it looks like it should. TBH, I'm assuming it is. Here's the sequence I have layed out: Set the color Set search parameters if mouse1 is pressed, then wait 50 on mouseclick, move to position determined by Search. When I build, I get no errors. Running this script, I notice 2 things: Nothing happens. Mouse1 click with the color on the screen does nothing. The autoit icon does not appear in the taskbar. I'm guessing this means the script is not running, did not run at all, or only ran for a fraction of a second. There's probably an obvious logic error, but I can't see it. Any ideas?
kaotkbliss Posted March 10, 2010 Posted March 10, 2010 couple of things your script is running for only a fraction of a second because there is no loop to keep it running (so as soon as it checks and finds nothing, it exits) pixelsearch is only searching a single pixel on the screen. it works like: PixelSearch(x of top left corner of search area,y of top left corner of search area, x of bottom right corner, y of bottom right corner, color) pixelsearch, if found returns an array so the line Mouseclick ("left", $Search) needs to be changed to Mouseclick ("left", $Search[0],$Search[1]) and unless there is more to the code, you are missing an endif at the end 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy!
PsaltyDS Posted March 10, 2010 Posted March 10, 2010 Try: $Color = 0x48B748 Without the quotes. You want a literal INT32, not a string. The function _IsPressed() is included in the Misc.au3 standard UDF that ships with AutoIt. If you don't know that, you haven't bothered with the help file much yet... Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Liner Posted March 11, 2010 Author Posted March 11, 2010 (edited) The function _IsPressed() is included in the Misc.au3 standard UDF that ships with AutoIt. If you don't know that, you haven't bothered with the help file much yet... I obviously didn't discover it in the help file, but I used it first. It wasn't a command listed in the yellow cursor function list either. I got it off of a forum. He said someone wrote it, if that person was someone from autoit, I didn't know.I'd never have figured out the quote problem. But regardless, tbh I rarely resort to the help files, perhaps I need to make it a habit :/kaotkbliss - I was planning to add more to the code, I didn't include endif. And of course, it does needs more very helpful Edited March 11, 2010 by Liner
kaotkbliss Posted March 11, 2010 Posted March 11, 2010 One problem I found with the help file, if you don't know the exact name of the function and don't type it in exactly, you aren't going to find it under the search tab. ispressed will not return the function for _ispressed 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy!
Liner Posted March 11, 2010 Author Posted March 11, 2010 One problem I found with the help file, if you don't know the exact name of the function and don't type it in exactly, you aren't going to find it under the search tab. ispressed will not return the function for _ispressed That makes me feel better, haI'm updating the code right now, so I'll edit this post when I'm done.
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