cxzzD 0 Posted January 27, 2011 Hello. I've been trying to recreate the Windows Info thingy (A very basic clone). I'm currently working on the color of the mouse, but I seem to get into some problems. Here is the code that I'd like to get to work.. If $Hello = 1 Then global $mPos = MouseGetPos() global $mCol = PixelGetColor($mPos[0],$mPos[1]) Sleep(100) global $result = Hex($mCol,6) MsgBox(0, "", $result) ;MsgBox(0,"MousePos Color",$mCol&" "&"MousePos x:"& $mPos[0]) $Hello -= 1 EndIf $ColorFind = PixelSearch(405, 215,947, 570, "0x" & $result) <--- Here is the thing that wont work. I get the error "Variable not declared". What I want it to do is to write out the "$result" variable with an 0x infront of it. Am I way off or am I somewhat close? Thanks in advance. Share this post Link to post Share on other sites
Fender 0 Posted January 27, 2011 (edited) Hey there! It's actually what it says, you are trying to use $Hello without declaration Had no probs with your script actually, after having declared the $Hello var you are using: Global $Hello = 1 If $Hello = 1 Then global $mPos = MouseGetPos() global $mCol = PixelGetColor($mPos[0],$mPos[1]) Sleep(100) global $result = Hex($mCol,6) MsgBox(0, "", $result) ;MsgBox(0,"MousePos Color",$mCol&" "&"MousePos x:"& $mPos[0]) $Hello -= 1 EndIf $ColorFind = PixelSearch(405, 215,947, 570, "0x" & $result) Hope this helps. Edited January 27, 2011 by Fender Share this post Link to post Share on other sites
cxzzD 0 Posted January 27, 2011 (edited) Hey there! Had no probs with your script actually, after having declared the $Hello var you are using: Global $Hello = 1 If $Hello = 1 Then global $mPos = MouseGetPos() global $mCol = PixelGetColor($mPos[0],$mPos[1]) Sleep(100) global $result = Hex($mCol,6) MsgBox(0, "", $result) ;MsgBox(0,"MousePos Color",$mCol&" "&"MousePos x:"& $mPos[0]) $Hello -= 1 EndIf $ColorFind = PixelSearch(405, 215,947, 570, "0x" & "0x" & $result) Actually that part Is working correctly. But the part that isnt working is the colorfind thing. Here is the full code, probably should have posted it all from the begining. ;o HotKeySet("{F6}","_Terminate") HotKeySet("{F7}","_HejsanPlusOne") Global $Hello = 0 while 1 If $Hello = 1 Then global $mPos = MouseGetPos() global $mCol = PixelGetColor($mPos[0],$mPos[1]) Sleep(100) global $result = Hex($mCol,6) MsgBox(0, "", $result) ;MsgBox(0,"MousePos Color",$mCol&" "&"MousePos x:"& $mPos[0]) $Hello -= 1 EndIf $ColorFind = PixelSearch(405, 215,947, 570, $result) if IsArray($ColorFind) = True Then MouseMove($ColorFind[0],$ColorFind[1], 0) MouseClick("left") EndIf WEnd Func _HejsanPlusOne() $Hello += 1 EndFunc Func _Terminate() Exit 0 EndFunc Edited January 27, 2011 by cxzzD Share this post Link to post Share on other sites
Fender 0 Posted January 27, 2011 (edited) Mind that you declare a global variable $result in your IF statement, which is kinda dangerous. In your case, the first time your IF is checked, the $result is not created at all, because the condition is not met ($Hello is NOT 1). Then you get your error, cause the variable is indeed not declared yet. It's better to declare the $result before you start any checks, and then just use it. Example: HotKeySet("{F6}","_Terminate") HotKeySet("{F7}","_HejsanPlusOne") Global $Hello = 0 Global $ColorFind = 0 Global $result = 0 while 1 If $Hello = 1 Then global $mPos = MouseGetPos() global $mCol = PixelGetColor($mPos[0],$mPos[1]) Sleep(100) $result = Hex($mCol,6) MsgBox(0, "", $result) ;MsgBox(0,"MousePos Color",$mCol&" "&"MousePos x:"& $mPos[0]) $Hello -= 1 EndIf $ColorFind = PixelSearch(405, 215,947, 570, $result) if IsArray($ColorFind) = True Then MouseMove($ColorFind[0],$ColorFind[1], 0) MouseClick("left") EndIf WEnd Func _HejsanPlusOne() $Hello += 1 EndFunc Func _Terminate() Exit 0 EndFunc Edited January 27, 2011 by Fender Share this post Link to post Share on other sites