AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Frustration....

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Traderhut



Joined: 05 Apr 2008
Posts: 11
Location: DFW

PostPosted: Sat Apr 05, 2008 8:25 pm    Post subject: Frustration.... Reply with quote

AHK has been really super cool, and REALLY super frustrating!

I've had strangeness with calling 'Foo ()' and having it ignore the whole line..
(Do you see the error in the above? I found it in under 2 HOURS)

I've tried to create Gui and put it in another file (because the GuiCreator likes to blow away the file and wipe out all my changes unless I tell it please, save my stuff...)

Right now, I'm trying to do a simple include, but it seems that the a new variable space is created by a include - no I'm not kidding, it appears to be a whole new module - not an include at all!

Putting code like:

Gui, Add, Edit, x-4 y160 w480 h220 vedLog, edLog
Gui, Add, Button, x366 y0 w80 h30 , Close
; Generated using SmartGUI Creator 4.0
Gui, Show, x131 y91 h379 w479, New GUI Window


In one file, and then doing:

ShowGui()
{

global ;

#include gui.ahk

GuiControl , edLog, "New log entry"
}

Bitches and moans because edLog isn't defined... Yeah, right.. Ok, so how can one create a GUI and update the thing as a script runs? Heck, how can one manage GUI at all, do I *really* need to define it in the script that I'm writing (over 500 lines, great target for GuiTrasher to wipe out.)


Sigh, this plus the flakey Image scanning code, and other fun stuff that just drives me nuts, makes me wonder if source code is available so I can track down some of these bugs and suggest fixes...

Frustrated in Dallas...

-Chert

PS: A lot of my frustration is due to 25 years as a Software engineer, and I'm use to working with a structured language that has a more advanced parser.
_________________
---

http://www.traderhut.com
Back to top
View user's profile Send private message
n-l-i-d
Guest





PostPosted: Sat Apr 05, 2008 8:55 pm    Post subject: Reply with quote

Ouch...

I think there are a few misunderstandings:

- If you want to seperate the GUI part and include it, you don't need a function, like in your example, simply include it where you want it in the file.

- The handlers of the GUI are created with subroutines, not functions, doublecheck in the manual.

It might be less frustrating for you if you first try to forget (I know that is not easy) your previous experience with coding, since AHK is nothing like other languages. Check and doublecheck the manual while coding, and if you encounter some inomalities/problems, post your code here, and there are plenty of people willing to help out.

PS: SmartGUI is not an IDE with automatic flawless insertion of changed code, it will break your script if you modify it inbetween. If you create your GUI with it, first finish it in SmartGUI, export the code, and than adapt the rest of your code.

HTH
Back to top
Traderhut



Joined: 05 Apr 2008
Posts: 11
Location: DFW

PostPosted: Sun Apr 06, 2008 2:06 am    Post subject: Figured out part... Reply with quote

The function 'GuiControl starts off with a phamtom argument... If you say:

GuiControl,Foo,Hi

It will complain that argument 1 (Foo) is invalid.

If you say:

GuiControl,,Foo,hi


It will complain that Argument 1 (Foo) is invalid.

If you do:

GuiControl ,Foo, hi

One (me) would expect that the GuiControl's first parameter is blank, but no, in this case it is Foo, you have to specify a leading ',' to get it to work..

This isn't the case for all commands, just some.... It drives me nuts...

