roc Posted June 22, 2010 Share Posted June 22, 2010 I have made a script that will login to a website, navigate to the appropriate page and input a date in the field and press the enter button for me. (Background- At my work we have to request leave online, there is very stiff competition sense we can only submit our leave one year in advance. So many people stay up to midnight to put in for leave a year out. I made a script to do it for me. Now I want to get a GUI for it) I have made the GUI that allows me to select the date I want and to put in the password for the website. I just cant get the GUI and the script to work together. Can someone lead me in the right direction? I have no idea what I’m doing. I have included the script and the GUI bellow, Thank you for your time. GUI, #include <ButtonConstants.au3> #include <DateTimeConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form=c:\users\boss\desktop\form2.kxf $Form2 = GUICreate("ALR", 265, 245, 320, 253) GUISetIcon("D:\004.ico") $Button1 = GUICtrlCreateButton("&Get my leave", 94, 187, 75, 25, $WS_GROUP) GUIStartGroup() $Date2 = GUICtrlCreateDate("2010/06/21 17:58:58", 48, 32, 186, 21) $Label2 = GUICtrlCreateLabel("Date you would like leave", 72, 72, 126, 17) $Input1 = GUICtrlCreateInput("", 72, 120, 121, 21) $Label1 = GUICtrlCreateLabel("Password", 104, 152, 50, 17) GUIStartGroup() GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Script, #cs ---------------------------------------------------------------------------- Author: Justin Script Function: ALR- Auto Leave Request start 14 seconds prior to the hour #ce ---------------------------------------------------------------------------- ; Script Start - Leave request code #include<IE.au3> $sUsername = "My user name" $sPassword = "my password" $sUrl = "https://website.com" $oIE = _IECreate($sUrl, 0, 1, 0, 1) Sleep(2000) $oHWND = _IEPropertyGet($oIE, "hwnd") WinSetState($oHWND, "", @SW_MAXIMIZE) $oForm = _IEFormGetCollection($oIE, 0) $oUsername = _IEFormElementGetObjByName($oForm, 'hprLogin$adUserName') $oPassword = _IEFormElementGetObjByName($oForm, "hprLogin$adPass") _IEFormElementSetValue($oUsername, $sUsername) _IEFormElementSetValue($oPassword, $sPassword) Sleep(500) MouseClick( "left" , 500, 500 ) Sleep(500) Send("{tab}") Send("{ENTER}") Sleep(6000) _IENavigate ($oIE, "https://thewebsite.com") Sleep(4000) MouseClick( "left" , 400, 500 ) Sleep(200) #include<IE.au3> $sDate = "06/29/2011" $oHWND = _IEPropertyGet($oIE, "hwnd") WinSetState($oHWND, "", @SW_MAXIMIZE) $oForm = _IEFormGetCollection($oIE, 0) $oDate1 = _IEFormElementGetObjByName($oForm, "date1") $oDate2 = _IEFormElementGetObjByName($oForm, "date2") _IEFormElementSetValue($oDate1, $sDate) _IEFormElementSetValue($oDate2, $sDate) Sleep(200) MouseClick( "left" , 500, 500 ) Sleep(200) Send("{ENTER}") Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 22, 2010 Moderators Share Posted June 22, 2010 roc, Double posting like this is frowned upon here. Please do not do it again. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Fossil Rock Posted June 22, 2010 Share Posted June 22, 2010 (edited) Line 32... either put a ; in front of it or remove it to get the GUI to appear.I have made a script that will login to a website, navigate to the appropriate page and input a date in the field and press the enter button for me. (Background- At my work we have to request leave online, there is very stiff competition sense we can only submit our leave one year in advance. So many people stay up to midnight to put in for leave a year out. I made a script to do it for me. Now I want to get a GUI for it)I have made the GUI that allows me to select the date I want and to put in the password for the website. I just cant get the GUI and the script to work together. Can someone lead me in the right direction? I have no idea what I’m doing. I have included the script and the GUI bellow, Thank you for your time.GUI,#include <ButtonConstants.au3>#include <DateTimeConstants.au3>#include <EditConstants.au3>#include <GUIConstantsEx.au3>#include <StaticConstants.au3>#include <WindowsConstants.au3>#Region ### START Koda GUI section ### Form=c:\users\boss\desktop\form2.kxf$Form2 = GUICreate("ALR", 265, 245, 320, 253)GUISetIcon("D:\004.ico")$Button1 = GUICtrlCreateButton("&Get my leave", 94, 187, 75, 25, $WS_GROUP)GUIStartGroup()$Date2 = GUICtrlCreateDate("2010/06/21 17:58:58", 48, 32, 186, 21)$Label2 = GUICtrlCreateLabel("Date you would like leave", 72, 72, 126, 17)$Input1 = GUICtrlCreateInput("", 72, 120, 121, 21)$Label1 = GUICtrlCreateLabel("Password", 104, 152, 50, 17)GUIStartGroup()GUISetState(@SW_SHOW)#EndRegion ### END Koda GUI section ###While 1$nMsg = GUIGetMsg()Switch $nMsgCase $GUI_EVENT_CLOSEExitEndSwitchWEndScript, <<<<<<<<<<<<#cs ---------------------------------------------------------------------------- Author: Justin Script Function: ALR- Auto Leave Request start 14 seconds prior to the hour#ce ----------------------------------------------------------------------------; Script Start - Leave request code#include<IE.au3>$sUsername = "My user name"$sPassword = "my password"$sUrl = "https://website.com"$oIE = _IECreate($sUrl, 0, 1, 0, 1)Sleep(2000)$oHWND = _IEPropertyGet($oIE, "hwnd")WinSetState($oHWND, "", @SW_MAXIMIZE)$oForm = _IEFormGetCollection($oIE, 0)$oUsername = _IEFormElementGetObjByName($oForm, 'hprLogin$adUserName')$oPassword = _IEFormElementGetObjByName($oForm, "hprLogin$adPass")_IEFormElementSetValue($oUsername, $sUsername)_IEFormElementSetValue($oPassword, $sPassword)Sleep(500)MouseClick( "left" , 500, 500 )Sleep(500)Send("{tab}")Send("{ENTER}")Sleep(6000)_IENavigate ($oIE, "https://thewebsite.com")Sleep(4000)MouseClick( "left" , 400, 500 )Sleep(200)#include<IE.au3>$sDate = "06/29/2011"$oHWND = _IEPropertyGet($oIE, "hwnd")WinSetState($oHWND, "", @SW_MAXIMIZE)$oForm = _IEFormGetCollection($oIE, 0)$oDate1 = _IEFormElementGetObjByName($oForm, "date1")$oDate2 = _IEFormElementGetObjByName($oForm, "date2")_IEFormElementSetValue($oDate1, $sDate)_IEFormElementSetValue($oDate2, $sDate)Sleep(200)MouseClick( "left" , 500, 500 )Sleep(200)Send("{ENTER}") Edited June 22, 2010 by Fossil Rock Agreement is not necessary - thinking for one's self is! Link to comment Share on other sites More sharing options...
Zedna Posted June 22, 2010 Share Posted June 22, 2010 Use Func ... EndFunc like this: expandcollapse popup#include <ButtonConstants.au3> #include <DateTimeConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GuiDateTimePicker.au3> #include <IE.au3> #Region ### START Koda GUI section ### Form=c:\users\boss\desktop\form2.kxf $Form2 = GUICreate("ALR", 265, 245, 320, 253) GUISetIcon("D:\004.ico") $Button1 = GUICtrlCreateButton("&Get my leave", 94, 187, 75, 25, $WS_GROUP) GUIStartGroup() $Date2 = GUICtrlCreateDate("2010/06/21", 48, 32, 186, 21) $hDTP = GUICtrlGetHandle($Date2) _GUICtrlDTP_SetFormat($hDTP, "yyyy/MM/dd") $Label2 = GUICtrlCreateLabel("Date you would like leave", 72, 72, 126, 17) $Input1 = GUICtrlCreateInput("", 72, 120, 121, 21) ; password $Label1 = GUICtrlCreateLabel("Password", 104, 152, 50, 17) GUIStartGroup() GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 ; pass date,password as parameters of function MyLeave(GUICtrlRead($Date2), GUICtrlRead($Input1)) EndSwitch WEnd Exit #cs ---------------------------------------------------------------------------- Author: Justin Script Function: ALR- Auto Leave Request start 14 seconds prior to the hour #ce ---------------------------------------------------------------------------- ; Script Start - Leave request code Func MyLeave($sDate, $sPassword) $sUsername = "My user name" ;~ $sPassword = "my password" $sUrl = "https://website.com" $oIE = _IECreate($sUrl, 0, 1, 0, 1) Sleep(2000) $oHWND = _IEPropertyGet($oIE, "hwnd") WinSetState($oHWND, "", @SW_MAXIMIZE) $oForm = _IEFormGetCollection($oIE, 0) $oUsername = _IEFormElementGetObjByName($oForm, 'hprLogin$adUserName') $oPassword = _IEFormElementGetObjByName($oForm, "hprLogin$adPass") _IEFormElementSetValue($oUsername, $sUsername) _IEFormElementSetValue($oPassword, $sPassword) Sleep(500) MouseClick("left", 500, 500) Sleep(500) Send("{tab}") Send("{ENTER}") Sleep(6000) _IENavigate($oIE, "https://thewebsite.com") Sleep(4000) MouseClick("left", 400, 500) Sleep(200) ;~ $sDate = "06/29/2011" $oHWND = _IEPropertyGet($oIE, "hwnd") WinSetState($oHWND, "", @SW_MAXIMIZE) $oForm = _IEFormGetCollection($oIE, 0) $oDate1 = _IEFormElementGetObjByName($oForm, "date1") $oDate2 = _IEFormElementGetObjByName($oForm, "date2") _IEFormElementSetValue($oDate1, $sDate) _IEFormElementSetValue($oDate2, $sDate) Sleep(200) MouseClick("left", 500, 500) Sleep(200) Send("{ENTER}") EndFunc Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
roc Posted June 22, 2010 Author Share Posted June 22, 2010 Thank you guys very much for your help. 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