Sign in to follow this  
Followers 0
jftuga

Report Computer Problem

8 posts in this topic

Here is a script that we will be using in our exam rooms and be placed on the Start menu. It asks for your Logon ID, location, and description of problem. It then takes a screen shot and emails this. We have it set up to be mailed to our help desk distribution list. Where it asks for Logon ID, this is really the first part of the user's email address.

I have also attached the file which includes screenshot.dll (which I found on the forum) and blat.exe (used for sending the email).

-John

;
; ReportComputerProblem.au3
; -John Taylor
; Sep-27-2006
;
; This script will email your 'help desk' a short description of a computer
; problem and a screen shot.  It uses two external files, screenshot.dll
; and blat.exe.

; In the SendEmail() function, change the following variables:
;   $addr
;   $smtp_server
;   $smtp_FromAddress
;   $auth_user
;   $auth_pw
;
; The icon that I use when I compile to .exe for this program is:
; http://www.iconarchive.com/icon/system/alive-system-by-topicons/AngryMonitor.ico
;

#noicontray
#include <GUIConstants.au3>
#include <File.au3>

Opt("MustDeclareVars",1)
Opt("TrayIconHide", 1)

Dim $ProgName = "Report Computer Problem"

Dim $win = 0
Dim $w = 490
Dim $h = 300

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

func create_gui()
    Global $ProgName, $win, $w, $h
    Global $win = GUICreate($ProgName, $w, $h)
    GUISetState()

    GUICtrlCreateLabel("This program allows you to send a screenshot of your computer display to the helpdesk.", 15, 30)
    GUICtrlCreateLabel("When you press SUBMIT this window will close and then the screenshot will be taken.", 15, 45 )

    GUICtrlCreateLabel("Enter your Logon ID ( Example: jpentz )", 15,70)
    Global $LogonID = GUICtrlCreateInput("", 15,85)

    GUICtrlCreateLabel("What is your location ( Example: ACC, Exam J9 )", 15, 120)
    Global $Location = GUICtrlCreateInput("", 15,135)

    ;GUICtrlCreateLabel("Extremely urgent?", 280, 120 )
    Global $Urgent = GUICtrlCreateCheckbox("Extremely urgent?", 280, 120 )

    GUICtrlCreateLabel("Enter a short description of the problem", 15, 170)
    Global $Problem = GUICtrlCreateInput("", 15,185,460)

    Global $Submit = GUICtrlCreateButton("SUBMIT", 200, 220, 80)
    Global $Cancel = GUICtrlCreateButton("CANCEL", 200, 260, 80)
endfunc

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; validate user's input
func Validate()
    Global $LogonID, $Location, $Problem

    if StringLen( GUICtrlRead($LogonID) ) < 2 then
        MsgBox(48, "Warning", "Invalid Logon ID, please try again.")
        return 0
    endif

    if StringLen( GUICtrlRead($Location) ) < 2 then
        MsgBox(48, "Warning", "Invalid Location, please try again.")
        return 0
    endif

    if StringLen( GUICtrlRead($Problem) ) < 2 then
        MsgBox(48, "Warning", "Invalid Problem Description, please try again.")
        return 0
    endif

    return 1
endfunc


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; create an email message and write it to a temporary file
func CreateEmailMessage()
    Global $EmailFile
    Global $LogonID, $Location, $Problem
    local $rv = 0
    local $msg[8]

    local $now = @MON & "/" & @MDAY & "/" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC

    $msg[0] = @CRLF
    $msg[1] = "Date: " & $now
    $msg[2] = "Host: " & @ComputerName
    $msg[3] = @CRLF
    $msg[4] = "From: " & GUICtrlRead($LogonID)
    $msg[5] = "Location: " & GUICtrlRead($Location)
    $msg[6] = "Problem: " & GUICtrlRead($Problem)
    $msg[7] = @CRLF

    $EmailFile = _TempFile()
    return _FileWriteFromArray($EmailFile, $msg)
endfunc


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

func ScreenShot()
    Global $ScreenShotFile = _TempFile("","~",".jpg")

    DllCall("screenshot.dll", "int", "CaptureRegion", "str", $ScreenShotFile, "int", 0, "int", 0, "int", @DesktopWidth, "int", @DesktopHeight, "int", 85)
    sleep(333)
    if 0 == @error then
        return 1
    else
        return 0
    endif
