Sign in to follow this  
Followers 0
Anton1

Hotkey that fires gui for email

4 posts in this topic

Hello,

This script will bring up a gui for creating a standard email notice about a new project. My problem is that once the gui is used to generate the notice it closes, I want the script to continue to run in the background so it can be called when ever needed via the hotkey? Thanks for your help.

Here is the script...

CODE

#include <GuiConstants.au3>

Local $WONum, $Notes, $Generate, $msg, $Var1, $Var2, $Var3, $Var4, $Via, $DueDate, $Description, $Status, $Ship, $Deliver, $Pickup, $Apply, $New, $Reorder

HotKeySet ( "#1" , "WOGenerator" );Win-1, TO FIRE WOGen

GuiCreate("WOGen", 327, 408,-1, -1) ;, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$Label_1 = GuiCtrlCreateLabel("WO#", 30, 23, 30, 20)

$WONum = GuiCtrlCreateInput("123456", 60, 20, 50, 20)

$Label_2 = GuiCtrlCreateLabel("Due:", 150, 23, 30, 20)

$DueDate = GuiCtrlCreateDate("", 180, 20, 116, 20, 0x00)

$ViaGroup = GuiCtrlCreateGroup("Via", 30, 50, 270, 50)

$Ship = GuiCtrlCreateRadio("Ship", 40, 70, 60, 20)

GuiCtrlSetState(-1, $GUI_CHECKED)

$Deliver = GuiCtrlCreateRadio("Deliver", 100, 70, 60, 20)

$Pickup = GuiCtrlCreateRadio("Pickup", 170, 70, 60, 20)

$Apply = GuiCtrlCreateRadio("Apply", 230, 70, 60, 20)

$SatusGroup = GuiCtrlCreateGroup("Satus", 30, 110, 270, 50)

$New = GuiCtrlCreateRadio("New", 80, 130, 60, 20)

GuiCtrlSetState(-1, $GUI_CHECKED)

$Reorder = GuiCtrlCreateRadio("Reorder", 200, 130, 80, 20)

$Label_3 = GuiCtrlCreateLabel("Description:", 34, 171, 55, 14)

$Description = GuiCtrlCreateInput("", 35, 190, 265, 56)

$Label_4 = GuiCtrlCreateLabel("Notes:", 36, 253, 40, 16)

$Notes = GuiCtrlCreateInput("", 35, 270, 265, 60)

$Cancel = GuiCtrlCreateButton("Cancel", 35, 347, 80, 28)

$Generate = GuiCtrlCreateButton("Generate", 129, 347, 79, 28)

Func WOGenerator()

GuiSetState()

While 1

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

Case $msg = $generate

$Var1 = GUICtrlRead($WONum)

$Var2 = GUICtrlRead($DueDate)

$Var3 = GUICtrlRead($Description)

$Var4 = GUICtrlRead($Notes)

Select

Case GUICtrlRead($Ship) = 1

$Via = "Ship"

Case GUICtrlRead($Deliver) = 1

$Via = "Deliver"

Case GUICtrlRead($Pickup) = 1

$Via = "Pickup"

Case GUICtrlRead($Apply) = 1

$Via = "Apply"

EndSelect

Select

Case GUICtrlRead($New) = 1

$Status = "N,"

Case GUICtrlRead($Reorder) = 1

$Status = "Reorder"

EndSelect

$myOlApp = ObjCreate("Outlook.Application")

$myItem = $myOlApp.Application.CreateItem(0)

$myItem.Display

$myItem.To = "email address"

$myItem.Subject = "WO# "&$Var1&" - "&$Status&" "&$Via&" "&$Var2&", "&$Var3

$myItem.Body = $Var4

;MsgBox(0, 'Testing', "WO# "&$Var1&" - "&$Status&" "&$Via&" "&$Var2&", "&$Var3&" - "&$Var4)

ExitLoop

Case $msg = $Cancel

ExitLoop

EndSelect

WEnd

Exit

EndFunc

While 1

Sleep(1000)

WEnd

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Emm.. Well... there's an Exit there. When you close the GUI, it exits the loop and then the script. Look:

