Jump to content

Functions and guis


Recommended Posts

I've divided my script into several functions for a better overview. Here is a basic overview of the script:

Init()
MainGUI()
Processing()
Exit

Func Init()
  ;some code
EndFunc

Func MainGUI()
  ;some code
  ;a gui
   GuiWaitClose()
   If GuiRead() = $buttonConfig Then Config()
EndFunc

Func Processing()
  ;Some Code
EndFunc

Func Config()
  ;a gui with a while loop and exitloop
   GuiDelete()
   MainGUI(); to rerun the func MainGUI
EndFunc

A click on the config button in the main gui calls the function Config with the config gui. Closing the config gui returns to the function MainGUI. At the moment I'm just calling the function MainGUI at the end of the config function. It seems to work fine but I would like to know if there is a better way to do this.

Regards,Peter Bonge

Link to comment
Share on other sites

I've divided my script into several functions for a better overview. Here is a basic overview of the script:

Init()
MainGUI()
Processing()
Exit

Func Init()
  ;some code
EndFunc

Func MainGUI()
  ;some code
  ;a gui
   GuiWaitClose()
   If GuiRead() = $buttonConfig Then Config()
EndFunc

Func Processing()
  ;Some Code
EndFunc

Func Config()
  ;a gui with a while loop and exitloop
   GuiDelete()
   MainGUI(); to rerun the func MainGUI
EndFunc

A click on the config button in the main gui calls the function Config with the config gui. Closing the config gui returns to the function MainGUI. At the moment I'm just calling the function MainGUI at the end of the config function. It seems to work fine but I would like to know if there is a better way to do this.

I don't what bother you. Your code is fine.

Perhaps depending you are doing in config you don't need to delete the gui and recreate it but you will see what really need to update in the config function.

Go :D

Link to comment
Share on other sites

I don't know if I should post the whole code. It has more than 250 lines and there are a lot of german strings. And there are some more files which are needed by the script (icons, textfiles)...

I've had some doubts because of this post. I don't know if I have also "a flow issue in your logic"...

Perhaps depending you are doing in config you don't need to delete the gui and recreate it but you will see what really need to update in the config function.

I thought I've read elsewhere that only one gui at the same time is possible, isn't it? Nevertheless it is not really necessary that both guis are open at the same time.

By the way: It is a (german) tool to copy images from a digital camera to a dated folder on the harddisk.

And now I go to bed...

Regards,Peter Bonge

Link to comment
Share on other sites

  • Developers

I don't know if I should post the whole code. It has more than 250 lines and there are a lot of german strings. And there are some more files which are needed by the script (icons, textfiles)...

I've had some doubts because of this post. I don't know if I have also "a flow issue in your logic"...

I thought I've read elsewhere that only one gui at the same time is possible, isn't it? Nevertheless it is not really necessary that both guis are open at the same time.

By the way: It is a (german) tool to copy images from a digital camera to a dated folder on the harddisk.

And now I go to bed...

I will have a look for you .... just mail or PM it to me.....

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

I don't know if I should post the whole code. It has more than 250 lines and there are a lot of german strings. And there are some more files which are needed by the script (icons, textfiles)...

I've had some doubts because of this post. I don't know if I have also "a flow issue in your logic"...

I thought I've read elsewhere that only one gui at the same time is possible, isn't it? Nevertheless it is not really necessary that both guis are open at the same time.

By the way: It is a (german) tool to copy images from a digital camera to a dated folder on the harddisk.

And now I go to bed...

You have no trouble in the reading perhaps I should clarify the Doc.

When I say only one Gui that means that you cannot have 2 gui running at the same time. but updating the same gui to change label hidden/disable control even add control is all a legal gui modification.

You cannot delete a previous define control just hidden it.

Good luck

Link to comment
Share on other sites

...you cannot have 2 gui running at the same time.

Only from the same instance of a script. If you really wanted, you could either call a 2nd script, or have the script call itself with a special paramater to launch a different GUI. Combining that with script communication by use of the AutoItWin[Get/Set]Title functions can make for some very powerful GUI manipulation.

Edited to change "function" to "script" (see my next post below)

