Jump to content
Sign in to follow this  
nhardel

User Rights with GUI

Recommended Posts

nhardel

Could some one please assist me with this code. I am having two issues.

1. I use fileinstall to push two gifs and a jpg with my compiled script. It works flawlessly if the user is an admin of the workstation, but does not display the pictures in the gui if the user has only basic rights. I know that the pictures are being placed in the users temp folder regardless of permissions (%userprofile%\Local Settings\TEMP\)

2. The send button seems to be disabled in a restricted account. Again everything seems to work if user has admin rights to the workstation otherwise the Button does not work.

The enviroment is on a 2003 network domain with users running win2000 clients. Compiled script is running from a network storage, but seems to be executing everything from a local standpoint.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=nestle.exe
#AutoIt3Wrapper_UseAnsi=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <INet.au3>
#include <DateTimeConstants.au3>
#include <ButtonConstants.au3>

#Region ### Define variables ###
Global $address
Global $body
Global $subject
Global $ITRequest_read
Global $MealRequest_read
Global $TourRequest_read
Global $POC1_read
Global $POC2_read
Global $POC1_Tel_read
Global $POC2_Tel_read
Global $Company_Input_read
Global $Visitor_Names_read
Global $Start_Date_read
Global $End_Date_read
Global $Arrival_Time_read
Global $Meeting_Location_read
Global $Easel_read
Global $Projector_read
Global $Flip_Charts_read
Global $Audio_Equipment_read
Global $MealRequest_read
Global $MealRequestAttendees_read
Global $MealRequestTime_read
Global $MealRequestEdit_read
Global $ITRequest_read
Global $ITRequestEdit_read
Global $ITRequestEmail
Global $TourRequest_read
Global $TourRequestEdit_read
Global $TourRequestAudio_read
#EndRegion ### END Define Variables ###


;Uncompress and installs pics in user's temp folder
$nesquik = @TempDir &"\Nesquik_logo.jpg"
$nestle = @TempDir &"\Nestle_logo.gif"
$coffee = @TempDir &"\Coffee_Mate_logo.gif"
fileinstall("Nesquik_logo.jpg", $nesquik)
fileinstall("Nestle_logo.gif", $nestle)
fileinstall("Coffee_Mate_logo.gif", $coffee)

 ; to select a specific default format
If @AutoItUnicode Then
        $DTM_SETFORMAT_ = 0x1032
    Else
        $DTM_SETFORMAT_ = 0x1005
    EndIf
        
#Region ### START Koda GUI section ### Form=c:\program files\special\autoit3\koda\forms\nestlé anderson visitor notification form.kxf
$Form1_1 = GUICreate("Nestlé Anderson Visitor Notification Form", 843, 652, 300, 200)
GUISetFont(12, 400, 0, "Arial")
GUISetBkColor(0xFFFFFF)

$Label1 = GUICtrlCreateLabel("Name of Visitors", 6, 168, 129, 23)
GUICtrlSetFont(-1, 12, 800, 0, "Arial")

$POC1 = GUICtrlCreateInput("Your name", 333, 64, 121, 26)
GUICtrlSetTip(-1, "Name of Contact for Security to reach")

$POC1_Tel = GUICtrlCreateInput("Your Extension", 501, 64, 121, 26)
GUICtrlSetTip(-1, "Telephone# of contact for Security to call")

$POC2 = GUICtrlCreateInput("Alternative", 333, 96, 121, 26)
GUICtrlSetTip(-1, "Name of Contact for Security to reach")

$POC2_Tel = GUICtrlCreateInput("Extension", 501, 96, 121, 26)
GUICtrlSetTip(-1, "Telephone# of contact for Security to call")

$Company_Input = GUICtrlCreateInput("Company Name", 142, 136, 241, 26)

$Visitor_Names = GUICtrlCreateEdit("", 142, 168, 241, 105, BitOR($ES_AUTOVSCROLL,$ES_WANTRETURN,$WS_VSCROLL))
GUICtrlSetData(-1, "Visitors Names")

$Start_Date = GUICtrlCreateDate("2008/07/23 11:30:27", 430, 176, 114, 26, $WS_TABSTOP)

$End_Date = GUICtrlCreateDate("2008/07/23 11:32:41", 654, 176, 114, 26, $WS_TABSTOP)

$Arrival_Time = GUICtrlCreateDate("12:00", 630, 232, 98, 26, BitOR($DTS_UPDOWN,$DTS_TIMEFORMAT,$WS_TABSTOP))
GUICtrlSendMsg(-1, $DTM_SETFORMAT_, 0, "h:mm ttt")

$Easel = GUICtrlCreateCheckbox("Easel", 590, 272, 97, 17)

$Flip_Charts = GUICtrlCreateCheckbox("Flip Charts", 694, 272, 145, 17)

