Jump to content

WinGetClientSize WinGetPos weird info


SiY11
 Share

Recommended Posts

When I use the Window Info tool, the info is all correct but when I use WinGetClientSize and WinGetPos in the script I get zeros for the arrays. To be clear I do not get errors, the AutoIT script thinks the arrays are all zero. Is there something I should be adding? I have tried to use handles and get the same result.

I was thinking this might be the fault of the running program I am trying to pull info from but when I saw the Info tool grabs this info correctly I am led to believe either I am leaving something out or, I do not know something.

Just to get this out of the way.

While looking up the many other problems I had during my learning process (new to programming altogether.) I have noticed this community LOVES to hate on newcomers with simple questions, please note I have spent a large amount of time on the Help file, Google, These forums, and looking in others scripts. If your search skills are better than mine please just offer the link thank you. Needless to say I am a little scared to post this. 

Edited by SiY11
Link to comment
Share on other sites

You left out the code you're using and the program/window you're trying to read from.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Sorry I assumed I would not need to as I was thinking this was straight forward and I was stuck due to my limited knowledge.

;=====Included programs and files=====;
    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    ;#include <FastFind.au3>
    #InstallKeybdHook

;=====Included programs and files=====;

;=====Options=====;
    Opt("MouseCoordMode", 2) ; relative coord to the active windows
    Opt("PixelCoordMode", 2) ; relative coord to the active windows
    Opt("WinTitleMatchMode", 2) ; Match any substring in the title

;=====Options=====;

$is_running = true

;=====Gui=====;
    #Region ### START Koda GUI section ### Form=
        $Form1 = GUICreate("Form1", 265, 211, 368, 499)
        $ButtonExit = GUICtrlCreateButton("Exit", 96, 96, 75, 25)
        ;$Label1 = GUICtrlCreateLabel("", 0, 0, 265, 4)
        ;$Input1 = GUICtrlCreateInput("", 8, 8, 161, 21)
        GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

;=====Gui=====;

;=====Main program body=====;
While $is_running

    ; Check the title of Skype
        Local $Skypetitle = WinGetTitle("[class:tSkMainForm]")
            MsgBox(0, "Full title read was:", $Skypetitle)



    ; Check the Handle of Skype
        Local $Skypehandle = WinGetHandle("[Class:tSkMainForm]", $Skypetitle)
            ;If @error Then
                ;MsgBox(4096, "Error", "Could not find the correct window Handle")
            ;EndIf


    ; Check if Skype is the active window
        Local $IsSkypeActive = WinActive("[Class:tSkMainForm]", $Skypehandle)

    ; Activates the Skype window
        WinActivate($Skypehandle)



    ; Checks what resolution Skype is set to
        Local $Skyperesolution = WinGetClientSize("[Class:tSkMainForm]", $Skypehandle)
            MsgBox(0, "Current Skype Resolution", $Skyperesolution &"x"& $Skyperesolution)

        Local $size = WinGetPos("[Class:tSkMainForm]", $Skypehandle)
            MsgBox(0, "Active window stats (x,y,width,height):", $size & "X x Y" & $size & "   " & $size & "W x H" & $size)


;=====Main program body=====;

;=====Hotkeys=====;

;=====Hotkeys=====;




;=====Gui Extended (button actions)=====;
$nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $ButtonExit
            Exit
    EndSwitch

;=====Gui Extended (button actions)=====;


WEnd


;=====Functions Defined=====;


Func offline() ;needs var
    Local $i = 0
        Do
            Local $coord = PixelSearch (281, 35, 1585, 755, 0xD719C7, 25, 0, $Skypehandle )
                If Not @error Then
                    Sleep ( 0 )
                        MouseClick( "left", $coord[0], $coord[1], 1, 0 )
                    Sleep (30)
                EndIf
    $i = $i + 1
        Until $i =10
EndFunc


Func LClick() ;needs var
    Local $i = 0
        Do
            Sleep ( 300 )
                MouseClick( "left" )
                MouseClick( "left" )
            Sleep (300)
    $i = $i + 1
        Until $i =2
EndFunc

