Jump to content

Help with working on other resolutions..


Recommended Posts

My script works perfectly on the resolution it was created in of course, but on others it fails. I've searched for the answer, tried so many different possibilities, but i guess i'm not that good at coding yet.. I've been working on this for 6 days so far and its really aggravating, any actual insight/help would be really appreciated.

Here's the main part of my script(prior to many attempts to get it working on many resolutions)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
While 1 = 1

$coord = PixelSearch(485, 228, @DesktopWidth, @DesktopHeight, 0xECEEF5)
If Not @error Then
    
MouseClick("Left", $coord[0], $coord[1], 1, 1)
Sleep(500)
EndIf

$coord = PixelSearch(703, 532, @DesktopWidth, @DesktopHeight, 0x98E6FF)
If Not @error Then

MouseClick("left", $coord[0], $coord[1], 1, 1)
Sleep(4000)
EndIf

$coord = PixelSearch(576, 609, @DesktopWidth, @DesktopHeight, 0x9CBA26)
If Not @error Then
    
MouseClick("Left", $coord[0], $coord[1], 1, 1)
Sleep(500)
EndIf



WEnd
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Please excuse my one post as i've never really needed help before.

Edited by NeverDUN
Link to comment
Share on other sites

(on a web page) It clicks a button, the another button, then a link.

For resolve your different resolution problem you can do like this, but you must find the handle of the browser window.

An example to understand the 2 relatives coordinates mods that you can get ! Posted Image

#include <WinAPI.au3>

$hwnd = GUICreate ( "Gui" )
GUISetState ( )
MouseMove ( @DesktopWidth/2, @DesktopHeight/2 )
Local $iX = _WinAPI_GetMousePosX ( )
Local $iX2 = _WinAPI_GetMousePosX ( True, $hwnd )
Local $iY = _WinAPI_GetMousePosY ( )
Local $iY2 = _WinAPI_GetMousePosY ( True, $hwnd )

ConsoleWrite ( "Screen Mouse Pos : "  & @Crlf & "X = " & $iX & @LF & "Y = " & $iY & @LF & @LF & "Gui  Mouse Pos : " & @LF & "X = " & $iX2 & @LF & "Y = " & $iY2 & @Crlf )

Or you can try by IE.au3

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

For resolve your different resolution problem you can do like this, but you must find the handle of the browser window.

An example to understand the 2 relatives coordinates mods that you can get ! Posted Image

#include <WinAPI.au3>

$hwnd = GUICreate ( "Gui" )
GUISetState ( )
MouseMove ( @DesktopWidth/2, @DesktopHeight/2 )
Local $iX = _WinAPI_GetMousePosX ( )
Local $iX2 = _WinAPI_GetMousePosX ( True, $hwnd )
Local $iY = _WinAPI_GetMousePosY ( )
Local $iY2 = _WinAPI_GetMousePosY ( True, $hwnd )

ConsoleWrite ( "Screen Mouse Pos : "  & @Crlf & "X = " & $iX & @LF & "Y = " & $iY & @LF & @LF & "Gui  Mouse Pos : " & @LF & "X = " & $iX2 & @LF & "Y = " & $iY2 & @Crlf )

Or you can try by IE.au3

Thanks very much. I'll try to understand this, add it to my script and make the necessary adjustments >.<
Link to comment
Share on other sites

This is the conclusion i've come too.. Haven't tested it on another resolution so idk if it works or no..

t but what i want to know is: Should i use the control coords or mouse coords?

I'm guessing since i used PixelSearch i should do:

Opt("PixelCoordMode", 2) For it to work on other peoples comps with different resolutions..

ps. dont want it to work just on IE, it works on all browsers with my resolution..

#include <WinAPI.au3>
#include <IE.au3>
Local $hWnd = WinGetHandle("[CLASS:Internet Explorer_Server; INSTANCE:1]")
Global $Paused

Opt("WinWaitDelay", 1000)
Opt("WinTitleMatchMode", 4)
Opt("WinDetectHiddenText", 1)
Opt("TrayIconDebug", 1)

