Jump to content

_IsPressed and MouseGetPos help plz


ziiion
 Share

Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
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

Link to comment
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:
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...