Jump to content

Recommended Posts

Posted

Hi guys and gals,

I am not a programmer but a persistent hack,  I found AutoIt to be an intriguing solution to some of my frustration when trying to learn a little about programming.  I have hacked all kinds of scripts and to be able to script something and spit it out as an .exe without much trouble is awesome for someone like me.

Anyway I am trying to create a timer for a specific need.  The intervals change as time goes.  Well I succeeded in getting that far.  So now I am to the point where I am trying to add a few features to this timer.  I added a pause that works when you hit the pause/break key.  But I would like to pause when you click a button in the gui.  I would also like to back up and move forward though the stages of the timer.  So I added these buttons but have no clue how to make them work.  I can get buttons to work in example scripts but not my own script. :(

So I was wondering if anyone would be willing to help me get these buttons activated and working properly.  I get this far with my usual "hack"ing :) but now I need help.

Any tips to clean up my messy code would be useful too.  I am almost embarrassed to share the code as I am sure to a real programmer it is atrocious. Please realize this is truly a cut and paste hack and slash so be gentle.  It's how I learn.

 

 

HTCondTimer3.au3

Posted (edited)

Just a few things to start with.

The buttons wont fire as you have  GUIOnEventMode set to 1 but are checking for the button clicks in the while loop. Either remove the line or use GUIOnEventMode to set the function to be called when a control is clicked.

$idPause = GUICtrlCreateButton("Pause", 175, 80, 70, 25)
GUICtrlSetOnEvent(-1, 'Paused')

The label is also stopping the buttons from being clicked. You need to disable this as it over the buttons

$TimeLabel = GUICtrlCreateLabel ( "", 35, 0, 480, 180, $SS_CENTER )
GUICtrlSetState(-1, $GUI_DISABLE)

You can use +=1 and -=1 to increase or decrease values such as 

$kV = $kV + 1

becomes

$kV +=1

You have other while loops in the functions but don't exit them so the code for that function keeps running, one even says "just sleeps forever...." and GoBack() while is missing an expression such as 1.

You also declare some variables but not others. Have a read here for some tips.

The minimum Sleep value is 10ms so Sleep(1) just defaults to 10.

$SS_CENTER is a global variable for styles and you need to add #include <StaticConstants.au3> to the top of the script

 

Edited by benners
Posted
10 minutes ago, Jos said:

Try to simply do some coding in stead of hacking...  much better! ;)

Jos

I learn backwards :P

My HTML tends to look all nice and neat when I am done.  In order to learn I have to have a motivating goal.  This timer is my goal.  It will get more and more cleaned up and proper as it goes.  I tend to get in a hurry sometimes and my goal to have something tangible to start with is my weird way of going about things.

Posted
2 minutes ago, Jos said:

Sleep forever ?  not the best way?  You are talking in riddles.... show code so we understand!

Jos

While 1
    Sleep (100); just sleeps forever....
WEnd

This is my way of stopping the timer.   Hopefully that will not be there when I finish.

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
  • Recently Browsing   0 members

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