I figured it out in the time between these e-mails, spending about 1 hour fighting with it, beating my hands on the desk, screaming at the keyboard, and pretty much wanting to pitch everything.... However, when I helped someone else fix their problem (they were similarly frustrated with their experience...) I happened to notice that his main problem was seeing ` and thinking it was ' and thus putting in 'n for a new line.

I still don't know how you write something that has a comma into a file...
Because the FileAppend call specifies the filename LAST, so if I have a var that has 'foo, bar' in it, won't it try to write 'foo' into bar if I do
FileAppend, %foo%, Filename.dat

If Foo := "foo,bar"?

The whole thing with some commands taking expressions, and some not, is major big time screwy... It's impossible to know for sure what you should expect in the output...


But, thanks for the suggestion....

-Chert
_________________
---

http://www.traderhut.com
Back to top
View user's profile Send private message
n-l-i-d
Guest





PostPosted: Sun Apr 06, 2008 11:09 am    Post subject: Reply with quote

The GuiControl syntax is as follows:

AHK Documentation wrote:
GuiControl, Sub-command, ControlID [, Param3]


Traderhut wrote:
GuiControl,Foo,Hi

It will complain that argument 1 (Foo) is invalid.


Argument 1 is supposed to be a sub-command, and since Foo is not a sub-command, it errors out.

Traderhut wrote:
GuiControl,,Foo,hi

It will complain that Argument 1 (Foo) is invalid.


Here the syntax is actually correct, but there is probably not a control with an ID "Foo", hence the error.

Traderhut wrote:
If you do:

GuiControl ,Foo, hi

One (me) would expect that the GuiControl's first parameter is blank, but no, in this case it is Foo, you have to specify a leading ',' to get it to work..


You found that one out yourself. This example is the same as your first example.

The commands in AHK are comma-delimited. If you need/want to only specify a part of a command, you will need to insert all comma's of the command, or else AHK cannot know what exact parameters you are trying to pass.

Traderhut wrote:
One (me) would expect that the GuiControl's first parameter is blank, but no, in this case it is Foo, you have to specify a leading ',' to get it to work..

This isn't the case for all commands, just some.... It drives me nuts...

I figured it out in the time between these e-mails, spending about 1 hour fighting with it, beating my hands on the desk, screaming at the keyboard, and pretty much wanting to pitch everything.... However, when I helped someone else fix their problem (they were similarly frustrated with their experience...) I happened to notice that his main problem was seeing ` and thinking it was ' and thus putting in 'n for a new line.


Escape character of AHK (accent/backtick)

AHK Documentation wrote:
AutoHotkey's default escape character is accent/backtick (`), which is at the upper left corner of most English keyboards. Using this character rather than backslash avoids the need for double blackslashes in file paths.

Since commas and percent signs have special meaning in the AutoHotkey language, use `, to specify a literal comma and `% to specify a literal percent sign.



Traderhut wrote:
I still don't know how you write something that has a comma into a file...
Because the FileAppend call specifies the filename LAST, so if I have a var that has 'foo, bar' in it, won't it try to write 'foo' into bar if I do
FileAppend, %foo%, Filename.dat

If Foo := "foo,bar"?


Code:
Foo := "foo,bar" ; assigns the complete string between quotes to variable Foo (expression)
FileAppend, %Foo%, Filename.dat


or

