Jump to content
Sign in to follow this  
failedtocompile

If statments for buttons + tooltip

Recommended Posts

failedtocompile

Hello.

I wanted to jazz up my existing script:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <SendMessage.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiToolTip.au3>

TraySetState(2)

$MyHomeShare = EnvGet("HomeShare")
$ProcessName1 = "Outlook.exe"
;$ProcessName2 = "WinWord.exe"
;$ProcessName3 = "Excel.exe"

$Form1 = GUICreate("Form1", 401, 221, 320, 221)
$Bkgrnd = GUICtrlCreatePic(@ScriptDir & "\temp.bmp", 0, 0, 400, 220, $WS_CLIPSIBLINGS)
$Btn_bkup = GUICtrlCreateButton("", 9, 168, 82, 41, BitOR($WS_CLIPSIBLINGS, $BS_FLAT))
$Btn_restore = GUICtrlCreateButton("", 315, 168, 73, 41, BitOR($WS_CLIPSIBLINGS, $BS_FLAT))
$Btn_exit = GUICtrlCreateButton("", 333, 0, 82, 37, BitOR($WS_CLIPSIBLINGS, $BS_FLAT))
GUISetState(@SW_SHOW)


    
    While 1
        switch GUIGetMsg()
        
    Case $Btn_bkup
                RunWait('"temp.exe" /q /f /s "' & $MyHomeShare & '\officebkup\officebkup.OPS"')

            Case $Btn_restore
                RunWait('"temp.EXE" /q /f /r "' & $MyHomeShare & '\officebkup\officebkup.OPS"')
        
        Case $Btn_exit
            MsgBox(0, 'Thankyou', 'Thankyou for using ' & @LF & '' & @LF & 'temp' & @LF & '' & @LF & 'Hope this has helped you')
            ExitLoop
            
        EndSwitch
        WEnd
Exit

So i tried adding IF statements

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <SendMessage.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiToolTip.au3>

TraySetState(2)

$MyHomeShare = EnvGet("HomeShare")
$ProcessName1 = "Outlook.exe"
;$ProcessName2 = "WinWord.exe"
;$ProcessName3 = "Excel.exe"

$Form1 = GUICreate("Form1", 401, 221, 320, 221)
$Bkgrnd = GUICtrlCreatePic(@ScriptDir & "\temp.bmp", 0, 0, 400, 220, $WS_CLIPSIBLINGS)
$Btn_bkup = GUICtrlCreateButton("", 9, 168, 82, 41, BitOR($WS_CLIPSIBLINGS, $BS_FLAT))
$Btn_restore = GUICtrlCreateButton("", 315, 168, 73, 41, BitOR($WS_CLIPSIBLINGS, $BS_FLAT))
$Btn_exit = GUICtrlCreateButton("", 333, 0, 82, 37, BitOR($WS_CLIPSIBLINGS, $BS_FLAT))
GUISetState(@SW_SHOW)


    
    
    Case $Btn_bkup
        If ProcessExists($ProcessName1) Then
            msgbox(0,"Outlook is Running",$ProcessName1 & "   Is Running please close it down before using this utility.")
            If Not ProcessExists($ProcessName1) Then RunWait('"temp.EXE" /q /f /s "' & $MyHomeShare & '\officebkup\officebkup.OPS"')
        EndIf
            
            Case $Btn_restore
                If ProcessExists($ProcessName1) Then
            msgbox(0,"Outlook is Running",$ProcessName1 & "   Is Running please close it down before using this utility.")
            If Not ProcessExists($ProcessName1) Then RunWait('"temp.EXE" /q /f /r "' & $MyHomeShare & '\officebkup\officebkup.OPS"')
        EndIf
        
        Case $Btn_exit
            MsgBox(0, 'Thankyou', 'Thankyou for using ' & @LF & '' & @LF & 'temp' & @LF & '' & @LF & 'Hope this has helped you')
            ExitLoop
Exit

But it just does nothing.

I also tried to adding tool tips for each button but when i launch the script the tool tip is not even on the GUI its located somewhere else on the desktop :D

I used a application called codewizard (cant find my example script which i used the examples the codewizard app provided) will try and find tool tip script at home and post it.

Anyway could someone point me in the right direction? such as a keyword i need to look for in help file or search forums for specific keyword.

I have looked in the help file for possibilities such as using loop statments but was not sure on how to apply that to my script.

Thanks in advance

Share this post


Link to post
Share on other sites
Zisly

This works, can't bother explaining all "misstakes".

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <SendMessage.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiToolTip.au3>

TraySetState(2)

$MyHomeShare = EnvGet("HomeShare")
$ProcessName1 = "Outlook.exe"
$ProcessName2 = "WinWord.exe"
$ProcessName3 = "Excel.exe"

$Form1 = GUICreate("Form1", 401, 221, 320, 221)
$Bkgrnd = GUICtrlCreatePic(@ScriptDir & "\temp.bmp", 0, 0, 400, 220, $WS_CLIPSIBLINGS)
$Btn_bkup = GUICtrlCreateButton("$Btn_bkup", 9, 168, 82, 41, BitOR($WS_CLIPSIBLINGS, $BS_FLAT))
$Btn_restore = GUICtrlCreateButton("$Btn_restore", 315, 168, 73, 41, BitOR($WS_CLIPSIBLINGS, $BS_FLAT))
$Btn_exit = GUICtrlCreateButton("$Btn_exit", 333, 0, 82, 37, BitOR($WS_CLIPSIBLINGS, $BS_FLAT))
GUISetState(@SW_SHOW)


While 1
    Sleep(30)
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Btn_bkup
            If ProcessExists($ProcessName1) Then
                MsgBox(0, "Outlook is Running", $ProcessName1 & "   Is Running please close it down before using this utility.")
            Else
                RunWait('"temp.EXE" /q /f /s "' & $MyHomeShare & '\officebkup\officebkup.OPS"')
            EndIf
        Case $Btn_restore
            If ProcessExists($ProcessName1) Then
                MsgBox(0, "Outlook is Running", $ProcessName1 & "   Is Running please close it down before using this utility.")
            Else
                RunWait('"temp.EXE" /q /f /r "' & $MyHomeShare & '\officebkup\officebkup.OPS"')
            EndIf
        Case $Btn_exit
            MsgBox(0, 'Thankyou', 'Thankyou for using ' & @LF & '' & @LF & 'temp' & @LF & '' & @LF & 'Hope this has helped you')
            Exit
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites
failedtocompile

Thankyou very much Zisly

Is there some debugging utility that helps you with resolving coding issues, that you used to asses mine? or are you just that good :D

anyway thanks again

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.