Sign in to follow this  
Followers 0
Remy

Buggy script.

3 posts in this topic

Hello, I'm making a script to do some stuff automaticaley for me. The problem is that the buttons in the program sometimes don't work. Sometimes it's not even possible to exit the program. So my question is what is wrong with it????

And I know that I only have programmed button 1,4 & 5.

#include <GUIConstants.au3>

GUICreate("Windows Cleaner",240,40)
$button1 = GUICtrlCreateButton ("Geschiedenis leegmaken", 0,0,40,40,$BS_ICON)
GUICtrlSetImage (-1, "inetcplc.dll",1)
$button2 = GUICtrlCreateButton ("Onlangs geopend leegmaken", 40,00,40,40,$BS_ICON)
GUICtrlSetImage (-1, "shell32.dll",20)
$button3 = GUICtrlCreateButton ("Prullenbak leegmaken", 80,00,40,40,$BS_ICON)
GUICtrlSetImage (-1, "shell32.dll",32)
$button4 = GUICtrlCreateButton ("Muispad Aan", 120, 0, 40, 40, $BS_ICON)
GUICtrlSetImage (-1, "setupapi.dll",1)
$button5 = GUICtrlCreateButton ("Muispad uit", 160, 0, 40, 40, $BS_ICON)
GUICtrlSetImage (-1, "msratelc.dll", 0)
$button6 = GUICtrlCreateButton ("Programma afsluiten", 200, 0, 40, 40, $BS_ICON)
GUICtrlSetImage (-1, "shell32.dll",27)

GUISetState()

While 1
    $msg = GUIGetMsg()  

Select

Case $msg =$button1
    Run ("RUNDLL32 SHELL32.DLL,Control_RunDLL inetcpl.cpl")
    

Case $msg =$button4
    Run ("RUNDLL32 SHELL32.DLL,Control_RunDLL main.cpl")
    WinWait("Eigenschappen voor Muis","")
    If Not WinActive("Eigenschappen voor Muis","") Then WinActivate("Eigenschappen voor Muis","")
    WinWaitActive("Eigenschappen voor Muis","")
    Send ("{tab 6}")
    Send ("{right 2}")
    send ("{Up}")
    Send ("!i")
    Send ("t")
    send ("{enter}")
    
Case $msg =$button5
    run ("RUNDLL32 SHELL32.DLL,Control_RunDLL main.cpl")
    WinWait("Eigenschappen voor Muis","")
    If Not WinActive("Eigenschappen voor Muis","") Then WinActivate("Eigenschappen voor Muis","")
    WinWaitActive("Eigenschappen voor Muis","")
    send ("{tab 6}")
    send ("{Right 2}")
    Send ("{Up}")
    send ("!u")
    Sleep(1000)
    WinWait("Waarschuwing","")
    If Not WinActive("Waarschuwing","") Then WinActivate("Waarschuwing","")
    WinWaitActive("Waarschuwing","")
    send ("{enter}")
    send ("!t")
    Send ("{enter}")
EndSelect


$msg = GUIGetMsg() 
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    Wend

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Try putting this line

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
inside the Select (make it another Case instead of a separate If) Edited by DoctorX

-DRX

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

So my question is what is wrong with it????

There is nothing wrong with the script, but you need to realize that when you click button 4 or 5, the script logic in Case $msg =$button4 or Case $msg =$button5 need to be executed and finish before any button will react again.

So if it gets stuck on any of your WinWait or WinWaitActive statements, your program will not respond.

To find out were the program is hanging add a Opt("TrayIconDebug", 1) at the top and look at the trayicon for info.

EDIT: Also remove the second $msg = GUIGetMsg() ... this will make it fail a lot as well..

Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
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
Sign in to follow this  
Followers 0