mbiwpeoyc Posted October 6, 2005 Share Posted October 6, 2005 All,I'm trying to make a script that automatically generates 3 outlook signatures for my company. I need one html, one rtf, and one in plain text. I've got the script half working. It doesn't generate any errors for me, but it doesn't make the files either, and I'm not sure why. Any help at all would be appreciatted. I've tried putting the path in explicitly ('"c:\documents and settings\' & @username & 'application data\microsoft\Signatures\') and I've tried @appdatadir. None of them produce errors but the files go out in lala land somewhere #include <GUIConstants.au3>#include <file.au3>; turn on event mode so I can read button pressesopt("guioneventmode",1)$path = @appdatadir & 'Microsoft\Signatures\'guicreate ("Signature Generator", 185, 100); set special gui eventsguisetonevent($gui_event_close, "special")guisetonevent($gui_event_minimize, "special")guisetonevent($gui_event_restore, "special");start gui labelsguictrlcreatelabel("First Name", 10, 10)guictrlcreatelabel("Last Name", 100, 10)guictrlcreateinput ("", 10, 25, 75, 20)$last = guictrlcreateinput ("", 100, 25, 75, 20)$lastname = guictrlread($last)$bell = guictrlcreatebutton ("Phone Numbers", 55, 60, 85, 30)guictrlsetonevent(-1, "address")guisetstate (@sw_show);make window stay aroundwhile 1 sleep(10)wend;function for when you press the next buttonfunc address() Global $given Global $family Global $address1 $1st = guictrlread(5) ;read first name from previous window $1left = Stringleft ($1st, 1) ; grab the first character of the string and store it $firstname = stringtrimleft($1st, 1) ; Cut the first character of the string and store the result $fproper = Stringupper ($1left) ; Make the first letter uppercase $given = $fproper & $firstname ; Marry the two cut up strings but with proper capitalization $lst = guictrlread(6) $1lst = Stringleft ($lst, 1) $lastname = stringtrimleft($lst, 1) $lproper = stringupper ($1lst) $family = $lproper & $lastname $address1 = "somewhere somewhere" & @crlf & "anywheretown, USA" $prefix = "425" global $main $main = $prefix & ".123.4567" $fax = $prefix & ".123.4567" $something = wingethandle ( "Signature Generator") ; get parent handle guicreate ("Contact Info", 200, 200, -1, -1, -1, -1, $something) ; make a child ;link gui events to master func guisetonevent($gui_event_close, "special") guisetonevent($gui_event_minimize, "special") guisetonevent($gui_event_restore, "special") ;show the new window guisetstate(@sw_show) ;Labels for each branch guictrlcreatelabel("Branch Address:", 60, 5) guictrlcreatelabel($address1, 20, 20, 155, 30) guictrlcreatelabel("Main: " & $main, 10, 50) guictrlcreatelabel("Direct Line: ", 10, 70) guictrlcreatelabel("Cell Phone: ", 10, 90) guictrlcreatelabel("Fax Number: " & $fax, 10, 110) guictrlcreatelabel($given & $family & '@something.com', 10, 130) guictrlcreatelabel("www.corporateamerica.com", 10, 150) guictrlcreateinput("", 85, 70, 70, 16, $es_number) guictrlsettip(4110, "You must type in your phone number including the area code without any seperators" & @crlf & "i.e. 4251234567") guictrlcreateinput("", 85, 90, 70, 16, $es_number) guictrlsettip(4111, "You must type in your phone number including the area code without any seperators" & @crlf & "i.e. 4251234567") ;let's make the rtf, html, and txt sigs $irdone = guictrlcreatebutton ("Generate my Signatures", 40, 170) guictrlsetonevent(-1, "Generatebell")endfuncfunc generatebell() $direct = guictrlread(4110) $darea = stringleft($direct, 3) $dsuffix = stringright($direct, 4) $directcut = stringtrimleft($direct, 3) $dprefix = stringleft($directcut, 3) $directproper = $darea & '.' & $dprefix & '.' & $dsuffix if fileexists($path & 'standard.htm"') then filedelete($path & 'standard.htm"') endif $html = fileopen($path & 'standard.htm"', 1) $htmlpath = ($path & 'standard.htm"') filewrite($htmlpath, "<HTML>" & @crlf & "<HEAD>" & @crlf & "<TITLE></TITLE>" & @crlf & "</HEAD>" & @crlf) filewrite($htmlpath, "<BODY>" & @crlf) filewrite($htmlpath, '<P><B><Font Size=2 face = "Arial">') filewrite($htmlpath, $given & ' ' & $family & "</FONT></B>" & @crlf) filewrite($htmlpath, '<BR><B><I><FONT COLOR="#008000" SIZE=2 FACE="Arial">Sierra Systems</FONT></I></B>' & @crlf) $streetaddress = Stringleft($address1, 31) $cityaddress = stringright($address1, 23) $address = $streetaddress & @crlf & $cityaddress filewrite($htmlpath, '<BR><FONT SIZE=2 FACE="Arial">' & $streetaddress & '</FONT>' & @crlf) filewrite($htmlpath, '<BR><FONT SIZE=2 FACE="Arial">' & $cityaddress & '</FONT>' & @crlf) filewrite($htmlpath, '<BR><FONT SIZE=2 FACE="Arial">' & "Main: " & $main & "</FONT>" & @crlf) filewrite($htmlpath, '<BR><FONT SIZE=2 FACE="Arial">' & "Direct: " & $directproper & "</FONT>" & @crlf) filewrite($htmlpath, '<BR><FONT SIZE=2 FACE="Arial">' & "Fax: 425.586.5487</FONT>" & @crlf) $cell = guictrlread(4111) if Stringlen($cell) = 0 Then filewrite($htmlpath, '<BR><A HREF="mailto:' & $given & $family & '@corporate.com">' & '<U><FONT COLOR="#0000FF" SIZE=2 FACE="Arial">' & $given & $family & '@corproate.com</FONT></U></A>' & @crlf) filewrite($htmlpath, '<BR><A HREF="http://www.corporate.com"><U><FONT COLOR="#0000FF" SIZE=2 FACE="Arial">www.corporate.com</FONT></U></A></P>') filewrite($htmlpath, "</BODY>" & @crlf & "</HTML>") fileclose($html) elseif Stringlen($cell) > 0 Then $carea = stringleft($cell, 3) $csuffix = stringright($cell, 4) $ccut = stringtrimleft($cell, 3) $cprefix = stringleft($ccut, 3) $cellproper = $carea & '.' & $cprefix & '.' & $csuffix filewrite($htmlpath, '<BR><FONT SIZE=2 FACE="Arial">Cell: ' & $cellproper & "</FONT>" & @crlf) filewrite($htmlpath, '<BR><A HREF="mailto:' & $given & $family & '@corporate.com">' & '<U><FONT COLOR="#0000FF" SIZE=2 FACE="Arial">' & $given & $family & '@corporate.com</FONT></U></A>' & @crlf) filewrite($htmlpath, '<BR><A HREF="http://www.corporate.com"><U><FONT COLOR="#0000FF" SIZE=2 FACE="Arial">www.corporate.com</FONT></U></A></P>') filewrite($htmlpath, @crlf & "</BODY>" & @crlf & "</HTML>") fileclose($html) endif ;RTF file generation if fileexists($path & 'standard.rtf"') then filedelete($path * 'standard.rtf"') endif $rtfpath = fileopen($path & 'standard.rtf"', 1) $rtfhandle = ($path & 'standard.rtf"') filewrite($rtfhandle, "{\rtf1\ansi\ansicpg1252\deff0{\fonttbl{\f0\fswiss\fprq2\fcharset0 Arial;}{\f1\fswiss\fcharset0 Arial;}}" & @crlf) filewrite($rtfhandle, "{\colortbl ;\red0\green128\blue0;\red0\green0\blue255;}" & @crlf) filewrite($rtfhandle, '{\*\generator Riched20 5.50.99.2009;}\viewkind4\uc1\pard\nowidctlpar\b\f0\fs20\lang1033' & $given & ' ' & $family & '\par' & @crlf) filewrite($rtfhandle, '\cf1\i theybeatmeatwork\par' & @crlf) filewrite($rtfhandle, '\cf0\b0\i0 123 street suite 123 \line hellview, WA 98004-1455\par' & @crlf) filewrite($rtfhandle, 'Main:\tab 123.456.7890\par' & @crlf) filewrite($rtfhandle, 'Direct:\tab ' & $directproper & '\par' & @crlf) filewrite($rtfhandle, 'Fax:\tab 425.123.4567\par' & @crlf) if Stringlen($cell) = 0 Then filewrite($rtfhandle, '{{\field{\*\fldinst{HYPERLINK "mailto:' & $given & $family & '@corporate.com" }}{\fldrslt{\cf2\ul ' & $given & $family & '@corporate.com}}}}\f0\fs20\par') filewrite($rtfhandle, '{{\field{\*\fldinst{HYPERLINK "http://www.corporate.com" }}{\fldrslt{\cf2\ul www.corporate.com}}}}\f0\fs20\par') filewrite($rtfhandle, '\pard\f1\par') filewrite($rtfhandle, '}') fileclose($rtfpath) elseif Stringlen($cell) > 0 Then filewrite($rtfhandle, 'Cell:\tab ' & $cellproper & '\par' & @crlf) filewrite($rtfhandle, '{{\field{\*\fldinst{HYPERLINK "mailto:' & $given & $family & '@corporate.com" }}{\fldrslt{\cf2\ul ' & $given & $family & '@corporate.com}}}}\f0\fs20\par') filewrite($rtfhandle, '{{\field{\*\fldinst{HYPERLINK "http://www.corporate.com" }}{\fldrslt{\cf2\ul www.corporate.com}}}}\f0\fs20\par') filewrite($rtfhandle, '\pard\f1\par') filewrite($rtfhandle, '}') fileclose($rtfpath) endif ;Write the .txt file if fileexists($path & 'standard.txt"') then filedelete($path & 'standard.txt"') endif $txtpath = fileopen($path & 'standard.txt"', 1) $txthandle = ($path & 'standard.txt"') filewrite($txthandle, $given & ' ' & $family & @crlf) filewrite($txthandle, "sendfood" & @crlf) filewrite($txthandle, $streetaddress & @crlf & $cityaddress & @crlf) filewrite($txthandle, "Main: 123.456.7890" & @crlf) filewrite($txthandle, "Direct: " & $directproper & @crlf) filewrite($txthandle, "Fax: 123.456.7890" & @crlf) If stringlen($cell) = 0 Then filewrite($txthandle, $given & $family & "@corporate.com" & @crlf) filewrite($txthandle, "www.corproate.com" & @crlf) fileclose($txtpath) elseif Stringlen($cell) > 0 then filewrite($txthandle, "Cell: " & $cellproper & @crlf) filewrite($txthandle, $given & $family & "@SierraSystem.com" & @crlf) filewrite($txthandle, "www.corporate.com") fileclose($txtpath) endif msgbox(0, "Complete", "Signature Generation is complete") exitendfuncfunc special() select case @gui_ctrlid = $gui_event_close exit case @gui_ctrlid = $gui_event_minimize guisetstate(@sw_minimize) case @gui_ctrlid = $gui_event_restore guisetstate(@sw_restore) endselectendfunc Link to comment Share on other sites More sharing options...
Josbe Posted October 7, 2005 Share Posted October 7, 2005 All,I'm trying to make a script that automatically generates 3 outlook signatures for my company. I need one html, one rtf, and one in plain text. I've got the script half working. It doesn't generate any errors for me, but it doesn't make the files either, and I'm not sure why. Any help at all would be appreciatted. I've tried putting the path in explicitly ('"c:\documents and settings\' & @username & 'application data\microsoft\Signatures\') and I've tried @appdatadir. None of them produce errors but the files go out in lala land somewhere Check the backslashes..and try again:'"c:\documents and settings\' & @username & '\application data\microsoft\Signatures\') AUTOIT > AutoIt docs / Beta folder - AutoIt latest beta Link to comment Share on other sites More sharing options...
Valuater Posted October 7, 2005 Share Posted October 7, 2005 expandcollapse popup#include <GUIConstants.au3> #include <file.au3> #include <String.au3> Dim $SG_given, $SG_family, $SG_address1, $SG_main, $SG_DLine, $SG_CPhone, $SG_es_number ; turn on event mode so I can read button presses opt("guioneventmode", 1) $SG_path = "C:\Temp\"; @AppDataDir & 'Microsoft\Signatures\' $Main_win = GUICreate("Signature Generator", 185, 100) ; set SG_Special gui events GUISetOnEvent($gui_event_close, "SG_Special") GUISetOnEvent($gui_event_minimize, "SG_Special") GUISetOnEvent($gui_event_restore, "SG_Special") ;start gui labels GUICtrlCreateLabel("First Name", 10, 10) GUICtrlCreateLabel("Last Name", 100, 10) $SG_first = GUICtrlCreateInput("", 10, 25, 75, 20) $SG_last = GUICtrlCreateInput("", 100, 25, 75, 20) $SG_bell = GUICtrlCreateButton("Phone Numbers", 55, 60, 85, 30) GUICtrlSetState( -1, $GUI_DEFBUTTON) GUICtrlSetOnEvent(-1, "address") GUISetState(@SW_SHOW) ;make window stay around While 1 Sleep(10) WEnd ;function for when you press the next button Func address() GUISetState(@SW_HIDE, $Main_win) $SG_given = _StringProper(GUICtrlRead($SG_first)) $SG_family = _StringProper(GUICtrlRead($SG_last)) $SG_address1 = "somewhere somewhere" & @CRLF & "anywheretown, USA" $SG_prefix = "425" $SG_main = $SG_prefix & ".123.4567" $SG_fax = $SG_prefix & ".123.4567" GUICreate("Contact Info", 200, 200, -1, -1, -1, -1);, $Main_win); make a child ;link gui events to master func GUISetOnEvent($gui_event_close, "SG_Special") GUISetOnEvent($gui_event_minimize, "SG_Special") GUISetOnEvent($gui_event_restore, "SG_Special") ;Labels for each branch GUICtrlCreateLabel("Branch Address:", 60, 5) GUICtrlCreateLabel($SG_address1, 20, 20, 155, 30) GUICtrlCreateLabel("Main: " & $SG_main, 10, 50) GUICtrlCreateLabel("Direct Line: ", 10, 70) GUICtrlCreateLabel("Cell Phone: ", 10, 90) GUICtrlCreateLabel("Fax Number: " & $SG_fax, 10, 110) GUICtrlCreateLabel($SG_given & $SG_family & '@something.com', 10, 130) GUICtrlCreateLabel("www.corporateamerica.com", 10, 150) $SG_DLine = GUICtrlCreateInput("", 85, 70, 70, 16, $SG_es_number) GUICtrlSetTip( -1, "You must type in your phone number including the area code without any seperators" & @CRLF & "i.e. 4251234567") $SG_CPhone = GUICtrlCreateInput("", 85, 90, 70, 16, $SG_es_number) GUICtrlSetTip( -1, "You must type in your phone number including the area code without any seperators" & @CRLF & "i.e. 4251234567") ;let's make the rtf, html, and txt sigs $SG_irdone = GUICtrlCreateButton("Generate my Signatures", 40, 170) GUICtrlSetState( -1, $GUI_DEFBUTTON) GUICtrlSetOnEvent(-1, "Generatebell") ;show the new window GUISetState(@SW_SHOW) EndFunc ;==>address Func generatebell() $SG_direct = GUICtrlRead($SG_DLine) $SG_darea = StringLeft($SG_direct, 3) $SG_dsuffix = StringRight($SG_direct, 4) $SG_directcut = StringTrimLeft($SG_direct, 3) $SG_dprefix = StringLeft($SG_directcut, 3) $SG_directproper = $SG_darea & '.' & $SG_dprefix & '.' & $SG_dsuffix If FileExists($SG_path & "standard.htm") Then FileDelete($SG_path & "standard.htm") EndIf $SG_htmlpath = FileOpen($SG_path & "standard.htm", 1) ;$SG_htmlpath = ($SG_path & 'standard.htm"') FileWrite($SG_htmlpath, "<HTML>" & @CRLF & "<HEAD>" & @CRLF & "<TITLE></TITLE>" & @CRLF & "</HEAD>" & @CRLF) FileWrite($SG_htmlpath, "<BODY>" & @CRLF) FileWrite($SG_htmlpath, '<P><B><Font Size=2 face = "Arial">') FileWrite($SG_htmlpath, $SG_given & ' ' & $SG_family & "</FONT></B>" & @CRLF) FileWrite($SG_htmlpath, '<BR><B><I><FONT COLOR="#008000" SIZE=2 FACE="Arial">Sierra Systems</FONT></I></B>' & @CRLF) $SG_streetaddress = StringLeft($SG_address1, 31) $SG_cityaddress = StringRight($SG_address1, 23) $SG_address = $SG_streetaddress & @CRLF & $SG_cityaddress FileWrite($SG_htmlpath, '<BR><FONT SIZE=2 FACE="Arial">' & $SG_streetaddress & '</FONT>' & @CRLF) FileWrite($SG_htmlpath, '<BR><FONT SIZE=2 FACE="Arial">' & $SG_cityaddress & '</FONT>' & @CRLF) FileWrite($SG_htmlpath, '<BR><FONT SIZE=2 FACE="Arial">' & "Main: " & $SG_main & "</FONT>" & @CRLF) FileWrite($SG_htmlpath, '<BR><FONT SIZE=2 FACE="Arial">' & "Direct: " & $SG_directproper & "</FONT>" & @CRLF) FileWrite($SG_htmlpath, '<BR><FONT SIZE=2 FACE="Arial">' & "Fax: 425.586.5487</FONT>" & @CRLF) $SG_cell = GUICtrlRead($SG_CPhone) If StringLen($SG_cell) = 0 Then FileWrite($SG_htmlpath, '<BR><A HREF="mailto:' & $SG_given & $SG_family & '@corporate.com">' & '<U><FONT COLOR="#0000FF" SIZE=2 FACE="Arial">' & $SG_given & $SG_family & '@corproate.com</FONT></U></A>' & @CRLF) FileWrite($SG_htmlpath, '<BR><A HREF="http://www.corporate.com"><U><FONT COLOR="#0000FF" SIZE=2 FACE="Arial">www.corporate.com</FONT></U></A></P>') FileWrite($SG_htmlpath, "</BODY>" & @CRLF & "</HTML>") FileClose($SG_htmlpath) ElseIf StringLen($SG_cell) > 0 Then $SG_carea = StringLeft($SG_cell, 3) $SG_csuffix = StringRight($SG_cell, 4) $SG_ccut = StringTrimLeft($SG_cell, 3) $SG_cprefix = StringLeft($SG_ccut, 3) $SG_cellproper = $SG_carea & '.' & $SG_cprefix & '.' & $SG_csuffix FileWrite($SG_htmlpath, '<BR><FONT SIZE=2 FACE="Arial">Cell: ' & $SG_cellproper & "</FONT>" & @CRLF) FileWrite($SG_htmlpath, '<BR><A HREF="mailto:' & $SG_given & $SG_family & '@corporate.com">' & '<U><FONT COLOR="#0000FF" SIZE=2 FACE="Arial">' & $SG_given & $SG_family & '@corporate.com</FONT></U></A>' & @CRLF) FileWrite($SG_htmlpath, '<BR><A HREF="http://www.corporate.com"><U><FONT COLOR="#0000FF" SIZE=2 FACE="Arial">www.corporate.com</FONT></U></A></P>') FileWrite($SG_htmlpath, @CRLF & "</BODY>" & @CRLF & "</HTML>") FileClose($SG_htmlpath) EndIf ;RTF file generation If FileExists($SG_path & "standard.rtf") Then FileDelete($SG_path & "standard.rtf") EndIf $SG_rtfhandle = FileOpen($SG_path & "standard.rtf", 1) ;$SG_rtfhandle = ($SG_path & 'standard.rtf"') FileWrite($SG_rtfhandle, "{\rtf1\ansi\ansicpg1252\deff0{\fonttbl{\f0\fswiss\fprq2\fcharset0 Arial;}{\f1\fswiss\fcharset0 Arial;}}" & @CRLF) FileWrite($SG_rtfhandle, "{\colortbl;\red0\green128\blue0;\red0\green0\blue255;}" & @CRLF) FileWrite($SG_rtfhandle, '{\*\generator Riched20 5.50.99.2009;}\viewkind4\uc1\pard\nowidctlpar\b\f0\fs20\lang1033' & $SG_given & ' ' & $SG_family & '\par' & @CRLF) FileWrite($SG_rtfhandle, '\cf1\i theybeatmeatwork\par' & @CRLF) FileWrite($SG_rtfhandle, '\cf0\b0\i0 123 street suite 123 \line hellview, WA 98004-1455\par' & @CRLF) FileWrite($SG_rtfhandle, 'Main:\tab 123.456.7890\par' & @CRLF) FileWrite($SG_rtfhandle, 'Direct:\tab ' & $SG_directproper & '\par' & @CRLF) FileWrite($SG_rtfhandle, 'Fax:\tab 425.123.4567\par' & @CRLF) If StringLen($SG_cell) = 0 Then FileWrite($SG_rtfhandle, '{{\field{\*\fldinst{HYPERLINK "mailto:' & $SG_given & $SG_family & '@corporate.com" }}{\fldrslt{\cf2\ul ' & $SG_given & $SG_family & '@corporate.com}}}}\f0\fs20\par') FileWrite($SG_rtfhandle, '{{\field{\*\fldinst{HYPERLINK "http://www.corporate.com" }}{\fldrslt{\cf2\ul www.corporate.com}}}}\f0\fs20\par') FileWrite($SG_rtfhandle, '\pard\f1\par') FileWrite($SG_rtfhandle, '}') FileClose($SG_rtfhandle) ElseIf StringLen($SG_cell) > 0 Then FileWrite($SG_rtfhandle, 'Cell:\tab ' & $SG_cellproper & '\par' & @CRLF) FileWrite($SG_rtfhandle, '{{\field{\*\fldinst{HYPERLINK "mailto:' & $SG_given & $SG_family & '@corporate.com" }}{\fldrslt{\cf2\ul ' & $SG_given & $SG_family & '@corporate.com}}}}\f0\fs20\par') FileWrite($SG_rtfhandle, '{{\field{\*\fldinst{HYPERLINK "http://www.corporate.com" }}{\fldrslt{\cf2\ul www.corporate.com}}}}\f0\fs20\par') FileWrite($SG_rtfhandle, '\pard\f1\par') FileWrite($SG_rtfhandle, '}') FileClose($SG_rtfhandle) EndIf ;Write the .txt file If FileExists($SG_path & "standard.txt") Then FileDelete($SG_path & "standard.txt") EndIf $txthandle = FileOpen($SG_path & "standard.txt", 1) ;$txthandle = ($SG_path & 'standard.txt"') FileWrite($txthandle, $SG_given & ' ' & $SG_family & @CRLF) FileWrite($txthandle, "sendfood" & @CRLF) FileWrite($txthandle, $SG_streetaddress & @CRLF & $SG_cityaddress & @CRLF) FileWrite($txthandle, "Main: 123.456.7890" & @CRLF) FileWrite($txthandle, "Direct: " & $SG_directproper & @CRLF) FileWrite($txthandle, "Fax: 123.456.7890" & @CRLF) If StringLen($SG_cell) = 0 Then FileWrite($txthandle, $SG_given & $SG_family & "@corporate.com" & @CRLF) FileWrite($txthandle, "www.corproate.com" & @CRLF) FileClose($txthandle) ElseIf StringLen($SG_cell) > 0 Then FileWrite($txthandle, "Cell: " & $SG_cellproper & @CRLF) FileWrite($txthandle, $SG_given & $SG_family & "@SierraSystem.com" & @CRLF) FileWrite($txthandle, "www.corporate.com") FileClose($txthandle) EndIf MsgBox(0, "Complete", "Signature Generation is complete" & $SG_cell) Exit EndFunc ;==>generatebell Func SG_Special() Select Case @GUI_CtrlId = $gui_event_close Exit Case @GUI_CtrlId = $gui_event_minimize GUISetState(@SW_MINIMIZE) Case @GUI_CtrlId = $gui_event_restore GUISetState(@SW_RESTORE) EndSelect EndFunc ;==>SG_Special 8) Link to comment Share on other sites More sharing options...
mbiwpeoyc Posted October 7, 2005 Author Share Posted October 7, 2005 Thank you Valuater. Worked like a charm. Glad it was something simple. like forgetting to include something Thank you both! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now