$Projector = GUICtrlCreateCheckbox("Projector", 590, 296, 97, 17)

$Audio_Equipment = GUICtrlCreateCheckbox("Audio Equipment", 694, 296, 145, 17)

$Meeting_Location = GUICtrlCreateCombo("", 174, 296, 201, 250)
GUICtrlSetData(-1, "House|Nesquik South|Nesquik North|Juicy Juice|Nescafe|Recieving|Shipping|Nestea|Coffee-Mate East|Coffee-Mate West|Baby Ruth", "House")

$mealrequest = GUICtrlCreateCheckbox("Meal Requested", 6, 352, 145, 17)
GUICtrlSetFont(-1, 12, 800, 0, "Arial")

$MealRequestAttendees = GUICtrlCreateCombo("", 174, 384, 121, 200)
GUICtrlSetData(-1, "1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30", "1")
GUICtrlSetState(-1, $GUI_DISABLE)

$MealRequestTime = GUICtrlCreateDate("12:00", 174, 416, 122, 26, BitOR($DTS_UPDOWN,$DTS_TIMEFORMAT,$WS_TABSTOP))
GUICtrlSendMsg(-1, $DTM_SETFORMAT_ , 0, "h:mm ttt")
GUICtrlSetState(-1, $GUI_DISABLE)

$MealRequestEdit = GUICtrlCreateEdit("", 14, 472, 273, 89, BitOR($ES_AUTOVSCROLL,$ES_WANTRETURN,$WS_VSCROLL))
GUICtrlSetData(-1, StringFormat("Place any special directions for the \r\nmeal in this box."))
GUICtrlSetState(-1, $GUI_DISABLE)

$ITRequest = GUICtrlCreateCheckbox("IT Assistance", 502, 328, 129, 17)
GUICtrlSetFont(-1, 12, 800, 0, "Arial")

$ITRequestEdit = GUICtrlCreateEdit("", 654, 328, 185, 89, BitOR($ES_AUTOVSCROLL,$ES_WANTRETURN,$WS_VSCROLL))
GUICtrlSetData(-1, StringFormat("Explain why IT \r\nassistance is required \r\nin this box."))
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetTip(-1, "If checked, reason why")

$TourRequest = GUICtrlCreateCheckbox("Tour of Factory Floor", 438, 456, 193, 17)
GUICtrlSetFont(-1, 12, 800, 0, "Arial")

$TourRequestEdit = GUICtrlCreateEdit("", 654, 448, 185, 89, BitOR($ES_AUTOVSCROLL,$ES_WANTRETURN,$WS_VSCROLL))
GUICtrlSetData(-1, StringFormat("Place brief discription \r\nof your plans for the \r\ntour in this box."))
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetTip(-1, "Description of Tour needed")

$TourRequestAudio = GUICtrlCreateCheckbox("Tour Audio Gear", 656, 544, 153, 17)
GUICtrlSetState(-1, $GUI_DISABLE)

$Send = GUICtrlCreateButton("Send", 592, 592, 100, 30, 0)
GUICtrlSetState(-1, $gui_enable)

$Nesquik_Pic = GUICtrlCreatePic("C:\Documents and Settings\usametjas\Desktop\New Folder (2)\Nesquik_logo.jpg", 0, 0, 100, 100, 0)
GUICtrlSetState(-1, $GUI_DISABLE)

$Coffee_Pic = GUICtrlCreatePic("C:\Documents and Settings\usametjas\Desktop\New Folder (2)\Coffee_Mate_Logo.gif", 736, 0, 100, 100, 0)
GUICtrlSetState(-1, $GUI_DISABLE)

$Nestle_Pic = GUICtrlCreatePic("C:\Documents and Settings\usametjas\Desktop\New Folder (2)\Nestle_logo.gif", 6, 584, 417, 62, 0)
GUICtrlSetState(-1, $GUI_DISABLE)

$Label2 = GUICtrlCreateLabel("Company", 30, 136, 78, 23)
GUICtrlSetFont(-1, 12, 800, 0, "Arial")

$Label3 = GUICtrlCreateLabel("Approximate arrival time", 414, 240, 188, 23)
GUICtrlSetFont(-1, 12, 800, 0, "Arial")

$Label5 = GUICtrlCreateLabel("Location of Meeting", 6, 296, 154, 23)
GUICtrlSetFont(-1, 12, 800, 0, "Arial")

$Label6 = GUICtrlCreateLabel("Equipment Needed:", 414, 280, 156, 23)
GUICtrlSetFont(-1, 12, 800, 0, "Arial")

$Label8 = GUICtrlCreateLabel("If checked, reasons why", 502, 344, 125, 18)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")

$Label12 = GUICtrlCreateLabel("Number of Attendees", 14, 392, 151, 22)
GUICtrlSetState(-1, $GUI_DISABLE)

