Jump to content

CPU Usage


Recommended Posts

i guess my script was too long here the end part.

Case $msg[0] = $dns_settings
            
            
            ControlDisable($parent_title, "", "");disable parent window so that you have to close child to interact with parent
        ;Create child window and add the parameter to make it the child of the parent window
            $dns_settings_win = GUICreate("dns Settings", 500,150, $ParentWin_Pos[0] + 50, $ParentWin_Pos[1] + 50, -1, -1, $ParentWin)
            GuiSetIcon($icon, 0)
        ;-------------------------
            $dns_service_name = GuiCtrlCreateInput(ReadFileMatch1($service_configuration_file,$dns_abbrv,":","",""), 150, 20, 230, 20)
            GuiCtrlCreateLabel("dns Service Name:", 10, 22, 110, 20)
            $dns_service_button = GuiCtrlCreateButton("Edit", 400, 17, 50, 30)
        ;-------------------------
            $dns_process_name = GuiCtrlCreateInput(ReadFileMatch1($service_configuration_file,$dns_abbrv,":",1,""), 150, 60, 230, 20)
            GuiCtrlCreateLabel("dns Process Name:", 10, 62, 110, 30)
            $dns_process_button = GuiCtrlCreateButton("Edit", 400, 57, 50, 30)
        ;------------------------
            $dns_taskShow = GuiCtrlCreateButton("Open Task Manager", 50, 97, 150, 30)
        ;------------------------
            $dns_servShow = GuiCtrlCreateButton("Open MS Service list", 200, 97, 150, 30)
        ;------------------------
            $dns_exit = GuiCtrlCreateButton("Exit", 400, 97, 50, 30)
            GUISetState(@SW_SHOW)               
                While 1
                    $child_msg = GUIGetMsg()
                    Select  
                        Case $child_msg = $dns_taskShow
                            _RunDOS_N( "taskmgr" )
                        Case $child_msg = $dns_servShow
                            _RunDOS_N( "%SystemRoot%\system32\services.msc /s" )
                        Case $child_msg = $dns_service_button
                            $serv_contents = ReadFileMatch1($service_configuration_file,"","","",1);full array of file
                        Conf_Edit($serv_contents,$service_configuration_file,GUICtrlRead ($dns_service_name),$dns_abbrv,2)
                        
                        Case $child_msg = $dns_process_button
                            $serv_contents = ReadFileMatch1($service_configuration_file,"","","",1);full array of file
                        Conf_Edit($serv_contents,$service_configuration_file,GUICtrlRead ($dns_process_name),$dns_abbrv,3)
                                                
                                                    
                    Case $child_msg  = $GUI_EVENT_CLOSE or $child_msg  = $dns_exit
                        GUISwitch($dns_settings_win)
                        GUIDelete()
                        ControlEnable($parent_title, "", "")
                        Exitloop
                        
                    EndSelect
                WEnd
        ;Show the child window/Make the child window visible
            GUISetState(@SW_SHOW)
            
        ;Switch to the parent window
            GUISwitch($ParentWin)
    ;Case $msg[0] = 0 
    ;Sleep(1000)
    ;ContinueLoop
    EndSelect
    
WEnd


;

;#comments-end

Exit
Link to comment
Share on other sites

  • Moderators

Could be that you don't have one active Sleep()... an occassional sleep(10) even would help quite a bit in your While Statements.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

One thing I saw, set:

TraySetState()
    TraySetClick(16)

before the While 1-line and try again.

Edit: another thing with the memory is a known bug:

see here:

http://www.autoitscript.com/forum/index.php?showtopic=14723

Regards

Edited by Holger
Link to comment
Share on other sites

This is why I posted the code for help not smart ass comments, plus i responded to what I thought said it might be a known bug. probably I misunderstood what holger posted

AutoIt3 isn't so much the problem. It is usually the structure of your code that depends on quality :whistle:

<{POST_SNAPBACK}>