Code:
Foo = foo`,bar ; composes variable Foo from all text after the equal sign. The comma must be escaped (no expression)
FileAppend, %Foo%, Filename.dat


...and you could write this in numerous other variations too.

Traderhut wrote:
The whole thing with some commands taking expressions, and some not, is major big time screwy... It's impossible to know for sure what you should expect in the output...


It can be confusing, but if you assume that AHK was created for fast scripting: write as little as needed, and consult the documentation if in doubt, you should not have to get desperate.

Again: I think you are going too fast. You assume how the code could be based on your experience and expectations, then it doesn't give the expected result, you tweak the code again and again, and you get desperate... Razz

Tip: Go slow... consult the excellent documentation before you write your code. Save yourself from a heart attack: don't get mad, get even...

Wink

HTH
Back to top
Lexikos



Joined: 17 Oct 2006
Posts: 2589
Location: Australia, Qld

PostPosted: Sun Apr 06, 2008 12:05 pm    Post subject: Re: Frustration.... Reply with quote

Traderhut wrote:
I've had strangeness with calling 'Foo ()' and having it ignore the whole line..
AutoHotkey treats it as a function call only if '(' directly follows the function name. Spaces are not allowed. It is only strange if you assume AutoHotkey is like other languages.
Quote:
makes me wonder if source code is available so I can track down some of these bugs and suggest fixes...
AutoHotkey is open source. There is a "Source Code (C++)" link on the download page.
Quote:
If you say:

GuiControl,,Foo,hi


It will complain that Argument 1 (Foo) is invalid.
I cannot reproduce this. Are you sure? Rolling Eyes
Quote:
One (me) would expect that the GuiControl's first parameter is blank
This is explained in the tutorial:
the tutorial wrote:
Tip: You may have noticed from the other examples that the first comma of any command may be omitted (except when the first parameter is blank or the command is alone at the top of a continuation section).

Quote:
The whole thing with some commands taking expressions, and some not, is major big time screwy... It's impossible to know for sure what you should expect in the output...
If the documentation is not clear about what an argument accepts, post a suggestion in Suggestions on documentation improvements.

Generally, if the input of a command can only be numeric, it accepts expressions.
Expressions wrote:
An expression can be used in a parameter that does not directly support it (except an OutputVar or InputVar parameter such as those of StringLen) by preceding the expression with a percent sign and a space or tab.
Functions wrote:
The "% " prefix is also permitted in parameters that natively support expressions, but it is simply ignored.
Back to top
View user's profile Send private message
BoBo²
Guest





PostPosted: Sun Apr 06, 2008 12:26 pm    Post subject: Reply with quote

Quote:
I've had strangeness with calling 'Foo ()' and having it ignore the whole line..
(Do you see the error in the above? I found it in under 2 HOURS)
The space char?? But not to get a response from AutoHotkey.exe (the compiler) it needs to use #ErrorStdOut, but I might be wrong ... Shocked
Back to top
Traderhut



Joined: 05 Apr 2008
Posts: 11
Location: DFW

PostPosted: Sun Apr 06, 2008 8:47 pm    Post subject: Yeah, it's documented, but it still cost me 2 hours.. Reply with quote

BoBo² wrote:
Quote:
I've had strangeness with calling 'Foo ()' and having it ignore the whole line..
(Do you see the error in the above? I found it in under 2 HOURS)
The space char?? But not to get a response from AutoHotkey.exe (the compiler) it needs to use #ErrorStdOut, but I might be wrong ... Shocked


Yeah, and 20+ years of habit making the code look cleaner is hard to break. Some IDE's auto-put the space in for you.
I understand how this can make the parser easier...

Thanks for the source link, I'll down load it and see if I can see how it can fail doing an ImageSearch() (another post)

-Chert
_________________
---

http://www.traderhut.com
Back to top
View user's profile Send private message
Traderhut



Joined: 05 Apr 2008
Posts: 11
Location: DFW

PostPosted: Sun Apr 06, 2008 11:19 pm    Post subject: More Frustration.... Reply with quote

Lexikos wrote:
Traderhut wrote:
I've had strangeness with calling 'Foo ()' and having it ignore the whole line..
AutoHotkey treats it as a function call only if '(' directly follows the function name. Spaces are not allowed. It is only strange if you assume AutoHotkey is like other languages.
Quote:
makes me wonder if source code is available so I can track down some of these bugs and suggest fixes...
AutoHotkey is open source. There is a "Source Code (C++)" link on the download page.


Downloaded it, auto converted it to VS 2005...

32 warnings, 2 fatal errors...

Sigh...

Error 33 fatal error CVT1100: duplicate resource. type:MANIFEST, name:1, language:0x0409 CVTRES
Error 34 fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt AutoHotkey


Any suggestions?

I guess I can go track down a copy of VS 2003, and see if I can get it to compile there...

Of course, I can also look through the code and try to find the handler for the ImageSearch function... Which I'd have to do anyway, and see if I can find the bug...

-Chert
_________________
---

http://www.traderhut.com
Back to top
View user's profile Send private message
Traderhut



Joined: 05 Apr 2008
Posts: 11
Location: DFW

PostPosted: Mon Apr 07, 2008 12:19 am    Post subject: Sigh... My Fault 2.. Reply with quote

Greetings,

I just noticed two bugs.....

filename = "foo"
image := "c:\images\"
image := image . filename . ".gif"


Which created a filename of c:\images\"foo".gif

Bit by the := vs = syntax... for the who knows how many'th time...

And the other problem was that the image that I was working on was on the X: drive, and not on C: in the first place...

I shouldn't code when I'm sick and have a temp.... But I had the time now.. Smile

Thanks to all who helpped me along the path to enlightment....

-Chert
_________________
---

http://www.traderhut.com
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 2589
Location: Australia, Qld

PostPosted: Mon Apr 07, 2008 1:01 am    Post subject: Re: More Frustration.... Reply with quote

Traderhut wrote:
Any suggestions?
Read Compiling AutoHotkey (linked from the How to compile.txt file) or try my script.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group