Jump to content

Retrieve Width and Height of a window and ControlClick - (Moved)


Recommended Posts

I want to do as the title similar to

Opt("WinTitleMatchMode", 2) 


if ProcessExists("notepad.exe") Then
    winactivate("notepad")
    MouseClick("left", @DesktopWidth / 2, @DesktopHeight / 2) ;notepad instead of desktop and divide width and height by 2

 

Any examples would be great!

Link to comment
Share on other sites

  • Developers

Moved to the appropriate forum, as the Developer General Discussion forum very clearly states:

Quote

General development and scripting discussions. If it's super geeky and you don't know where to put it - it's probably here.


Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums.

Moderation Team

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

3 hours ago, iuc73663 said:

Not sure if this is what you are looking for, but I would approach this as follows: 

-Find where you want to move the window

-Calculate the size you want to window to be

-Resize window to that size

-Move window using this function: https://www.autoitscript.com/autoit3/docs/functions/WinMove.htm

 

Hope it helps.

 

Show me where I said I wanted to move or resize any window? pls stop spam

Link to comment
Share on other sites

$bSetupFakeWindows = True
If $bSetupFakeWindows Then
    For $i = 0 To 4
        Run("notepad.exe")
    Next
    Sleep(1000)
    $aWin = WinList("[CLASS:Notepad]")
    For $i = 1 To UBound($aWin)-1
        $xRandom = Random(1,800,1)
        $yRandom = Random(1,800,1)
        $hRandom = Random(200,500)
        $wRandom = Random(200,500)
        WinMove($aWin[$i][1],"",$xRandom,$yRandom,$wRandom,$hRandom)
    Next
EndIf

$aWin = WinList("[CLASS:Notepad]")
For $i = 1 To UBound($aWin)-1
    WinActivate($aWin[$i][1])
    $hControl = ControlGetHandle($aWin[$i][1],"",15)
    $aControl = ControlGetPos($aWin[$i][1],"",$hControl)
    ControlClick($aWin[$i][1],"",$hControl,"left",1,$aControl[2]/2,$aControl[3]/2)
Next

 

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

3 hours ago, jdelaney said:
$bSetupFakeWindows = True
If $bSetupFakeWindows Then
    For $i = 0 To 4
        Run("notepad.exe")
    Next
    Sleep(1000)
    $aWin = WinList("[CLASS:Notepad]")
    For $i = 1 To UBound($aWin)-1
        $xRandom = Random(1,800,1)
        $yRandom = Random(1,800,1)
        $hRandom = Random(200,500)
        $wRandom = Random(200,500)
        WinMove($aWin[$i][1],"",$xRandom,$yRandom,$wRandom,$hRandom)
    Next
EndIf

$aWin = WinList("[CLASS:Notepad]")
For $i = 1 To UBound($aWin)-1
    WinActivate($aWin[$i][1])
    $hControl = ControlGetHandle($aWin[$i][1],"",15)
    $aControl = ControlGetPos($aWin[$i][1],"",$hControl)
    ControlClick($aWin[$i][1],"",$hControl,"left",1,$aControl[2]/2,$aControl[3]/2)
Next

 

that opens notepad and moves from the windows default location as "Random"

Link to comment
Share on other sites

@AllEyezOnMe

Maybe WinGetClientSize() would help you on what you are trying to do.

EDIT:

Reading carefully, you better use Control* functions to click something on your script, but we need more than "Notepad", since that's a window, and not a control's name :)

Edited by FrancescoDiMuro

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

6 hours ago, AllEyezOnMe said:

that opens notepad and moves from the windows default location as "Random"

...and then dymamically clicks the center of each randomly sized and placed window based on the control size.  How can you have missed the control* functions

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
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...