WinActivate("Get More Twitter Followers, Facebook Likes & Youtube Views | Twiends - Windows Internet Explorer")
WinWait("Get More Twitter Followers, Facebook Likes & Youtube Views | Twiends - Windows Internet Explorer", "")
If Not WinActive("Get More Twitter Followers, Facebook Likes & Youtube Views | Twiends - Windows Internet Explorer", "") Then WinActivate("Get More Twitter Followers, Facebook Likes & Youtube Views | Twiends - Google Chrome", "")
WinWaitActive("Get More Twitter Followers, Facebook Likes & Youtube Views | Twiends - Windows Internet Explorer", "")

HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("+!d", "ShowMessage") 

$hwnd = GUICreate ( "Gui" )
GUISetState ( )
MouseMove ( @DesktopWidth/2, @DesktopHeight/2 )
Local $iX = _WinAPI_GetMousePosX ( )
Local $iX2 = _WinAPI_GetMousePosX ( True, $hwnd )
Local $iY = _WinAPI_GetMousePosY ( )
Local $iY2 = _WinAPI_GetMousePosY ( True, $hwnd )

ConsoleWrite ( "Screen Mouse Pos : "  & @Crlf & "X = " & $iX & @LF & "Y = " & $iY & @LF & @LF & "Gui  Mouse Pos : " & @LF & "X = " & $iX2 & @LF & "Y = " & $iY2 & @Crlf )


While 1 = 1


    $coord = PixelSearch(485, 228, @DesktopWidth, @DesktopHeight, 0xECEEF5)
    If Not @error Then

        MouseClick("Left", $coord[0], $coord[1], 1, 1)
        Sleep(500)
    EndIf

    $coord = PixelSearch(703, 532, @DesktopWidth, @DesktopHeight, 0x98E6FF)
    If Not @error Then

        MouseClick("left", $coord[0], $coord[1], 1, 1)
        Sleep(5000)
    EndIf

    $coord = PixelSearch(576, 609, @DesktopWidth, @DesktopHeight, 0x9CBA26)
    If Not @error Then

        MouseClick("Left", $coord[0], $coord[1], 1, 1)
        Sleep(500)
    EndIf


WEnd


Func TogglePause()
    $Paused = Not $Paused
    While $Paused
        Sleep(500)
        ToolTip('Script is "Paused"', 0, 0)
    WEnd
    ToolTip("")
EndFunc   ;==>TogglePause

Func Terminate()
    Exit 0
EndFunc   ;==>Terminate

Func ShowMessage()
    MsgBox(4096, "", "www.twiender.tk.")
EndFunc   ;==>ShowMessage
Edited by NeverDUN
Link to comment
Share on other sites

Can anyone help out a lil more here? I'm new to autoit but i got the basics.. i think..

the easy way is using the _IE functions... the hard way is using maths and brain :D

use porcents... if your res is 1240*800 and if you want to start the search on 620*400 the middle it´s the 50 porcent... so

pixelsearch((@DesktopWidth*100)/50,(@DesktopHeight*100)/50,@DesktopWidth,@DesktopHeight,$yourcolor)

let see your script....

i guess your resolution is 1680x1050(thats mine) and you start your search on 485x228

so appling maths :unsure:

1680 ----- 100%

485 ------ x = 485 * 100 / 1680

grab the calculator

so x = 28,86% let say 29%

the same with height

228 * 100 / 1050 = 21,71 sooo = 22% :>

ok

so instead of this

$coord = PixelSearch(485, 228, @DesktopWidth, @DesktopHeight, 0xECEEF5)

use this

$startpointx = (@desktopwidth/100) * 29
$startpointy = (@desktopheight/100) * 22
$coord = PixelSearch($startpointx, $startpointy, @DesktopWidth, @DesktopHeight, 0xECEEF5)

this will work to all resolutions ;) welcome to my world :S

My advice learn from the help and the forum about _IE Functions, they do everything without open the browser if you want... i still don´t learn it but soon... i hope you understand what i say upthere

Edited by monoscout999
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...