Jump to content

WinMove from PID


 Share

Recommended Posts

15 hours ago, Nine said:

@kjpolker

Global $aPos
Global $x1, $y1, $x2, $y2

Why creating those variables as Global, doesn't seem to be required. They should have been declared Local instead. In general, try to avoid declaring Global inside functions, it makes programs hard to read and maintain.  If needed, declare the Global vars at the top of the script, this is a good programming practice.

If ubound($aWinList)- 1=2 Then

This is not a very elegant programming usage.  Since WinList returns the number of found windows, you should have use :

If $aWinList[0][0] = 2 Then

 But maybe I am too picky :)

I appreciate the feedback! All of that makes sense to me. I usually only declare locals in functions and globals at the top of script but I was so involved with getting the thing to work I slopped it together from the comments here 😂

Edited by kjpolker
Link to comment
Share on other sites

On 1/19/2020 at 6:35 AM, Musashi said:

AutoIt only uses "zero(0)-based indexing" for arrays !

==> Variant 1 : [Index=0] -> Count ; [Index=1] -> Element_1 , [Index=2] -> Element_2 ...

==> Variant 2 : [Index=0] -> Element_1 ; [Index=1] -> Element_2 , [Index=2] -> Element_3 ...

The fact, that in Variant 1 the Index=1 contains the first 'real' element does not make it a "one(1)- based array".

I hope I'm not writing nonsense now. Apparently 80% of my brain cells are still fighting the beers from yesterday's party :lol:.

I understand completely and the only reason I'm bothering to reply is to show where I'm getting my reasoning.  In the help file, stringsplit() makes a remark about a flag that sets no count "effectively makes the array zero based"  so this leads me to believe that without the no count flag that its returning "what is effectively " a 1 based array.  Getting technical yes all arrays start at 0 but when you're talking about the relevant data contained in the array it starts at one.  This is kinda a hair splitting tomato tamato scenario.   I was just trying to keep my response as simple as possible.  I just hate to have it appear like I'm just pulling stuff from you know where.

Screenshot_20200124-114938_Samsung Internet.jpg

Link to comment
Share on other sites

1 hour ago, markyrocks said:

so this leads me to believe that without the no count flag that its returning "what is effectively " a 1 based array.

You misled yourself. The array returned without the no count flag set is still zero based, it just contains the count in the zero element and the data starts at one and goes up from there. With the no count flag set, the data starts at zero with no count in zero.

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

1 hour ago, BrewManNH said:

You misled yourself. The array returned without the no count flag set is still zero based, it just contains the count in the zero element and the data starts at one and goes up from there. With the no count flag set, the data starts at zero with no count in zero.

I understand this completely.   However the description of the splitstring function is explicitly stating that using the no count flag is transitioning from a state that is not zero based to a state that is.   If in the opinion of the author this wasn't the case it would be pointless to mention it at all.  I didn't mislead myself,  I was misled by the author of the help file.  Maybe it was a mistake on their part,  maybe me and the author agree on the definition of the array base being relevant data to a shuffle.   Hence in a sort through the array youd never start at zero if you know it's the count.  So again I understand completely that the array still starts at zero, but the relevant data starts at 1.  Yes the count is important but most people are so used to using ubound it might as well not even exist.   As I previously stated I only posted the above to show where I was getting my info.  I don't really want to argue about it bc its semantics.   If you want your hardcore literal definition of the term that's fine but I'll keep my fluid definition.   

 

Link to comment
Share on other sites

@markyrocks :

Regardless of the other things you've written :

Concerning the phrase "effectively makes the array 0- based" in the help, I partly agree with you. Some users might deduce that there are also 1-based arrays in AutoIt, which would be a false conclusion.

3 hours ago, markyrocks said:

Getting technical yes all arrays start at 0 but when you're talking about the relevant data contained in the array it starts at one.  This is kinda a hair splitting tomato tamato scenario.

Definitely No ;)!

This is not about hairsplitting, but about the main problem that many users (especially beginners) have with 0-based arrays in AutoIt. The majority of help requests refer to the error : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

21 hours ago, markyrocks said:

However the description of the splitstring function is explicitly stating that using the no count flag is transitioning from a state that is not zero based to a state that is.   

Effectively

You need to learn what the word means before denigrating the description.

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

On 1/25/2020 at 12:51 PM, BrewManNH said:

Effectively

You need to learn what the word means before denigrating the description.

Explain exactly how something can "effectively " be something if in your opinion it is that thing already?  But thanks for talking down to me.  

 

@Musashi I totally feel you but I don't see how describing an array as 1 based adds to confusion if the array is used like..

For $x=1 to $array[0][0]
    Next
    ;or 
    For $x=1 to ubound($array)-1
    Next

What would be a better description of an array that the relevant data starts at one?  Is it easier to explain to a noob that the count is element 0 or that the array starts at 1.  I realize array math is difficult regardless but we wouldn't even be having this conversation if the op had read and understood the help file in the first place.   I find it much easier for a noob to be confused by a count being at zero and then doing something like..

For $x=0 to ubound($array)-1
    Next

