Sign in to follow this  
Followers 0
Tasmania

+= errors out sometimes...

7 posts in this topic

This is the code it errors out on:

$pos = WinGetPos("Notes")
 
$pos[1] += 25
$pos[3] -= 25

Share this post


Link to post
Share on other sites



Pretty sure that the Window title isn't found... try:

$pos = WinGetPos("Notes")
If Not @error Then
    $pos[1] += 25
    $pos[3] -= 25
Else
    MsgBox(0,"error", "Window not found")
EndIf

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Yep, it's saying the window isn't found... hmmm, that's interesting...

Edit: Easy to fix, I'll just add in a window wait, but still... that's very interesting that it works sometimes and not others... lol...

Thanks :)

Edited by Tasmania

Share this post


Link to post
Share on other sites

Acutally, it's not surprising. Sometimes the window gets the ticks it needs to come up before your script progresses, sometimes your script gets the ticks to error out before the window comes up.

I run into this all the time. A good mix of soft and/or hard waits will keep everything running smoothly.


Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites

Acutally, it's not surprising. Sometimes the window gets the ticks it needs to come up before your script progresses, sometimes your script gets the ticks to error out before the window comes up.

I run into this all the time. A good mix of soft and/or hard waits will keep everything running smoothly.

In other-words, a scripting application may run two times faster than an application that needs to download data from a database... which is what I've noticed... is this an accurate restatement?

Share this post


Link to post
Share on other sites

This is a classic case (deomonstrated by Jdeb) of proper error handling preventing nasty situations.

We know that WinGetPos returns an Array if successful or an @error if failed.

Why would we (knowing that there is a possibility of failure) not do proper error handling ahead of time?

(Notice I'm using a handle here... I try to stay away from titles if and when possible)

$aPos = WinGetPos($hWnd)
If @error = 0 Then
    ;EtcoÝ÷ ØêÚºÚ"µÍÌÍØTÜÈHÚ[Ù]ÜÊ ÌÍÚÛ
BYÐ^J  ÌÍØTÜÊH[Ñ]
I generally use the IsArray() one because I'm thinking array here... but I'm sure @error would be much faster if speed was an issue.

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

This is true... I will attempt to program more error handling in the future as I program instead of after the fact. It is probable that this will prevent many headaches.

Thanks for the advice :)

Share this post


Link to post
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
Sign in to follow this  
Followers 0