doomsday123 Posted January 25, 2005 Share Posted January 25, 2005 What I want to do is to save the X and Y location of the mouse when the user does a single Left Click. How would i do this? Thanks Link to comment Share on other sites More sharing options...
layer Posted January 25, 2005 Share Posted January 25, 2005 (edited) Func _IsPressed($hexKey) Local $aR, $bRv $hexKey = '0x' & $hexKey $aR = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey) If $aR[0] <> 0 Then $bRv = 1 Else $bRv = 0 EndIf Return $bRv EndFunc $pos= MouseGetPos () While 1 If _IsPressed ('01') then ToolTip ("X: " & $pos[0] & " Y: " & $pos[1], $pos[0], $pos[1]); replace the MsgBox with whatever function you want! Sleep (100) it should work, untested EDIT: changed it to a tooltip Edited January 25, 2005 by layer FootbaG Link to comment Share on other sites More sharing options...
doomsday123 Posted January 25, 2005 Author Share Posted January 25, 2005 That will work for a mouse click or a key press? Link to comment Share on other sites More sharing options...
layer Posted January 25, 2005 Share Posted January 25, 2005 a mouseclick, or just to make things easier... HotKeySet ("{ESC}", "MyExit") HotKeySet ("{PAUSE}", "Clip") While 1 $pos= MouseGetPos () $color= PixelGetColor ($pos[0], $pos[1]) $hexit= Hex ($color, 6) ToolTip ("X: " & $pos[0] & " " & "Y: " & $pos[1] _ & @lf & _ "RGB Color under mouse: 0x" & $hexit, $pos[0] + 10, $pos[1] + 10) Sleep (10) WEnd Func Clip () ClipPut ("The color at" & " " & "X: " & $pos[0] & " and" & " " & "Y: " & $pos[1] & " " & "is" & " " & "0x" & $hexit) EndFunc Func MyExit () Exit EndFunc press the "Pause" button on keyboard to copy the current mouse position and the color of the pixel... and pres the "Esc" button on the keyboard to exit! FootbaG Link to comment Share on other sites More sharing options...
doomsday123 Posted January 25, 2005 Author Share Posted January 25, 2005 Im trying to add the X pos and the Y pos to arrays each time I hit the space bar but i cant get it to work. global $i= 0 global $X[50] global $Y[50] HotKeySet ("{ESC}", "MyExit") HotKeySet ("{SPACE}", "Clip") While 1 global $pos= MouseGetPos () $color= PixelGetColor ($pos[0], $pos[1]) $hexit= Hex ($color, 6) ToolTip ("X: " & $pos[0] & " " & "Y: " & $pos[1] _ & @lf & _ "RGB Color under mouse: 0x" & $hexit, $pos[0] + 10, $pos[1] + 10) Sleep (10) WEnd Func Clip () $X[i]= pos[0] $Y[i]= pos[1] $i= ($i + 1) EndFunc Func MyExit () Exit EndFunc Link to comment Share on other sites More sharing options...
layer Posted January 25, 2005 Share Posted January 25, 2005 (edited) like:HotKeySet ("{ESC}", "MyExit") HotKeySet ("{SPACE}", "Clip") While 1 $pos= MouseGetPos () $color= PixelGetColor ($pos[0], $pos[1]) $hexit= Hex ($color, 6) ToolTip ("X: " & $pos[0] & " " & "Y: " & $pos[1] _ & @lf & _ "RGB Color under mouse: 0x" & $hexit, $pos[0] + 10, $pos[1] + 10) Sleep (10) WEnd Func Clip () $pos= MouseGetPos () ClipPut ("X: " & $pos[0] & " Y: " & $pos[1]) EndFunc Func MyExit () Exit EndFuncok, press space to put the current X and Y in the clipboard... and hit esc to exit... and to get the clipboard.. go to any text editor like notepad, and hit "Ctrl+V"k? k bye EDIT: sorry, i misunderstood you, its late and im tired, tomorrow i will help you Edited January 25, 2005 by layer FootbaG Link to comment Share on other sites More sharing options...
doomsday123 Posted January 25, 2005 Author Share Posted January 25, 2005 (edited) But what I am wanting to do is to store it in an array every time i click space. I want to do this so i can later make it to where it will go to every mouse position i hit spacebar at. Anyone know how i could do this?EDIT: Hehe Ok THanks Edited January 25, 2005 by doomsday123 Link to comment Share on other sites More sharing options...
closeupman Posted January 25, 2005 Share Posted January 25, 2005 But what I am wanting to do is to store it in an array every time i click space. I want to do this so i can later make it to where it will go to every mouse position i hit spacebar at. Anyone know how i could do this?EDIT: Hehe Ok THanks<{POST_SNAPBACK}>I'm seeing by ur edit someone pm'd obviously.You should try before you ask. The person gave you all the code.....all you had to do was add an array and store it. Link to comment Share on other sites More sharing options...
doomsday123 Posted January 25, 2005 Author Share Posted January 25, 2005 Lol. you must have missed it but i did try it. I posted the code that i tried and for some reason it is giving me an error... Link to comment Share on other sites More sharing options...
layer Posted January 25, 2005 Share Posted January 25, 2005 HotKeySet ("{ESC}", "MyExit") HotKeySet ("{SPACE}", "Clip") While 1 $pos= MouseGetPos () $color= PixelGetColor ($pos[0], $pos[1]) $hexit= Hex ($color, 6) ToolTip ("X: " & $pos[0] & " " & "Y: " & $pos[1] _ & @lf & _ "RGB Color under mouse: 0x" & $hexit, $pos[0] + 10, $pos[1] + 10) Sleep (10) WEnd Func Clip () $pos= MouseGetPos () FileWriteLine ("XYCoords.txt", "X: " & $pos[0] & " Y: " & $pos[1]) EndFunc Func MyExit () Exit EndFunc ... chances are, the arrays will not help you because, im not so good with arrays except in a few cases, and i think there is a limit.. and it's not enough for what you want to do, so instaed, i just made it write it to a text file in the directory the script is in FootbaG Link to comment Share on other sites More sharing options...
doomsday123 Posted January 25, 2005 Author Share Posted January 25, 2005 Very cool. What i am trying to work towards is to be able to press TAB and for it to move the mouse to every location i hit SPACE at in the same order. Here is what i have so far but it wont work with more than one location. It only goes to the last location I pressed space at. Dim $counter= 0 Dim $Xar[50] Dim $Yar[50] HotKeySet ("{ESC}", "MyExit") HotKeySet ("{SPACE}", "Clip") HotKeySet ("{TAB}", "Play") While 1 $pos= MouseGetPos () $color= PixelGetColor ($pos[0], $pos[1]) $hexit= Hex ($color, 6) ToolTip ("X: " & $pos[0] & " " & "Y: " & $pos[1] _ & @lf & _ "RGB Color under mouse: 0x" & $hexit, $pos[0] + 10, $pos[1] + 10) Sleep (10) WEnd Func Clip () $pos= MouseGetPos () $Xar[$counter]= $pos[0] $Yar[$counter]= $pos[1] EndFunc Func Play () $i= 0 While $i <= $counter MouseMove($Xar[$i], $Yar[$i]) ; Sleep(100) $i= $i + 1 Wend EndFunc Func MyExit () Exit EndFunc If you could help it would be great. Thanks. Link to comment Share on other sites More sharing options...
falconv Posted January 25, 2005 Share Posted January 25, 2005 (edited) Forgive me if I missed something, but at a glance, it looks like you're not telling it when to increase the count, therefore each time you press {Space}, it replaces the last entry added. Func Clip () $pos= MouseGetPos () $Xar[$counter]= $pos[0] $Yar[$counter]= $pos[1] $counter = $counter + 1 EndFunc Edited January 25, 2005 by falconv Link to comment Share on other sites More sharing options...
doomsday123 Posted January 25, 2005 Author Share Posted January 25, 2005 Haha ! Thank you sir. I looked over that Link to comment Share on other sites More sharing options...
closeupman Posted January 26, 2005 Share Posted January 26, 2005 (edited) here ya go....a bit simpler...using one array (note:the first value [0] is a dummy....but doesnt affect the program) Hope ya like...I tested it and it was fine.expandcollapse popup global $mouse_pos[1] global const $TRUE=1 HotKeySet("{SPACE}", "RecordMouse") HotKeySet("{ESC}", "Leave") HotKeySet("{TAB}", "Play") while $TRUE sleep(50) wend func RecordMouse() $pos = MouseGetPos() _ArrayAdd($mouse_pos,$pos[0]) _ArrayAdd($mouse_pos,$pos[1]) endfunc Func Play() local $icounter,$smgsg,$displaycount=1 ;do from 1 cuz 0 is a dummy value, cuz have to declare array of size 1 by default For $iCounter = 1 To UBound($mouse_pos) - 1 if mod($icounter,2)<>0 then MouseMove($mouse_pos[$icounter],$mouse_pos[$icounter+1]) sleep(100) Next endfunc Func Leave() Exit EndFunc ;=============================================================================== ; ; Function Name: _ArrayAdd() ; Description: Adds a specified value at the end of an array, returning the ; adjusted array. ; Author(s): Jos van der Zande ; ;=============================================================================== Func _ArrayAdd(ByRef $avArray, $sValue) If IsArray($avArray) Then ReDim $avArray[uBound($avArray) + 1] $avArray[uBound($avArray) - 1] = $sValue SetError(0) Else SetError(1) EndIf Return 1 EndFunc ;==>_ArrayAdd Edited October 21, 2013 by Jos 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