endfunc

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

func SendEmail()
    Global $EmailFile, $ScreenShotFile, $LogonID_data, $Urgent_data

    Const $addr = "helpdesk@example..com"
    Const $smtp_server = "smtp..example..com"
    Const $smtp_FromAddress = $LogonID_data & "@example..com"
    local $smtp_subject = "Computer problem, see screenshot"
    Const $auth_user = "noreply"  ; for your smtp server
    Const $auth_pw = "AbC..123"
    Dim $cmd, $priority, $tmp

    $priority = 0
    if $GUI_CHECKED == $Urgent_data then
        $tmp = "[URGENT] " & $smtp_subject
        $smtp_subject = $tmp
        $priority = 1
    endif

    $cmd = 'blat.exe ' & $EmailFile & ' -to ' & $addr & ' -server ' & $smtp_server & ' -f "' & _
        $smtp_FromAddress & '" -subject "' & $smtp_subject & '" -attach ' & $ScreenShotFile & ' -priority ' & $priority & ' -u ' & $auth_user & ' -pw ' & $auth_pw & _
        " -noh2"

    local $status = 0
    $status = RunWait($cmd,"",@SW_HIDE)

    return $status
endfunc

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

func CleanUp()
    Global $EmailFile, $ScreenShotFile

    sleep(250)
    FileDelete($EmailFile)
    FileDelete($ScreenShotFile)
endfunc

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

func main()
    Global $Submit, $Cancel, $win
    Global $LogonID, $LogonID_data, $Urgent, $Urgent_data
    local $msg, $rv

    create_gui()

    while 1
        $msg = GUIGetMsg()

        if $GUI_EVENT_CLOSE == $msg then ExitLoop
        if $Cancel == $msg then ExitLoop

        if $msg == $Submit then
            $rv = Validate()
            if 0 == $rv then
                ContinueLoop
            endif

            $rv = CreateEmailMessage()
            if 0 == $rv then
                MsgBox(0x10, "Internal Error", "Unable to create email message, the helpdesk will NOT be notified of this problem.")
                ExitLoop
            endif

            $LogonID_data = GUICtrlRead($LogonID)
            $Urgent_data = GUICtrlRead($Urgent)
            GUIDelete( $win )
            $rv = ScreenShot()
            if 0 == $rv then
                MsgBox(0x10, "Internal Error", "Unable to create screen shot, the helpdesk will NOT be notified of this problem.")
                ExitLoop
            endif

            $rv = SendEmail()
            if 0 <> $rv then
                MsgBox(0x10, "Internal Error", "Unable to send email, the helpdesk will NOT be notified of this problem.")
                ExitLoop
            endif

            CleanUp()

            ExitLoop
        endif ; $msg == $Submit
    wend
endfunc

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

main()

; end of script

ReportComputerProblem.rar

Share this post


Link to post
Share on other sites



Here is a script that we will be using in our exam rooms and be placed on the Start menu. It asks for your Logon ID, location, and description of problem. It then takes a screen shot and emails this. We have it set up to be mailed to our help desk distribution list. Where it asks for Logon ID, this is really the first part of the user's email address.

I have also attached the file which includes screenshot.dll (which I found on the forum) and blat.exe (used for sending the email).

-John

;
; ReportComputerProblem.au3
; -John Taylor
; Sep-27-2006
;
; This script will email your 'help desk' a short description of a computer
; problem and a screen shot.  It uses two external files, screenshot.dll
; and blat.exe.

; In the SendEmail() function, change the following variables:
;   $addr
;   $smtp_server
;   $smtp_FromAddress
;   $auth_user
;   $auth_pw
;
; The icon that I use when I compile to .exe for this program is:
; http://www.iconarchive.com/icon/system/alive-system-by-topicons/AngryMonitor.ico
;

#noicontray
#include <GUIConstants.au3>
#include <File.au3>

Opt("MustDeclareVars",1)
Opt("TrayIconHide", 1)

Dim $ProgName = "Report Computer Problem"

Dim $win = 0
Dim $w = 490
Dim $h = 300

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

