Jump to content

GUI + Program


 Share

Recommended Posts

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

  • Moderators

roc,

Double posting like this is frowned upon here. :mellow:

Please do not do it again. :P

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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 $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}")

Edited by Fossil Rock

Agreement is not necessary - thinking for one's self is!

My-Colors.jpg

cuniform2.gif

Link to comment
Share on other sites

Use Func ... EndFunc like this:

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