Jump to content

GUI input read help


Recommended Posts

How getting myself abit confused trying create GUI script to read value, set value for an Radio button, added attachment and aemailer.au3emailer.au3 number quantity into GUI front end to send emails.

The script which I am trying to create with GUI, to ask the user to enter an email address and then quantity of emails to send allow the user attach a file/files, and then a radio button to selet which version Outook being used. This for the subject body of as outlook 2003 subject message uses short cut key 'Alt J' & 2007 uses 'Alt U'.

I have enclosed my 1st attempt using msg boxes which works then my 2nd attempt trying creat GUI version with outlook version selection.

which is attchment called emailer.au3

The 2nd attempt, which i need help with?

#inlude <ButtonConstants.au3>

#include <EditConstants.au3>

#include <GUIConstantsEx.au3>

#include <StaticConstants.au3>

#include <WindowsConstants.au3>

local $email, $number, $U, $J, $radiop, $Msg, $nMsg

Opt("GUIOnEventMode",1)

$Form1_1 = GUICreate("Outlook emailer", 532, 231, 168, 124)

$input1 = GUICtrlCreateInput("Email", 24, 40, 481, 21)

$Label1 = GUICtrlCreateLabel("Enter Email address to send to:-", 16, 8, 193, 20)

GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")

;GUICtrlSetOnEvent($input1, "email")

$Label2 = GUICtrlCreateLabel("How many messages to be sent", 8, 80, 195, 20)

$input2 = GUICtrlCreateInput("1", 24, 104, 73, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))

GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")

GUICtrlSetLimit(-1, 3)

;GUICtrlSetOnEvent($Label2, "input2")

$radio1 = GUICtrlCreateRadio("Outlook 2003", 24, 152, 113, 17)

GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")

GUICtrlSetOnEvent($radio1, "radio1")

$radio2 = GUICtrlCreateRadio("Outlook 2007", 24, 192, 113, 17)

GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")

GUICtrlSetOnEvent($radio2, "radio2")

$filemenu = GUICtrlCreateMenu("File")

$fileitem = GUICtrlCreateMenuItem("Open...", $filemenu)

$recentfilesmenu = GUICtrlCreateMenu("Recent Files", $filemenu)

$separator1 = GUICtrlCreateMenuItem("", $filemenu)

$exititem = GUICtrlCreateMenuItem("Exit", $filemenu)

GUICtrlSetOnEvent($fileitem, "file")

$Start = GUICtrlCreateButton("Start", 336, 168, 137, 41, $WS_GROUP)

GUICtrlSetOnEvent($Start, "Start")

GUISetState (@SW_SHOW)

If not WinExists ("Microsoft Outlook 2003") Then

msgbox (0, "User Message", "Outlook will start!", "2")

Run ("C:\Program Files\Microsoft Office\Office\outlook.exe")

Else

msgbox (0, "User Message", "Please wait", "1")

Endif

While 1

$Msg = GUIGetMsg()

Sleep(1000)

if $Msg -0 Then exit

if $Msg=$Start then Start()

WEnd

func radio1()

$radiop = GUICtrlRead($radio1, $U)

EndFunc

func radio2()

$radiop = GUICtrlRead($radio2, $J)

EndFunc

func file()

GUISetState()

While 1

$nMsg = GUIGetMsg()

Select

Case $nMsg = $GUI_EVENT_CLOSE

ExitLoop

Case $nMsg = $fileitem

$file = FileOpenDialog("Choose file...", @WorkingDir & "\", "All (*.*)")

If @error <> 1 Then GUICtrlCreateMenuItem($file, $recentfilesmenu)

Case $nMsg = $exititem

ExitLoop

EndSelect

WEnd

GUIDelete()

Exit

EndFunc

Func start()

Sleep (500)

$x=0

Do

WinActivate("Inbox - Microsoft Outlook", "")

Send("^n") ; Ctrl N "for new email window"

WinActivate("Untitled - Message (Rich Text) ", "")

Send ($input1)

Send ("!" & $radiop) ; "Alt J" key pressed for subject box

Send ("Message" & $input2)

Send("!if") ; Alt I F keys " to open Attachment window "

WinWait("", "",5)

send ($fileitem)

;Send ("C:\Program Files\test.txt")

WinWait("", "", 5)

Send("{ENTER}")

Send("{ENTER}")

WinWait("", "", 5)

Send("^{ENTER}")

Sleep (1000)

$x=$x+1

Until $x=$input2

MsgBox (0, "Message Sent", "Total of "& $x & " messages has been sent to " & $input1)

EndFunc

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...