func create_gui()
    Global $ProgName, $win, $w, $h
    Global $win = GUICreate($ProgName, $w, $h)
    GUISetState()

    GUICtrlCreateLabel("This program allows you to send a screenshot of your computer display to the helpdesk.", 15, 30)
    GUICtrlCreateLabel("When you press SUBMIT this window will close and then the screenshot will be taken.", 15, 45 )

    GUICtrlCreateLabel("Enter your Logon ID ( Example: jpentz )", 15,70)
    Global $LogonID = GUICtrlCreateInput("", 15,85)

    GUICtrlCreateLabel("What is your location ( Example: ACC, Exam J9 )", 15, 120)
    Global $Location = GUICtrlCreateInput("", 15,135)

    ;GUICtrlCreateLabel("Extremely urgent?", 280, 120 )
    Global $Urgent = GUICtrlCreateCheckbox("Extremely urgent?", 280, 120 )

    GUICtrlCreateLabel("Enter a short description of the problem", 15, 170)
    Global $Problem = GUICtrlCreateInput("", 15,185,460)

    Global $Submit = GUICtrlCreateButton("SUBMIT", 200, 220, 80)
    Global $Cancel = GUICtrlCreateButton("CANCEL", 200, 260, 80)
endfunc

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; validate user's input
func Validate()
    Global $LogonID, $Location, $Problem

    if StringLen( GUICtrlRead($LogonID) ) < 2 then
        MsgBox(48, "Warning", "Invalid Logon ID, please try again.")
        return 0
    endif

    if StringLen( GUICtrlRead($Location) ) < 2 then
        MsgBox(48, "Warning", "Invalid Location, please try again.")
        return 0
    endif

    if StringLen( GUICtrlRead($Problem) ) < 2 then
        MsgBox(48, "Warning", "Invalid Problem Description, please try again.")
        return 0
    endif

    return 1
endfunc
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; create an email message and write it to a temporary file
func CreateEmailMessage()
    Global $EmailFile
    Global $LogonID, $Location, $Problem
    local $rv = 0
    local $msg[8]

    local $now = @MON & "/" & @MDAY & "/" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC

    $msg[0] = @CRLF
    $msg[1] = "Date: " & $now
    $msg[2] = "Host: " & @ComputerName
    $msg[3] = @CRLF
    $msg[4] = "From: " & GUICtrlRead($LogonID)
    $msg[5] = "Location: " & GUICtrlRead($Location)
    $msg[6] = "Problem: " & GUICtrlRead($Problem)
    $msg[7] = @CRLF

    $EmailFile = _TempFile()
    return _FileWriteFromArray($EmailFile, $msg)
endfunc
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

func ScreenShot()
    Global $ScreenShotFile = _TempFile("","~",".jpg")

    DllCall("screenshot.dll", "int", "CaptureRegion", "str", $ScreenShotFile, "int", 0, "int", 0, "int", @DesktopWidth, "int", @DesktopHeight, "int", 85)
    sleep(333)
    if 0 == @error then
        return 1
    else
        return 0
    endif
endfunc

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

func SendEmail()
    Global $EmailFile, $ScreenShotFile, $LogonID_data, $Urgent_data

    Const $addr = "helpdesk@example..com"
    Const $smtp_server = "smtp..example..com"
    Const $smtp_FromAddress = $LogonID_data & "@example..com"
    local $smtp_subject = "Computer problem, see screenshot"
    Const $auth_user = "noreply"  ; for your smtp server
    Const $auth_pw = "AbC..123"
    Dim $cmd, $priority, $tmp

    $priority = 0
    if $GUI_CHECKED == $Urgent_data then
        $tmp = "[URGENT] " & $smtp_subject
        $smtp_subject = $tmp
        $priority = 1
    endif

    $cmd = 'blat.exe ' & $EmailFile & ' -to ' & $addr & ' -server ' & $smtp_server & ' -f "' & _
        $smtp_FromAddress & '" -subject "' & $smtp_subject & '" -attach ' & $ScreenShotFile & ' -priority ' & $priority & ' -u ' & $auth_user & ' -pw ' & $auth_pw & _
        " -noh2"

    local $status = 0
    $status = RunWait($cmd,"",@SW_HIDE)

    return $status
