Jump to content

Various AutoIT annoying stuff that doesn't make sense: Variable used without being declared


Recommended Posts

Maybe i'm getting old maybe i'm getting picky maybe i'm used to high level language but,

After years and years of sporadically returning to autoit and building experience as senior dev  I find that autoit has some huge gaps that crook it and make it frustrating and unusable.

As for what made me do this post, here you go:

I needed to do some quick tool to capture pixel coords, pixel checksum and stuff for automation activities and Au3Info basically sucks (and also does not help capturing advanced windows in various programs). So the source, since it always gets asked is:
 

#include <MsgBoxConstants.au3>

Opt("PixelCoordMode", 1)
Opt("MouseCoordMode", 1)

Global $coordinates[2][2] = [[0, 0], [0, 0]] ; Store 2 points (x, y)
Global $count = 0
Global $keepRunning = True

HotKeySet('!q', '_RecordCoordAndChecksum')
HotKeySet('!d', '_DelayedRecordCoordAndChecksum')

HotKeySet('!a', '_CopyCoord')
HotKeySet('!p', '_Exit')

While $keepRunning
    Sleep(100)
WEnd

#for web areas with Hover pseudoclasses so you can move mouse out
Func _DelayedRecordCoordAndChecksum()
    _RecordCoordAndChecksum(3000)
EndFunc

Func _RecordCoordAndChecksum($delay = 10)
    If $count < 2 Then
        Local $pos = MouseGetPosition()
        $coordinates[$count][0] = $pos[0]
        $coordinates[$count][1] = $pos[1]
        $count += 1
    EndIf

    If $count == 2 Then
        Sleep($delay)
        Local $checksum = PixelChecksum($coordinates[0][0], $coordinates[0][1], $coordinates[1][0], $coordinates[1][1])
        Local $finalResult = $coordinates[0][0] & "," & $coordinates[0][1] & "," & $coordinates[1][0] & "," & $coordinates[1][1] & "," & $checksum
        MsgBox($MB_SYSTEMMODAL, "Checksum Generated", "Coordinates and Checksum: " & $finalResult)
        ClipPut($finalResult)
        $count = 0
        _ResetArray()
    EndIf
EndFunc

Func _Exit()
    $keepRunning = False
EndFunc

Func _ResetArray()
    For $i = 0 To 1
        $coordinates[$i][0] = 0
        $coordinates[$i][1] = 0
    Next
EndFunc

Func MouseGetPosition()
    Return MouseGetPos()
EndFunc

Func _CopyCoord()
    $finalResult = MouseGetPos()
    MsgBox($MB_SYSTEMMODAL, "Coords" , $finalResult[0] & "," & $finalResult[1])
    ClipPut($finalResult[0] & "," & $finalResult[1])
EndFunc



Beside the fact that you usually have to move half of the stuff in Global vars else you get a shit ton of errors and all becomes much more complicated, this particular script says when you double press ALT+Q
 

Quote

+>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+BREAK to Stop.
"D:\pixelchecksumfinder.au3" (34) : ==> Variable used without being declared.:
Sleep($delay)
Sleep(^ ERROR
->02:15:42 AutoIt3.exe ended.rc:1
+>02:15:42 AutoIt3Wrapper Finished.


Well, it doesn't make any F... sense

I have 

Func _RecordCoordAndChecksum($delay = 10)

so it's absolutely defined and initialized.
Also when calling:
_DelayedRecordCoordAndChecksum


I get the same stuff even though i pass:
 

_RecordCoordAndChecksum(3000)


Not even GPT is able to identify any issue (I always avoid to pester the help forum if possible)
That said the whole language is unreliable and randomly fails repeating the same task because of.... reasons? who the hell knows, it just skips a beat doing what it's programmed to do

Also tried to automate something on chrome and it doesn't send the hotkeys
Also whenever you handle files any file with a dot (.) in the name makes AutoIT go apeshit
Also any resolution change makes autoit useless

And so on, I could keep going. The more I use it as an advanced user the more I lose faith in it even though I was a big fan of it

Edited by Newb

I'm a compulsive poster. When I post something, come to read it at least 5 minutes later after the posting, because I will edit it. I edited even this signature a few minutes later after I wrote it.

Link to comment
Share on other sites

Posted (edited)
2 minutes ago, pixelsearch said:

AutoIt help file, function HotKeySet :
"The called function can not be given parameters. They will be ignored"

I think this should be on the first line of the remarks and not the last lol.
Beside this, the real problem is that the error message returned is sneaky, unclear and misleading to use an euphemism.

Edited by Newb

I'm a compulsive poster. When I post something, come to read it at least 5 minutes later after the posting, because I will edit it. I edited even this signature a few minutes later after I wrote it.

Link to comment
Share on other sites

2 minutes ago, pixelsearch said:

I just found this thread a few seconds ago, it seems interesting, maybe it could help you.

Good luck :)

Thanks, no need, it's just the nth stupid utility script, no need to build a workaround over it, i'ìll just do the autoit standard way, adding the nth global var on top of the script, lmao

I'm a compulsive poster. When I post something, come to read it at least 5 minutes later after the posting, because I will edit it. I edited even this signature a few minutes later after I wrote it.

Link to comment
Share on other sites

Posted (edited)
21 minutes ago, pixelsearch said:

I just found this thread a few seconds ago, it seems interesting, maybe it could help you.

Good luck :)

Moreover, after further trying and thinking, this makes even less sense.

Calling the _DelayedRecordCoordAndChecksum works (as expected since it calls the function separately and not from a hotkey)
Calling it from HotKeySet('!q', '_RecordCoordAndChecksum') calls _RecordCoordAndChecksum($delay = 10) and $delay is already defined, I don't get why it says "Variable used without being declared" since it has a default value and it's exactly there in the Func signature.
Though, removing the default value says it gets called without enough params.
This means the function is called by HotkeySet without params but the function should run anyway since it has a default value!!!!
This doesn't make any sense as calling from HotkeySet should be the same as calling a function with default parameters without passing the parameter, thus letting the function use the default param value

Edited by Newb

I'm a compulsive poster. When I post something, come to read it at least 5 minutes later after the posting, because I will edit it. I edited even this signature a few minutes later after I wrote it.

Link to comment
Share on other sites

  • Developers
Posted (edited)
10 hours ago, Newb said:

Well, it doesn't make any F... sense

It does make sense....

10 hours ago, Newb said:

Not even GPT is able to identify any issue (I always avoid to pester the help forum if possible)
That said the whole language is unreliable and randomly fails repeating the same task because of.... reasons? who the hell knows, it just skips a beat doing what it's programmed to do

Maybe go for another option then instead of pestering us anyway with your frustrations? 

--- stopped reading there as this thread is just venting of somebody that doesn't what to think .....

*CLICK*  

 

 

Edited by Jos

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

  • Jos locked this topic
Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...