rawkhopper Posted April 18, 2017 Share Posted April 18, 2017 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 Link to comment Share on other sites More sharing options...
benners Posted April 18, 2017 Share Posted April 18, 2017 (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 April 18, 2017 by benners Xandy 1 Link to comment Share on other sites More sharing options...
rawkhopper Posted April 18, 2017 Author Share Posted April 18, 2017 Awesome! Thanks for the help. I will hack at it some more and see what happens. Thanks for the push in the right direction! Link to comment Share on other sites More sharing options...
Developers Jos Posted April 18, 2017 Developers Share Posted April 18, 2017 13 minutes ago, rawkhopper said: hack Try to simply do some coding in stead of hacking... much better! 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 More sharing options...
rawkhopper Posted April 18, 2017 Author Share Posted April 18, 2017 Oh and the just sleeps forever is my way of stopping the whole thing when the timer is done. I guess that's not the best way to do it. Link to comment Share on other sites More sharing options...
Developers Jos Posted April 18, 2017 Developers Share Posted April 18, 2017 Sleep forever ? not the best way? You are talking in riddles.... show code so we understand! 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 More sharing options...
rawkhopper Posted April 18, 2017 Author Share Posted April 18, 2017 10 minutes ago, Jos said: Try to simply do some coding in stead of hacking... much better! Jos I learn backwards 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. Link to comment Share on other sites More sharing options...
rawkhopper Posted April 18, 2017 Author Share Posted April 18, 2017 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. Link to comment Share on other sites More sharing options...
Developers Jos Posted April 18, 2017 Developers Share Posted April 18, 2017 (edited) I don't see what is wrong there when your script's GUI is event based. Jos Edited April 18, 2017 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 More sharing options...
rawkhopper Posted April 18, 2017 Author Share Posted April 18, 2017 Ok Thanks Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now