Link to comment
Share on other sites

This is why I posted the code for help not smart ass comments, plus i responded to what I thought said it might be a known bug. probably I misunderstood what holger posted

<{POST_SNAPBACK}>

Smart ass comments ? That was a tip. I was telling you that unless it's a bug, AutoIt3 usually is not the problem. It is usually the way the code is written, how certain functions are used, and improper use of functions. I'm not saying your code may have had all that, I didn't even look over all your code at the time. But I'm saying, it's not a good habbit to first blame the program, and then later find out it was your code.
FootbaG
Link to comment
Share on other sites

Thank you, my bad, little frustrated I looked over my code a zillion times...I actually assume first it was my code just something i'm missing since i'm new to autoit. this is why I posted to code for help. Thanks for your insight.

Smart ass comments ? That was a tip. I was telling you that unless it's a bug, AutoIt3 usually is not the problem. It is usually the way the code is written, how certain functions are used, and improper use of functions. I'm not saying your code may have had all that, I didn't even look over all your code at the time. But I'm saying, it's not a good habbit to first blame the program, and then later find out it was your code.

<{POST_SNAPBACK}>

Link to comment
Share on other sites

Thank you, my bad, little frustrated I looked over my code a zillion times...I actually assume first it was my code just something i'm missing since i'm new to autoit.  this is why I posted to code for help. Thanks for your insight.

<{POST_SNAPBACK}>

No problem... I know how it feels to be frusterated, and be new... It's a weird feeling.

Welcome to the forums :whistle:

FootbaG
Link to comment
Share on other sites

Welcome to the forums!

I suggest modifying your script to use the GUI OnEvent mode instead of the MessageLoop mode. This will ultimately make your code cleaner and easier to manage while allowing you the luxury of adding Sleep()s to your code (doing so during a message loop will make your GUI lag between e.g. a button click and its functioning, which you appear to have acknowledged).

Link to comment
Share on other sites

Thanks, I will try this although not familar i'll look it up and change my code any pointer will also be good thanks

Welcome to the forums!

I suggest modifying your script to use the GUI OnEvent mode instead of the MessageLoop mode. This will ultimately make your code cleaner and easier to manage while allowing you the luxury of adding Sleep()s to your code (doing so during a message loop will make your GUI lag between e.g. a button click and its functioning, which you appear to have acknowledged).

<{POST_SNAPBACK}>

Link to comment
Share on other sites

I have tried what you said the cpu is down very low, i'm still using the beta version and excited. I also change my traymsg to use the tray onevent so as your suggestion for gui onevent. this is much cleaner and only uses cpu time when needed...thanks thanks...but now i have another questions.

if best practice is to use the onevent modes options, reduces cpu time all great stuff..then why do we use the while loops for gui when the only good reason i see it for is for array and sleep time...any pointers

i mostly use the for loops for my arrays.??

Welcome to the forums!

I suggest modifying your script to use the GUI OnEvent mode instead of the MessageLoop mode. This will ultimately make your code cleaner and easier to manage while allowing you the luxury of adding Sleep()s to your code (doing so during a message loop will make your GUI lag between e.g. a button click and its functioning, which you appear to have acknowledged).

<{POST_SNAPBACK}>

Link to comment
Share on other sites

I have tried what you said the cpu is down very low, i'm still using the beta version and excited. I also change my traymsg to use the tray onevent so as your suggestion for gui onevent. this is much cleaner and only uses cpu time when needed...thanks thanks...but now i have another questions.

if best practice is to use the onevent modes options, reduces cpu time all great stuff..then why do we use the while loops for gui when the only good reason i see it for is for array and sleep time...any pointers

i mostly use the for loops  for my arrays.??

<{POST_SNAPBACK}>

without the loop, your script is jsut a script to display a gui. the loop tells it to wait around for more instructions after finish that goal. without the loop, the gui goes away. comment it out and try to run it
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...