Edited by pekster

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Link to comment
Share on other sites

Only from the same instance of a script. If you really wanted, you could either call a 2nd function, or have the script call itself with a special paramater to launch a different GUI. Combining that with script communication by use of the AutoItWin[Get/Set]Title functions can make for some very powerful GUI manipulation. That last idea is good. I will try that soon.

What do you mean by

you could either call a 2nd function

?

Can you give an example?

Link to comment
Share on other sites

In between I've put the script and all files temporary on my webspace:

httq://www...

The script is already translated. But the textfiles are still in German...

Edit: Now I've finished my tool/script (source code included):

httq://www...

Edit2: Sorry, but I'm going to remove that website because of another website...

Edited by peterbonge

Regards,Peter Bonge

Link to comment
Share on other sites

The script looks really clean.

One thing I noticed:

- There's no GuiShow in the main function

I don't understand how the GuiWaitClose works.

I never used it. The same for GuiDelete.

There's a delay if you click on Config.

I haven't worked with Guis that much. I bet people here can decrease that delay.

Link to comment
Share on other sites

The script looks really clean.

One thing I noticed:

- There's no GuiShow in the main function

I don't understand how the GuiWaitClose works.

I never used it. The same for GuiDelete.

There's a delay if you click on Config.

I haven't worked with Guis that much. I bet people here can decrease that delay.

@SlimShady, @peterbonge

I am very glad that peterbonge use GuiWaitClose because that the function I design for starting in the gui world.

-Define the gui

- wait closing

- process info set in the Gui

Just some precision the GuiShow is only needed when writing with GuiMsg(0) which allow to have Adlib/ HotKey working in parrallel with the Gui clicking. That's for me a super advanced way to code Gui. the AutoBuilder is generating this kind of sequence in case the user need to handle this Adlib/hotkey situation.

Again Congratulation @peterbonge for using the functions as I design them. :D

Link to comment
Share on other sites

Can you give an example?

Sorry, I didn't mean function. That should have read "2nd script" instead. You'd either need another seperate script, or you could call the same script again with a paramater, like this:

If $CmdLine[0] > 0 Then
  If $CmdLine[1] = "GUI run" Then
 ;do your 2nd GUI stuff, since this is now a 2nd instance
  EndIf
EndIf

;main body of script goes here

;to call your 2nd GUI, use:
Run(@ScriptFullPath & ' "GUI run"' & $other_paramaters)

Also note that you could do advanced stuff by passing more than the first paramater to the script and have it handled in the first 2 If statements.

Edited to fix my quotes

Edited by pekster

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Link to comment
Share on other sites

Guest Guest

@SlimShady and @jpm:

Thanx for all the flowers :D

I'm thinking of putting the main function into a while loop like in the other post I've mentioned in my previous post. But I don't know which solution is the better one. And if the while loop isn't better here: Why is it better in the other post? I'm a little bit confused...

Link to comment
Share on other sites

@SlimShady and @jpm:

Thanx for all the flowers  :D

I'm thinking of putting the main function into a while loop like in the other post I've mentioned in my previous post. But I don't know which solution is the better one. And if the while loop isn't better here: Why is it better in the other post? I'm a little bit confused...

You wonder what's "better"... Better for you or the CPU?

Do you want to make it respond faster to your actions?

Link to comment
Share on other sites

You wonder what's "better"... Better for you or the CPU?

Both ;-)

I know that loops are raising the CPU to 100%. Because of this I've put the sleep command into the loop of the config function.

I think the whole program would be slowed down if I would put the main function into a loop with a sleep command. If this is true it wouldn't be the better way. My solution is slow enough...

I thought that my solution is ok all the time. Just the other post is confusing me. There was a loop suggested as the better way and I still don't understand this.

Regards,Peter Bonge

Link to comment
Share on other sites

Sorry. I forgot to login. The previous post is from me...

As now Jon introduce an automatic delay in the GuiMsg(0) they are almost equivalent.

GuiMsg() will consume CPU when a click is done. GuiMsg(0) will poll to know if there is a message so will consume little CPU even if there is no click :D

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