$Label13 = GUICtrlCreateLabel("Time to be Delivered", 14, 424, 149, 22)
GUICtrlSetState(-1, $GUI_DISABLE)

$Label7 = GUICtrlCreateLabel("Nestlé Anderson Visitor Notification Form", 184, 16, 483, 33)
GUICtrlSetFont(-1, 18, 800, 0, "Arial")
GUICtrlSetBkColor(-1, 0x0000FF)

$Label9 = GUICtrlCreateLabel("Details for meal", 14, 448, 113, 22)

$Label10 = GUICtrlCreateLabel("If checked, give details of tour", 438, 472, 149, 18)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")

$Label11 = GUICtrlCreateLabel("Contact", 229, 64, 58, 22)
GUICtrlSetTip(-1, "First Point of Contact")

$Label14 = GUICtrlCreateLabel("Alt. Contact", 229, 96, 84, 22)
GUICtrlSetTip(-1, "Second Point of Contact")

$Label15 = GUICtrlCreateLabel("Beginning date of visit", 414, 144, 174, 23)
GUICtrlSetFont(-1, 12, 800, 0, "Arial")

$Label16 = GUICtrlCreateLabel("Ending date  of visit", 638, 144, 154, 23)
GUICtrlSetFont(-1, 12, 800, 0, "Arial")

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $ITRequest
            $state = BitAnd(GUICtrlRead($ITRequest),$GUI_CHECKED)
            if $state = 1 Then
                GUICtrlSetState($ITRequestEdit, $gui_enable)
                $ITRequestEmail = 1
            else 
                GUICtrlSetState($ITRequestEdit, $gui_disable)
                GUICtrlSetData($ITRequestEdit, "Explain why IT assistance is required in this box.")
                $ITRequestEmail = 0
            EndIf
        Case $TourRequest
            $state = BitAnd(GUICtrlRead($TourRequest),$GUI_CHECKED)
            if $state = 1 Then
                GUICtrlSetState($TourRequestEdit, $gui_enable)
                GUICtrlSetState($TourRequestAudio, $gui_enable)
            else 
                GUICtrlSetState($TourRequestEdit, $gui_disable)
                GUICtrlSetState($TourRequestAudio, $gui_disable)
                GUICtrlSetState($TourRequestAudio, $GUI_UNCHECKED)
                GUICtrlSetData($TourRequestEdit, "Place brief discription of your plans for the tour in this box.")
            EndIf
        Case $MealRequest
            $state = BitAnd(GUICtrlRead($MealRequest),$GUI_CHECKED)
            if $state = 1 Then
                GUICtrlSetState($MealRequestEdit, $gui_enable)
                GUICtrlSetState($MealRequestTime, $gui_enable)
                GUICtrlSetState($MealRequestAttendees, $gui_enable)
            else 
                GUICtrlSetState($MealRequestEdit, $gui_disable)
                GUICtrlSetState($MealRequestTime, $gui_disable)
                GUICtrlSetState($MealRequestAttendees, $gui_disable)
                GUICtrlSetData($MealRequestEdit, "Place any special directions for the meal in this box.")
                GUICtrlSetData($MealRequestAttendees, "0")
                GUICtrlSetData($MealRequestTime, "12:00 PM")
            EndIf
        Case $Send
            Sendemail()
            Exit
    EndSwitch
WEnd

Func _readGUI()
    $POC1_read = GUICtrlRead ($POC1)
    $POC1_Tel_read = GuiCtrlRead($POC1_Tel)
    $POC2_read = GUICtrlRead ($POC2)
    $POC2_Tel_read = GUICtrlRead($POC2_Tel)
    $Visitor_Names_read = GUICtrlRead($Visitor_Names)
    $Company_Input_read = GUICtrlRead($Company_Input)
    $Start_Date_read = GUICtrlRead($Start_Date)
    $End_Date_read = GUICtrlRead($End_Date)
    $Arrival_Time_read = GUICtrlRead($Arrival_Time)
    $Meeting_Location_read = GUICtrlRead($Meeting_Location)

    $state = BitAnd(GUICtrlRead($Easel),$GUI_CHECKED)
    if $state = 1 Then
        $Easel_read = "Easel is needed"
    else 
        $Easel_read = "Easel is not needed"
    EndIf

    $state = BitAnd(GUICtrlRead($Flip_Charts),$GUI_CHECKED)
    if $state = 1 Then
        $Flip_Charts_read = "Flip Charts are needed"
    else 
        $Flip_Charts_read = "Flip Charts are not needed"
    EndIf
    
    $state = BitAnd(GUICtrlRead($Projector),$GUI_CHECKED)
    if $state = 1 Then
        $Projector_read = "Projector is needed"
    else 
        $Projector_read = "Projector is not needed"
    EndIf
    
    $state = BitAnd(GUICtrlRead($Audio_Equipment),$GUI_CHECKED)
    if $state = 1 Then
        $Audio_Equipment_read = "Audio Equipment is needed"
    else 
        $Audio_Equipment_read = "Audio Equipment is not needed"
    EndIf
