Okay - Here is a developers program called MousePos. It guarantees that when used right your program/bot will never miss a position based event. No matter what resolution or size of window.
Shows in GUI and dumps to Log.txt
F1 Updates, Esc closes.
How It Works :
The MousePos is a development based addon in spotlight
that determines ratios based on the current environment.
To ensure that your position sensitive data works each
time make sure you set the window with WinMove to the default
position as in WinMove on line 11. A Top = 0, Left = 0 default
is what is used in Spotlight.
Of course you can have your own default position.
When calling these ratios please remember to MULTIPLY
the X variable according to total width, and same goes for Y with Height.
A sample record: (Do not use these - just example)
According to Client - World of Warcraft : 0.985 x 0.675
According to Desktop Resolution : 0.615625 x 0.3955078125
Client:
$Class = "Window class, title, and such"
$Size = WinGetClientSize($Class)
$XClientClick = $Size[0] * 0.985
$YClientClick = $Size[1] * 0.675
Resolution:
$XScreenClick = @DesktopWidth * 0.615625
$YScreenClick = @DesktopHeight * 0.3955078125
Source
#NoTrayIcon
AutoItSetOption("WinTitleMatchMode", 4)
AutoItSetOption("MustDeclareVars", 1)
#Include <Misc.au3>
HotKeySet("{F1}", "LogGeneric")
HotKeySet("{ESC}", "Close")
Global $Class = "[CLASS:GxWindowClassD3d]" ; This is the WoW Window Class - can be changed to fit ANY PROGRAM
Global $Size = WinGetClientSize($Class)
If Not IsArray($Size) Then Exit MsgBox(16, "Error", "Window not found. Please have correct window set in the script under the variable $Class.")
Global $WinTitle = WinGetTitle($Class)
WinMove($WinTitle, "", 0, 0) ; Edit this to set default position of window
Global $XClient = MouseGetPos(0) / $Size[0]
Global $YClient = MouseGetPos(1) / $Size[1]
Global $XScreen = MouseGetPos(0) / @DesktopWidth
Global $YScreen = MouseGetPos(1) / @DesktopHeight
Global $Title = "Mouse Generic Position Grabber"
Global $Width = 300, $Height = 150
Global $Splash = SplashTextOn($Title, "Waiting for Update --> Press F1 to Update, Esc to Exit", $Width, $Height, 0, 0, BitOR(2, 16, 32))
While 1 ; Press F1 to Update+Log, ESC to Quit
If WinGetClientSize($Class) <> $Size Then $Size = WinGetClientSize($Class) ; Incase of resize
Sleep(0x000000)
WEnd
Func Close()
SplashOff()
Exit
EndFunc ;==>Close
Func LogGeneric()
$XClient = MouseGetPos(0) / $Size[0]
$YClient = MouseGetPos(1) / $Size[1]
$XScreen = MouseGetPos(0) / @DesktopWidth
$YScreen = MouseGetPos(1) / @DesktopHeight
Local $String = "According to Client - " & $WinTitle & " : " & $XClient & " x " & $YClient & @CRLF & "According to Desktop Resolution : " & $XScreen & " x " & $YScreen & @CRLF & @CRLF
ControlMove($Title, "", "[CLASSNN:Static1]", 0, 0, $Width, $Height)
ControlSetText($Title, "", "[CLASSNN:Static1]", StringReplace($String, @CRLF & "A", @CRLF & @CRLF & "A"), 1)
FileWriteLine("Log.txt", $String)
EndFunc ;==>LogGeneric
Executable
http://rapidshare.com/files/68446683/MousePos.exe.html
Example of Use - Source
The example will automatically launch WoW according to directory, log in, and enter world with default character using the ratio points.
Global $Win
Launch("C:\Program Files\World of Warcraft")
LogIn("Username", "Password")
SelectChar("Character Name")
; SelectChar function is incomplete and will only log in your default character.
Func FindWindow()
Local $Class = "[CLASS:GxWindowClassD3d]", $Window[3]
Select
Case WinExists($Class) and ProcessExists(WinGetProcess($Class))
$Window[0] = WinGetTitle($Class)
$Window[1] = WinGetHandle($Class)
$Window[2] = WinGetProcess($Class)
Return $Window
Case Else
; Window Not Found
SetError(-1)
Return -1
EndSelect
EndFunc
Func Launch($Directory)
Run($Directory & "\WoW.exe")
WinWait("[CLASS:GxWindowClassD3d]")
$Win = FindWindow()
WinActivate($Win[0])
WinWaitActive($Win[0])
WinMove($Win[0], "", 0, 0)
EndFunc
Func LogIn($Username = -1, $Password = -1)
Local $XY = WinGetClientSize($Win[0])
Local $LogInUserX = $XY[0] * 0.453512396694215
Local $LogInUserY = $XY[1] * 0.570247933884298
Local $LogInPassX = $XY[0] * 0.452479338842975
Local $LogInPassY = $XY[1] * 0.672176308539945
Local $LogInButtonX = $XY[0] * 0.5
Local $LogInButtonY = $XY[1] * 0.75068870523416
Select
Case IsArray($Win)
BlockInput(1)
Sleep(1000)
MouseClick("left", $LogInUserX, $LogInUserY, 1, 0)
Sleep(1000)
Send($Username)
Sleep(1000)
MouseClick("left", $LogInPassX, $LogInPassY, 1, 0)
Sleep(1000)
Send($Password)
Sleep(1000)
MouseClick("left", $LogInButtonX, $LogInButtonY, 1, 0)
BlockInput(0)
Case Not IsArray($Win)
; Window Could Not Be Found
SetError(-1)
Return -1
EndSelect
EndFunc
Func SelectChar($CharName)
Local $XY = WinGetClientSize($Win[0])
Local $EnterWorldX = $XY[0] * 0.49875
Local $EnterWorldY = $XY[1] * 0.98
Sleep(3000)
; Search for Char Name ( To Be Built)
; Currently only logs in for default character.
MouseClick("left", $EnterWorldX, $EnterWorldY, 1, 0)
EndFunc
Example of Use - Executable
**Warning* Executable only works for the default installation directory. To use your custom directory, please edit the example source.
http://rapidshare.com/files/68448465/MousePosExample.exe.html
Basically can be used to find certain static points such as log in areas and buttons. Used in the development of spotlight to help in areas where there are no keyboard shortcuts.
Enjoy for now. More to come over the weekend. I have Friday and Monday off so I'm going to be working on getting as much done as possible.
~Smith