Jump to content
Sign in to follow this  
doomsday123

Handle Click Event?

Recommended Posts

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 by layer

FootbaG

Share this post


Link to post
Share on other sites

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! :lmao:


FootbaG

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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
      EndFunc

ok, 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 o:)

EDIT: sorry, i misunderstood you, its late and im tired, tomorrow i will help you :):lmao:

Edited by layer

FootbaG

Share this post


Link to post
Share on other sites

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 by doomsday123

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 :lmao:


FootbaG

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 by falconv

Share this post


Link to post
Share on other sites

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.

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 by Jos

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...