Obviously in that scenario that op might assume that the first window is $array[0][0] and the first hwd was [0][1]. Then not understand why it's not working correctly.  Regardless none of these scenarios result in out of bounds bc an array dimmed [$x][1] would still have a [0][1] whether it was empty or not. Probably further adding to confusion bc there isn't an error but the expected outcome is just not coming to fruition. 

Edited by markyrocks
Link to comment
Share on other sites

2 hours ago, markyrocks said:

Is it easier to explain to a noob that the count is element 0 or that the array starts at 1

I agree with you to a certain extent, that for people outside the mathematical/programming world, base 1 is probably the natural way of counting. If I asked my mother to number 10 boxes, she would use as values 1..10 but never 0..9 ;).

BTW : Here is a comparison of some languages regarding arrays.
https://en.wikipedia.org/wiki/Comparison_of_programming_languages_(array)#cite_ref-cr17_14-0

What remains is the fact that AutoIt only uses 0-based arrays. There are no 1-based arrays here, which are transformed to 0-based arrays by NO_COUNT, for example. Do not blame me for this and also not for the possibly missleading formulation in the help 😛.

Furthermore : Please do not let us have an endless discussion of fundamentals and backgrounds. Thousands of contributions have already been made to this topic.

If you are interested, here is a small selection :

Why are zero-based arrays the norm?
https://softwareengineering.stackexchange.com/questions/110804/why-are-zero-based-arrays-the-norm

Edsger W. Dijkstra's article "Why numbering should start at zero".
http://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

Im not arguing for or against one or the other. Or the pros and cons ect.  I don't blame you or anyone else for anything.   I was just stating where I got the information from.   I actually did read up on the subject a bit over the weekend.   Its about as interesting as watching grass grow.   The reality is I said something,  someone called me out.  I explained my piece.   I showed where I got my info.  Bc everytime if someone says something that is "incorrect" in this forum people try to make you look like some kinda clown.   So whether you agree or disagree I'm referring to a section of the help file.   I'm not just making stuff up.  

If I was to put a finger on what I'm arguing for its trying to easily describe the behavior of an array in this scenario without going into a ton of detail to avoid confusion.  That's it end of the story.   

Link to comment
Share on other sites

1 hour ago, markyrocks said:

Because everytime if someone says something that is "incorrect" in this forum people try to make you look like some kinda clown.

Excuse the vulgarity of the word, but this is just bullshit. I see lots of questions, that could be solved with a quick glance into the help itself. Nevertheless, there are many helpers in the forum who answer these questions with stoical patience, often even with ready-to-use scripts.

BTT :

* I agreed, that the phrase in the help you refer to could be misleading

* I partly agreed, that 0-based arrays do not necessarily correspond to 'normal' counting behaviour

* I have provided links that explain the background of n-based arrays (you may consider them boring or unnecessary, but other users may not)

With not a single word I made you look like a clown. And this is the end of my story (in this thread).

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

2 minutes ago, Musashi said:

Excuse the vulgarity of the word, but this is just bullshit. I see lots of questions, that could be solved with a quick glance into the help itself. Nevertheless, there are many helpers in the forum who answer these questions with stoical patience, often even with ready-to-use scripts.

BTT :

* I agreed, that the phrase in the help you refer to could be misleading

* I partly agreed, that 0-based arrays do not necessarily correspond to 'normal' counting behaviour

* I have provided links that explain the background of n-based arrays (you may consider them boring or unnecessary, but other users may not)

With not a single word I made you look like a clown. And this is the end of my story (in this thread).

I did not say you did.  But I was responded to with "you misled yourself " and a claim that I didn't understand the definition of a word... these are both degrading statements.   Not everything is about you.  Coming at me with vulgarity doesn't exactly scream non hostile.  I will agree that there are many patient members here .  Maybe I should refrase.  If you say something "incorrect " certain people will try to make you look like a clown.  Theres always one or 2 in the crowd I guess.  Gawd here we are back to splitting hairs.   The English language isn't like coding there's such a thing as reading between the lines.   Not everything said is so literal.  I mean seriously, did you think that I was referring to every person?  Get real. 

Link to comment
Share on other sites

3 hours ago, markyrocks said:

But I was responded to with "you misled yourself " and a claim that I didn't understand the definition of a word..

Was either of those mischaracterizations?

You said you lead yourself to believe something that was wrong, so you mislead yourself.

Second, you seemed to not understand the meaning of effectively, the meaning of is "in such a manner as to achieve a desired result.", or "in effect". Which means to me that the array data is starting at zero rather than at 1 effectively.

That's all, nothing more. 

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

3 hours ago, BrewManNH said:

Was either of those mischaracterizations?

You said you lead yourself to believe something that was wrong, so you mislead yourself.

Second, you seemed to not understand the meaning of effectively, the meaning of is "in such a manner as to achieve a desired result.", or "in effect". Which means to me that the array data is starting at zero rather than at 1 effectively.

That's all, nothing more. 

yes they are both mischaracterizations...like i said if i was misled by anything it was by the help file... and again what sense does it make to describe something that is "effectively" as itself?  If i hit a nail with a pipe the pipe is effectively a hammer.  If i hit a nail with a hammer its not effectively a hammer...its just a hammer....

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