;=====Functions Defined=====;
Edited by SiY11
Link to comment
Share on other sites

  • Moderators

SiY11,

Welcome to the AutoIt forum. :)

Having read this in your initial post:

I have noticed this community LOVES to hate on newcomers with simple questions

I am not at all surprised that:

I am a little scared to post this

I take the first of those comments as a personal insult, as well as one to the community in general - I make a point of welcoming new users to the forum and helping them with their problems, be they simple or more complex. But you have perhaps heard of the old saying: "Give a man a fish, you feed him for a day; give a man a net and you feed him forever" - we try to be net makers and repairers, not fishmongers, and so we do not give free rides to those who appear to have made no effort themselves. In your case you have a script and are asking a relatively simple question - the fact that you received such curt replies is quite probably due to the first of the quotes posted above. Despite this, you have now been told the problem with your script - in case jaberwocky6669's reply is not entirely clear, I suggest that you check in the Help files for the datatype returned by the 2 functions you use and then read the Arrays tutorial in the Wiki, particularly the "Accessing Data in Arrays" section. ;)

I trust that you are no longer "scared" (although perhaps a little embarrassed) and that you now understand why you do not see the values in your MsgBoxes. If you do still have problems then please post again and we shall try to explain in more detail. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

MsgBox(0, "Current Skype Resolution", $Skyperesolution[0] &"x"& $Skyperesolution[1])

 

I had tried that with the element arrays the first time and receive the error - "Subscript used with non-Array variable." If I remove element arrays I get the 0x0.

SiY11,

Welcome to the AutoIt forum. :)

Having read this in your initial post:

I am not at all surprised that:

I take the first of those comments as a personal insult, as well as one to the community in general - I make a point of welcoming new users to the forum and helping them with their problems, be they simple or more complex. But you have perhaps heard of the old saying: "Give a man a fish, you feed him for a day; give a man a net and you feed him forever" - we try to be net makers and repairers, not fishmongers, and so we do not give free rides to those who appear to have made no effort themselves. In your case you have a script and are asking a relatively simple question - the fact that you received such curt replies is quite probably due to the first of the quotes posted above. Despite this, you have now been told the problem with your script - in case jaberwocky6669's reply is not entirely clear, I suggest that you check in the Help files for the datatype returned by the 2 functions you use and then read the Arrays tutorial in the Wiki, particularly the "Accessing Data in Arrays" section. ;)

I trust that you are no longer "scared" (although perhaps a little embarrassed) and that you now understand why you do not see the values in your MsgBoxes. If you do still have problems then please post again and we shall try to explain in more detail. :)

M23

 

Sorry you take my comment as a personal insult, maybe you can show me I was wrong but this community has a bad reputation for being very elitist, from my perspective and outside communities.

I love the net analogy  and agree with it. I hope to never fall in the habit of looking for free rids as I do desire to learn.

I do not feel anyone was curt/rude. I think jaberwocky6669's reply was fine although it did not solve my problem. Ofcourse I did not make it clear I had tried with the element arrays attached as outlined in the help page for WinGetClientSize, sorry about that. With your direction to datatypes and Accessing Data in Arrays I feel I should be on the right track to discovering the answer to my problem.

I am still a bit shy and I presume I will be for sometime while I learn the social norms of this community and adapt to the proper standards of communication. I do not believe embarrassment will ever come into play as ignorance is never something to be ashamed of. 

TL:DR-

Thanks!

Edited by SiY11
Link to comment
Share on other sites

I figured it out!

It was the way I called the the window

Before:

Local $Skyperesolution = WinGetClientSize("[Class:tSkMainForm]", $Skypehandle)

After:

Local $Skyperesolution = WinGetClientSize($Skypehandle)

Complete code snip:

; Checks what resolution Skype is set to
        Local $Skyperesolution = WinGetClientSize($Skypehandle)
            MsgBox(0, "Current Skype Resolution", $Skyperesolution[0] &"x"& $Skyperesolution[1])

I started my programming class today and we are using Python. Funny, today was about variables, numbers vs floats, strings, and datatypes ;)

I would like to say I love Python and AutoIt!

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