Sign in to follow this  
Followers 0
ziiion

_IsPressed and MouseGetPos help plz

4 posts in this topic

#1 ·  Posted (edited)

hi im tryin to test this codes but i got stuck on this i got it to work after 30min =)

but now i get the same mouse coordinates every time i click how can i do to make it show updated coordinates of the mouse .

:idiot: :"> im trying to make a Script that captures the mouse click on window A and does it to another window B ... this were im at =)

thanx in advance

While 1
   If _IsPressed('1b') = 1 Then Exit;1b is ESC
   If _IsPressed('01') = 1 Then $pos = MouseGetPos()
      MsgBox(0, "Mouse x,y:", $pos[0] & "," & $pos[1])
   Sleep(1)
Wend

Exit

Func _IsPressed($hexKey);no need changing
  ; $hexKey must be the value of one of the keys.
  ; _IsPressed will return 0 if the key is not pressed, 1 if it is.
   
   Local $aR, $bRv;,$hexKey
   $hexKey = '0x' & $hexKey
   $aR = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey)
  ;If $aR[0] = -32767 Then
   If $aR[0] <> 0 Then
      $bRv = 1
   Else
      $bRv = 0
   EndIf
   
   Return $bRv
EndFunc ;==>_IsPressed
Edited by ziiion

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

While 1
  If _IsPressed('1b') = 1 Then Exit;1b is ESC
  If _IsPressed('01') = 1 Then 
     $pos = MouseGetPos()
     MsgBox(0, "Mouse x,y:", $pos[0] & "," & $pos[1])
   EndIf
  Sleep(1)
Wend

Exit

Func _IsPressed($hexKey);no need changing
; $hexKey must be the value of one of the keys.
; _IsPressed will return 0 if the key is not pressed, 1 if it is.
 
  Local $aR, $bRv;,$hexKey
  $hexKey = '0x' & $hexKey
  $aR = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey)
;If $aR[0] = -32767 Then
  If $aR[0] <> 0 Then
     $bRv = 1
  Else
     $bRv = 0
  EndIf
 
  Return $bRv
EndFunc;==>_IsPressed

In you code the Then $pos = mousegetpos is the only thing the if statement preformed so it kept just going onto the msgbox

Edited by killaz219

Share this post


Link to post
Share on other sites

func ReportClick()

$pos = MouseGetPos()

MsgBox(0, "Mouse x,y:", $pos[0] & "," & $pos[1])

endfunc

While 1

If _IsPressed('1b') = 1 Then Exit;1b is ESC

If _IsPressed('01') = 1 Then

ReportClick()

Sleep(1)

endif

Wend

Exit

Func _IsPressed($hexKey);no need changing

; $hexKey must be the value of one of the keys.

; _IsPressed will return 0 if the key is not pressed, 1 if it is.

Local $aR, $bRv;,$hexKey

$hexKey = '0x' & $hexKey

$aR = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey)

;If $aR[0] = -32767 Then

If $aR[0] <> 0 Then

$bRv = 1

Else

$bRv = 0

EndIf

Return $bRv

EndFunc ;==>_IsPressed

try this :idiot: just needed a little function and it works :D

enjoy

Share this post


Link to post
Share on other sites

func ReportClick()

  $pos = MouseGetPos()

  MsgBox(0, "Mouse x,y:", $pos[0] & "," & $pos[1])

endfunc

While 1

  If _IsPressed('1b') = 1 Then Exit;1b is ESC

  If _IsPressed('01') = 1 Then

  ReportClick()

  Sleep(1)

  endif

  Wend

Exit

Func _IsPressed($hexKey);no need changing

; $hexKey must be the value of one of the keys.

; _IsPressed will return 0 if the key is not pressed, 1 if it is.

 

  Local $aR, $bRv;,$hexKey

  $hexKey = '0x' & $hexKey

  $aR = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey)

;If $aR[0] = -32767 Then

  If $aR[0] <> 0 Then

    $bRv = 1

  Else

    $bRv = 0

  EndIf

 

  Return $bRv

EndFunc ;==>_IsPressed

try this :D just needed a little function and it works :lol:

enjoy

<{POST_SNAPBACK}>

thx so much i just got in from work =) that will help me understand this and now i can move on with the script :idiot:

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  
Followers 0