EndFunc

Func _readmealrequest()
    $state = BitAnd(GUICtrlRead($MealRequest),$GUI_CHECKED)
    if $state = 1 Then
        $MealRequestAttendees_read = GUICtrlRead($MealRequestAttendees)
        $MealRequestTime_read = guictrlread($MealRequestTime)
        $MealRequestEdit_read = GUICtrlRead($MealRequestEdit)
        $MealRequest_read = "" 
        $MealRequest_read &= "A meal is being requested.  Please make sure there is enough for " & $MealRequestAttendees_read & " people." & @CR
        $MealRequest_read &= "Please have the meal delivered by " & $MealRequestTime_read &"." & @CR
        $MealRequest_read &= "Additional Information regarding the meal:" & @CR
        $MealRequest_read &= $MealRequestEdit_read &@CRLF
    else 
        $MealRequest_read = "A meal is not required for this visit." & @CRLF
    EndIf
EndFunc

Func _readITrequest()
    $state = BitAnd(GUICtrlRead($ITRequest),$GUI_CHECKED)
    if $state = 1 Then
        $ITRequestEdit_read = GUICtrlRead($ITRequestEdit)
        $ITRequest_read = "IT assistance is required for the following reasons:" & @CR
        $ITRequest_read &= $ITRequestEdit_read & @CRLF
    else 
        $ITRequest_read = "IT assistance is not required." & @CRLF
    EndIf
EndFunc 

Func _readtourrequest()
$state = BitAND(guictrlread($TourRequestAudio),$GUI_CHECKED)
    if $state = 1 Then
        $TourRequestAudio_read = "required."
    else 
        $TourRequest_read = "not required."
    EndIf
$state = BitAnd(GUICtrlRead($TourRequest),$GUI_CHECKED)
    if $state = 1 Then
        $TourRequestEdit_read = GUICtrlRead($TourRequestEdit)
        $TourRequest_read = "A tour is requested.  The following are tour details:" & @CR
        $TourRequest_read &= $TourRequestEdit_read & @CR
        $TourRequest_read &= "Tour Audio Equipment is " & $TourRequestAudio_read & @crlf
    else 
        $ITRequest_read = "A tour is not required for this visit." & @CRLF
    EndIf
EndFunc 

Func _BuildEmail_mailto()
    If $ITRequestEmail = 1 Then 
        $address = "test1"
    Else 
        $address = "test2"
    EndIf
EndFunc

Func _BuildEmail_subject()
    $subject = "Visitor Request Form"
EndFunc

Func _BuildEmail_body()
    _readGUI()
    _readmealrequest()
    _readITrequest()
    _readtourrequest()  
    $body = ""
    $body &= "Nestlé Anderson Visitor Notification Form.  " 
    $body &= "The following visitors from " & $Company_Input_read &" will be arriving " & $Start_Date_read & "." &@CR
    $body &= $Visitor_Names_read & @CRLF
    $body &= "It is intended to meet at the following location: " & $Meeting_Location_read & @CR
    $body &= "The following equipment may be required for this meeting:" & @CR
    $body &= $Easel_read & @CR
    $body &= $Flip_Charts_read & @CR
    $body &= $Projector_read & @CR
    $body &= $Audio_Equipment_read & @CRLF
    $body &= "Meal Request Info" & @CR
    $body &= $MealRequest_read & @CR
    $body &= "IT Assistance Request" & @CR
    $body &= $ITRequest_read & @CR
    $body &= "Tour of Factory Floor Request" & @CR
    $body &= $TourRequest_read &@CRLF
EndFunc

Func Sendemail()
    _BuildEmail_mailto()
    _BuildEmail_subject()
    _BuildEmail_body()
    $email = _INetMail($address, $subject, $body)
EndFunc

If these fuctions do require admin rights, I will make do with out the pics but, the send button is a little bit more of a nessesity. Any help would be appreciated.

Edited by nhardel

Share this post


Link to post
Share on other sites
nhardel

Update:

I compliled the default test example of GUICtrlCreatButton and ran it from the same location as my form is being run from. It does work so I not sure its a permissions thing now. But there is something different about these two scripts in how they are running the button in the gui.

muttley

Okay Im a dumbass I still had the pictures pointing to a local address on my computer that fixed that issue

as for the send button I declared all variables and did a second guisetctrl to the button and enabled it again everything works

(to the developers not sure about the button thing possible a glitch then again I screwed up the picture problem on my own)

Edited by nhardel

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.