d0n Posted November 4, 2007 Share Posted November 4, 2007 (edited) I was wondering how i can create a dot on the screen next to my mouse, i know how to get the position of my mouse but how do i create something on the screen?? Y = mouse O = dot O Y and if i move my mouse i want the dot to move too, what functions should i be looking at to create this? Edited November 4, 2007 by d0n Link to comment Share on other sites More sharing options...
sandman Posted November 4, 2007 Share Posted November 4, 2007 (edited) I would recommend (as the easiest method) creating a popup GUI, setting the background color, and moving it. You should look at GUICreate and GUI control styles for making a popup window. Then in a While loop, check if the position of the mouse has changed, using MouseGetPos. If it has, use WinMove.Example While loop:Global $pos[2]; While 1 $new = MouseGetPos(); If $new[0] <> $pos[0] Or $new[1] <> $pos[1] Then WinMove("GUI", "", $new[0] - 10, $new[1]); EndIf $pos[0] = $new[0]; $pos[1] = $new[1]; WEnd Edited November 4, 2007 by sandman [center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center] Link to comment Share on other sites More sharing options...
d0n Posted November 4, 2007 Author Share Posted November 4, 2007 Hi, thanks for the help The what i want to do with this code is to get the color of the pixel not on the mouse but to the left of the mouse i dont know why this code wont get the pixel where the popup is but where my current mouse is #include "GUIConstants.au3" Global $pos[2]; $a = GUICreate("GUI", 5, 5, -1, -1, $WS_POPUP) GUISetState (@SW_SHOW) GUISetBkColor(0x00ff00, $a) $mouse = MouseGetPos() $mouse_x = $mouse[0] $mouse_y = $mouse[1] HotKeySet ("{Insert}", "pixel") func pixel() $new_bobber = PixelGetColor ($new[0],$new[1]) $color_bobber = ("0x" & Hex($new_bobber, 6)) MsgBox(0,"Color", $color_bobber) EndFunc While 1 $new = MouseGetPos(); If $new[0] <> $pos[0] Or $new[1] <> $pos[1] Then WinMove("GUI", "", $new[0] - 30, $new[1]); EndIf $pos[0] = $new[0]; $pos[1] = $new[1]; WEnd Link to comment Share on other sites More sharing options...
d0n Posted November 4, 2007 Author Share Posted November 4, 2007 i tried to use this for the code above, but still doesn't work $new_bobber = PixelGetColor (($pos[0] - 30),$pos[1]) Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 5, 2007 Share Posted November 5, 2007 (edited) Because your array $new is created with local scope (inside a function) it is not available yet when you try to use it in the While/WEnd loop. This works for me (added a way to exit the script): #include "GUIConstants.au3" Global $pos = MouseGetPos(), $new_bobber = 0x00FF00 $a = GUICreate("GUI", 5, 5, $pos[0] - 30, $pos[1], $WS_POPUP) GUISetBkColor($new_bobber, $a) GUISetState(@SW_SHOW) HotKeySet("{Insert}", "Pixel") HotKeySet("{ESC}", "_Quit") While 1 $new = MouseGetPos() If $new[0] <> $pos[0] Or $new[1] <> $pos[1] Then WinMove("GUI", "", $new[0] - 30, $new[1]) EndIf $pos = $new Sleep(20) WEnd Func Pixel() $new_bobber = PixelGetColor($pos[0], $pos[1]) $color_bobber = "0x" & Hex($new_bobber, 6) GUISetBkColor($new_bobber, $a) MsgBox(0, "Color", $color_bobber) EndFunc ;==>Pixel Func _Quit() Exit EndFunc ;==>_Quit Note when you copy an array, you don't have to do it one element at a time ($pos = $new), and lines only end in semicolons if you want to add a comment in AutoIt. Edited November 5, 2007 by PsaltyDS 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 Link to comment Share on other sites More sharing options...
d0n Posted November 5, 2007 Author Share Posted November 5, 2007 for some reason when i use that code, it still only gives me the pixel under the current mouse, not the dot to the left of the mouse and somehow after the 1st use of the insert key, the dot changes color to white? i am gonna try working on it again tonight thanks for the help Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 5, 2007 Share Posted November 5, 2007 (edited) for some reason when i use that code, it still only gives me the pixel under the current mouse, not the dot to the left of the mouse and somehow after the 1st use of the insert key, the dot changes color to white? i am gonna try working on it again tonight thanks for the help That's exactly what I thought it was supposed to do. Each time you hit INSERT the color at the mouse position is read and the dot is changed to that color. The problem with reading the color at the dot, is the color IS the dot. So you have to temporarily hide the dot to see the color under it. This leaves the dot green, and just pops up the color under the center of the dot. Since you placed a 5x5 dot at (-30,0) offset from the mouse, the center of the dot is a (-28,+2) offset. I also added the $WS_EX_TOPMOST extended style, just 'cause it seems sensible: #include "GUIConstants.au3" Global $pos = MouseGetPos(), $new_bobber = 0x00FF00 $a = GUICreate("GUI", 5, 5, $pos[0] - 30, $pos[1], $WS_POPUP, $WS_EX_TOPMOST ) GUISetBkColor($new_bobber, $a) GUISetState(@SW_SHOW) HotKeySet("{Insert}", "Pixel") HotKeySet("{ESC}", "_Quit") While 1 $new = MouseGetPos() If $new[0] <> $pos[0] Or $new[1] <> $pos[1] Then WinMove("GUI", "", $new[0] - 30, $new[1]) EndIf $pos = $new Sleep(20) WEnd Func Pixel() GUISetState(@SW_HIDE, $a) $new_bobber = PixelGetColor($pos[0] - 28, $pos[1] + 2) GUISetState(@SW_SHOW, $a) $color_bobber = "0x" & Hex($new_bobber, 6) MsgBox(0, "Color", $color_bobber) EndFunc ;==>Pixel Func _Quit() Exit EndFunc ;==>_Quit Edited November 5, 2007 by PsaltyDS 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 Link to comment Share on other sites More sharing options...
d0n Posted November 5, 2007 Author Share Posted November 5, 2007 (edited) just a question, why do you want to hide it and show it again after it gets the pixel, does it not change in real time or something? just for clarification i wanted this code to read the hex color at the green dot and show it on the msgbox the code above only gives me 0x00FF00 as the hex, not sure why tho EDIT, does it only work in the window i started with? cuz when i go over to firefox all i get is 0x00FF00, but if i use it on the SciTE4Autoit thing it would give me some different numbers so it does work but only in the window that i started the script in, what would be the best way to fix this? Edited November 5, 2007 by d0n Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 5, 2007 Share Posted November 5, 2007 (edited) just a question, why do you want to hide it and show it again after it gets the pixel, does it not change in real time or something?just for clarification i wanted this code to read the hex color at the green dot and show it on the msgboxthe code above only gives me 0x00FF00 as the hex, not sure why thoThe dot is green. If you read the color at the dot... it will be green... You can't read the color UNDER the dot; you will only read the color OF the dot unless you hide the dot temporarily. The Hide/Show happens so fast that you can't tell anyway.EDIT, does it only work in the window i started with? cuz when i go over to firefox all i get is 0x00FF00, but if i use it on the SciTE4Autoit thing it would give me some different numbersso it does work but only in the window that i started the script in, what would be the best way to fix this?The code I posted last works fine on any window, including Firefox. If you are modifying the code before running it, post your version so we can debug it. Edited November 5, 2007 by PsaltyDS 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 Link to comment Share on other sites More sharing options...
d0n Posted November 5, 2007 Author Share Posted November 5, 2007 i am using the same code you posted atm #include "GUIConstants.au3" Global $pos = MouseGetPos(), $new_bobber = 0x00FF00 $a = GUICreate("GUI", 5, 5, $pos[0] - 30, $pos[1], $WS_POPUP, $WS_EX_TOPMOST ) GUISetBkColor($new_bobber, $a) GUISetState(@SW_SHOW) HotKeySet("{Insert}", "Pixel") HotKeySet("{ESC}", "_Quit") While 1 $new = MouseGetPos() If $new[0] <> $pos[0] Or $new[1] <> $pos[1] Then WinMove("GUI", "", $new[0] - 30, $new[1]) EndIf $pos = $new Sleep(20) WEnd Func Pixel() GUISetState(@SW_HIDE, $a) $new_bobber = PixelGetColor($pos[0] - 28, $pos[1] + 2) GUISetState(@SW_SHOW, $a) $color_bobber = "0x" & Hex($new_bobber, 6) MsgBox(0, "Color", $color_bobber) EndFunc ;==>Pixel Func _Quit() Exit EndFunc ;==>_Quit if i start the script on my desktop, it will work on the desktop, but if i open firefox or any program that overlaps the desktop, it will only give me 0x00FF00 Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 5, 2007 Share Posted November 5, 2007 i am using the same code you posted atmif i start the script on my desktop, it will work on the desktop, but if i open firefox or any program that overlaps the desktop, it will only give me 0x00FF00Works fine. Doesn't do that for me on XP Pro, with AutoIt 3.2.8.1. What are you running it on? 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 Link to comment Share on other sites More sharing options...
d0n Posted November 5, 2007 Author Share Posted November 5, 2007 XP Pro, how would i find the autoit version Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 6, 2007 Share Posted November 6, 2007 XP Pro, how would i find the autoit version If you are running it from ScitTE, the console output includes the version: >"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Program Files\AutoIt3\Scripts\Test_1.au3" /autoit3dir "C:\Program Files\AutoIt3" /UserParams +>20:27:12 Starting AutoIt3Wrapper v.1.9.3 >Running AU3Check (1.54.9.0) from:C:\Program Files\AutoIt3 +>20:27:12 AU3Check ended.rc:0 >Running:(3.2.8.1):C:\Program Files\AutoIt3\autoit3.exe "C:\Program Files\AutoIt3\Scripts\Test_1.au3" +>20:27:17 AutoIT3.exe ended.rc:0 +>20:27:18 AutoIt3Wrapper Finished >Exit code: 0 Time: 6.724 This part shows version: ">Running:(3.2.8.1)" You could also just use the @AutoItVersion macro: MsgBox(64, "Version", "AutoIt Version = " & @AutoItVersion) 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 Link to comment Share on other sites More sharing options...
d0n Posted November 6, 2007 Author Share Posted November 6, 2007 mm i am only running 3.2.6.0, i guess i'll update it and give it another go Link to comment Share on other sites More sharing options...
d0n Posted November 6, 2007 Author Share Posted November 6, 2007 so i updated to 3.2.8.1, but it still does the same thing, only getting the pixel from desktop but not anything that overlaps it, files, firefox ect :S 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