Jump to content

mouse coordinates way off


Recommended Posts

im having some issues with mouse coordinates. i have the coordinates in exactly how i want them, but when i run the program the mouse is waaayyyyy off. im using the same code several times and the rest of the code works fine. its just the one chunk of code. any suggestions would be awesome! this is my source:

; Prompt the user to run the script - use a Yes/No prompt

$answer = MsgBox(36, "Update Script", "This script will launch Blocklist Manager, check for new sources, update lists, and import to PeerGuardian, Run?")

; Check the user's answer to the prompt

; If "No" was clicked (7) then exit the script

If $answer = 7 Then

MsgBox(48, "Update Script", "Update has been Canceled!")

Exit

EndIf

; Clear Blocklist Manager Cache

FileDelete("C:\Program Files\Bluetack\Blocklist Manager\Cache\*.*")

; Run Blocklist

Run("C:\Program Files\Bluetack\Blocklist Manager\BlockMgr.exe")

; Wait for Blocklist Manager to become active

WinWaitActive("Blocklist Manager")

; Check for new sources

WinActivate("Blocklist Manager")

Send("^u")

; The following code extracts the number of new sources and assigns the number to $Sources

WinActivate("Blocklist Manager", "")

Opt("WinTitleMatchMode", 4)

Opt("MouseCoordMode", 0);1=absolute, 0=relative, 2=client

$hWin = WinGetHandle("")

$CtrlHwnd = ControlGetHandle("","","")

$aStart = _WinCtrlPtToScreenPt($hWin, $CtrlHwnd, 193, 69) ; <== Change start coordinates here

$aEnd = _WinCtrlPtToScreenPt($hWin, $CtrlHwnd, 207, 69) ; <== Change end coordinates here

MouseClickDrag("left",$aStart[0], $aStart[1], $aEnd[0], $aEnd[1])

Send("^{INSERT}")

$Sources = ClipGet()

; Process Blocklists

Send ("^p")

; Wait for Blocklists to finish downloading

WinWaitActive("Blocklist Manager", "BLM Version: 2.7.7")

; Code to Assign Blocked Number of Ip Addresses to $DenyIPCount

WinActivate("Blocklist Manager")

$hWin = WinGetHandle("")

$CtrlHwnd = ControlGetHandle("","","")

$aStart = _WinCtrlPtToScreenPt($hWin, $CtrlHwnd, 171, 298) ; <== Change start coordinates here

$aEnd = _WinCtrlPtToScreenPt($hWin, $CtrlHwnd, 281, 298) ; <== Change end coordinates here

MouseClickDrag("left",$aStart[0], $aStart[1], $aEnd[0], $aEnd[1])

Send("^{INSERT}")

$DenyIPCount = ClipGet()

; Code to Assign Number of Errors to $ErrorCount

WinActivate("Blocklist Manager", "")

$hWin = WinGetHandle("")

$CtrlHwnd = ControlGetHandle("","","")

$aStart = _WinCtrlPtToScreenPt($hWin, $CtrlHwnd, 170, 369) ; <== Change start coordinates here

$aEnd = _WinCtrlPtToScreenPt($hWin, $CtrlHwnd, 185, 369) ; <== Change end coordinates here

MouseClickDrag("left",$aStart[0], $aStart[1], $aEnd[0], $aEnd[1])

Send("^{INSERT}")

$ErrorCount = ClipGet()

; If there are errors, show MsgBox

If $ErrorCount > 0 Then

MsgBox(48, "Error", "One or more errors have occured!")

EndIf

; Launch Blocklist Converter

Send ("!t{DOWN}{RIGHT}{ENTER}")

; Wait for Blocklist Manager converter to become active

WinWaitActive("Convert from Memory Array...")

; Start Blocklist Converter

Send ("!v")

; Wait for Conversion to Finish by changing focus, waiting for "Conversion Complete" then changing focus back to "Convert from Memory Array..."

WinActivate("Blocklist Manager")

WinWaitActive("Blocklist Manager", "Conversion Complete.")

WinActivate("Convert from Memory Array...")

; Save Output As

Send ("!a")

; Wait for Save As window to become active

WinWaitActive("Save As")

Sleep(1000)

; Save file as Paranoid Blocklist.p2p

Send("Paranoid Blocklist.p2p")

Sleep(1000)

Send("{ENTER}")

Sleep(1000)

Send("!y")

; Wait for save to finish

WinWaitClose("Save As")

; Close convert from memory array window

WinClose("Convert from Memory Array...")

WinWaitClose("Convert from Memory Array...")

; Close blocklist manager

WinClose("Blocklist Manager")

WinWaitClose("Blocklist Manager")

; Apply the updates to Peer Guardian

FileDelete("C:\Program Files\PeerGuardian2\cache.p2b")

WinActivate("PeerGuardian 2")

ControlCommand("PeerGuardian 2", "", 1172, "UnCheck", "")

WinClose("PeerGuardian 2", "")

Sleep(1000)

Run("C:\Program Files\PeerGuardian2\pg2.exe")

WinWaitActive("PeerGuardian 2","")

ControlCommand("PeerGuardian 2", "", 1172, "Check", "")

WinClose("PeerGuardian 2", "")

;Show Final Prompt with number of blocked IP's and Number of Errors

MsgBox(64, "Update Script", "Update Completed." & @CRLF & "Number of IP Addresses Being Blocked: " & $DenyIPCount & @CRLF & "Number of new Sources: " & $Sources & @CRLF & "Number of Errors: " & $ErrorCount)

Func _WinCtrlPtToScreenPt($WinHwnd, $CtrlHwnd, $iX, $iY)

Local $aRet[2], $tpoint

; ControlClick Coords

$tpoint = DllStructCreate("int X;int Y")

DllStructSetData($tpoint, "X", $iX)

DllStructSetData($tpoint, "Y", $iY)

_WinAPI_ClientToScreen($CtrlHwnd, $tpoint)

;$aCtrlPos = ControlGetPos($WinHwnd, "", $CtrlHwnd)

$aRet[0] = DllStructGetData($tpoint, "X");+ $aCtrlPos[0]

$aRet[1] = DllStructGetData($tpoint, "Y"); + $aCtrlPos[1]

Return $aRet

EndFunc ;==>_WinCtrlPttoScreenPt

Link to comment
Share on other sites

So, where in there was the problem? Can you reduce it to a short script that reproduces just this symptom?

You have several mouse coordinates used with literal values. Where did those values come from?

You have MouseCoordMode = 0 = relative coords to the active window. Does that match how you derived the literal coordinates used?

:)

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

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...