endfunc

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

func CleanUp()
    Global $EmailFile, $ScreenShotFile

    sleep(250)
    FileDelete($EmailFile)
    FileDelete($ScreenShotFile)
endfunc

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

func main()
    Global $Submit, $Cancel, $win
    Global $LogonID, $LogonID_data, $Urgent, $Urgent_data
    local $msg, $rv

    create_gui()

    while 1
        $msg = GUIGetMsg()

        if $GUI_EVENT_CLOSE == $msg then ExitLoop
        if $Cancel == $msg then ExitLoop

        if $msg == $Submit then
            $rv = Validate()
            if 0 == $rv then
                ContinueLoop
            endif

            $rv = CreateEmailMessage()
            if 0 == $rv then
                MsgBox(0x10, "Internal Error", "Unable to create email message, the helpdesk will NOT be notified of this problem.")
                ExitLoop
            endif

            $LogonID_data = GUICtrlRead($LogonID)
            $Urgent_data = GUICtrlRead($Urgent)
            GUIDelete( $win )
            $rv = ScreenShot()
            if 0 == $rv then
                MsgBox(0x10, "Internal Error", "Unable to create screen shot, the helpdesk will NOT be notified of this problem.")
                ExitLoop
            endif

            $rv = SendEmail()
            if 0 <> $rv then
                MsgBox(0x10, "Internal Error", "Unable to send email, the helpdesk will NOT be notified of this problem.")
                ExitLoop
            endif

            CleanUp()

            ExitLoop
        endif ; $msg == $Submit
    wend
endfunc

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

main()

; end of script

You have no idea how helpfull this is... I was writing a script to send an attachment via e-mail...

Share this post


Link to post
Share on other sites

i was just looking for something what can send file with e-mails

thanks

Arjan

p.s. great script though

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

i was just looking for something what can send file with e-mails

thanks

Arjan

p.s. great script though

perhaps you mean emails with files???

Look at blat.exe it's free, and it's at the core of this email function.

google it.

Edited by blademonkey

---"Educate the Mind, Make Savage the Body" -Mao Tse Tung

Share this post


Link to post
Share on other sites

I always get the message:

"unabel to send email..."

what did i do wrong?

The exe is compiled, nothing has changed blat.exe is whithin the same dir...so???

Please help me..

Share this post


Link to post
Share on other sites

I also get the same eror.

Unable to create email message, the helpdesk will NOT be notified of this problem.

these are my settings.

Const $addr = "guayo@hotmail..com"

Const $smtp_server = "smtp..hotmail.com"

Const $smtp_FromAddress = $LogonID_data & "@hotmail..com"

local $smtp_subject = "Computer problem, see screenshot"

Const $auth_user = "noreply" ; for your smtp server

Const $auth_pw = "AbC..123"

Dim $cmd, $priority, $tmp

What am I doing wrong!

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

I also get the same eror.

Unable to create email message, the helpdesk will NOT be notified of this problem.

these are my settings.

Const $addr = "guayo@hotmail..com"

Const $smtp_server = "smtp..hotmail.com"

Const $smtp_FromAddress = $LogonID_data & "@hotmail..com"

local $smtp_subject = "Computer problem, see screenshot"

Const $auth_user = "noreply" ; for your smtp server

Const $auth_pw = "AbC..123"

Dim $cmd, $priority, $tmp

What am I doing wrong!

Looks to me like you've got one extra dot in the smtp address.

Edited by RagnaroktA

Current Projects:Remote Administration Suite Updated! 12-20-07Remote User State Migration Tool (Plugin) Updated! 12-20-07Batch Print Wizard Updated! 12-20-07Links:AutoIt Beta | AutoIt Wiki

Share this post


Link to post
Share on other sites

Other than fixing the double dot problem, change:

Const $smtp_FromAddress = $LogonID_data & "@hotmail..com"

to just:

Const $smtp_FromAddress = "guayo@hotmail..com"

(but you won't be able to reply to them, you would have to Forward the message back to the user instead of Replying)

Also, run blat.exe from the command line with a test message until you get it working. Then, in the SendEmail() function, add a MsgBox(0, "Cmd", $cmd) to make sure that blat is doing what you *think* it should be doing.

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