#include <GuiConstants.au3>

Local $WONum, $Notes, $Generate, $msg, $Var1, $Var2, $Var3, $Var4, $Via, $DueDate, $Description, $Status, $Ship, $Deliver, $Pickup, $Apply, $New, $Reorder


HotKeySet("#1", "WOGenerator");Win-1, TO FIRE WOGen



GUICreate("WOGen", 327, 408, -1, -1) ;, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$Label_1 = GUICtrlCreateLabel("WO#", 30, 23, 30, 20)
$WONum = GUICtrlCreateInput("123456", 60, 20, 50, 20)
$Label_2 = GUICtrlCreateLabel("Due:", 150, 23, 30, 20)
$DueDate = GUICtrlCreateDate("", 180, 20, 116, 20, 0x00)
$ViaGroup = GUICtrlCreateGroup("Via", 30, 50, 270, 50)
$Ship = GUICtrlCreateRadio("Ship", 40, 70, 60, 20)
GUICtrlSetState(-1, $GUI_CHECKED)
$Deliver = GUICtrlCreateRadio("Deliver", 100, 70, 60, 20)
$Pickup = GUICtrlCreateRadio("Pickup", 170, 70, 60, 20)
$Apply = GUICtrlCreateRadio("Apply", 230, 70, 60, 20)
$SatusGroup = GUICtrlCreateGroup("Satus", 30, 110, 270, 50)
$New = GUICtrlCreateRadio("New", 80, 130, 60, 20)
GUICtrlSetState(-1, $GUI_CHECKED)
$Reorder = GUICtrlCreateRadio("Reorder", 200, 130, 80, 20)
$Label_3 = GUICtrlCreateLabel("Description:", 34, 171, 55, 14)
$Description = GUICtrlCreateInput("", 35, 190, 265, 56)
$Label_4 = GUICtrlCreateLabel("Notes:", 36, 253, 40, 16)
$Notes = GUICtrlCreateInput("", 35, 270, 265, 60)
$Cancel = GUICtrlCreateButton("Cancel", 35, 347, 80, 28)
$Generate = GUICtrlCreateButton("Generate", 129, 347, 79, 28)


Func WOGenerator()
    GUISetState()
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $Generate
                $Var1 = GUICtrlRead($WONum)
                $Var2 = GUICtrlRead($DueDate)
                $Var3 = GUICtrlRead($Description)
                $Var4 = GUICtrlRead($Notes)
                Select
                    Case GUICtrlRead($Ship) = 1
                        $Via = "Ship"
                    Case GUICtrlRead($Deliver) = 1
                        $Via = "Deliver"
                    Case GUICtrlRead($Pickup) = 1
                        $Via = "Pickup"
                    Case GUICtrlRead($Apply) = 1
                        $Via = "Apply"
                EndSelect
                Select
                    Case GUICtrlRead($New) = 1
                        $Status = "N,"
                    Case GUICtrlRead($Reorder) = 1
                        $Status = "Reorder"
                EndSelect

                $myOlApp = ObjCreate("Outlook.Application")
                $myItem = $myOlApp.Application.CreateItem(0)
                $myItem.Display
                $myItem.To = "email address"
                $myItem.Subject = "WO# " & $Var1 & " - " & $Status & " " & $Via & " " & $Var2 & ", " & $Var3
                $myItem.Body = $Var4

                ;MsgBox(0, 'Testing', "WO# "&$Var1&" - "&$Status&" "&$Via&" "&$Var2&", "&$Var3&" - "&$Var4)
                ExitLoop
            Case $msg = $Cancel
                ExitLoop


        EndSelect
    WEnd

;~  Exit <--- Problem
    GUISetState(@SW_HIDE);Hide it back instead of closing it.

EndFunc   ;==>WOGenerator



While 1
    Sleep(1000)
WEnd
Edited by Nahuel

Share this post


Link to post
Share on other sites

Thnaks Nahuel! That is what I need to do is hide the Gui. Now when it is recalled for another email I need to reset the feilds to blank, how would I do this? Thanks for the input!

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