Sign in to follow this  
Followers 0
roc

timer,sleep,wait?

6 posts in this topic

#1 ·  Posted (edited)

I have been working on a program and have it almost done, thanks to help from this great comunity. I just have one more thing I need to add.

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.why im asleep or not around. (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.

I have everything working except for,

I have added a date box where I can pick the time I would like the program to run at. I just can't figure out how to make the script wait until the time before it starts. Is there away to make a program wait or sleep until a specific time?

Can someone lead me in the right direction? I have no idea what I’m doing.

#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, 203, 75, 25, $WS_GROUP)
GUIStartGroup()
$Date2 = GUICtrlCreateDate("", 88, 16, 90, 21)
$hDTP = GUICtrlGetHandle($Date2)
_GUICtrlDTP_SetFormat($hDTP, "MM/dd/yyyy")
$Label2 = GUICtrlCreateLabel("Date you would like leave", 72, 48, 126, 17)
$Input1 = GUICtrlCreateInput("", 72, 136, 121, 21) ; password
$Label1 = GUICtrlCreateLabel("Password", 104, 176, 50, 17)

$Label3 = GUICtrlCreateLabel("Time to run script", 88, 104, 85, 17)
$Date1 = GUICtrlCreateDate("23:59:45", 88, 72, 90, 21, BitOR($DTS_UPDOWN,$DTS_TIMEFORMAT,$WS_TABSTOP))


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 = "myname"
;~  $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://website.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
Edited by roc

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

roc,

Just wait in a loop until the correct time. Change the button code to look like this: :mellow:

Case $Button1
    ; Wait until required time
    $sReqTime = "23:59:36" ; 14 secs before midnight
    Do
        ; Wait 1 sec
        Sleep(1000) 
    Until @HOUR & ":" & @MIN & ":" & @SEC = $sReqTime
    ; Now pass date,password as parameters of function
    MyLeave(GUICtrlRead($Date2), GUICtrlRead($Input1))

Just make sure your system clock is accurate! :party:

M23

Edit: When you post code please use Code tags. Put [autoit ] before and [/autoit ] after your posted code (but omit the trailing space - it is only there so the tags display here). Or press the blue button just under the BOLD toolbar button. :P

Edited by Melba23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

if you are just looking for a time, then @hour and @min will work. I use a code something like:

While @WDAY=7

If @WDAY=7 Then Sleep(500000)

WEnd

this will sleep through Saturday

If @HOUR&@MIN=0500 Then folder()

this will run the folder() function at 5am...

*edit*

@YDAY gives the day of the year which could prove useful in your script to wait until the very last day or first day of the year.

Edited by kaotkbliss

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites

roc,

Just wait in a loop until the correct time. Change the button code to look like this: :mellow:

Case $Button1
    ; Wait until required time
    $sReqTime = "23:59:36" ; 14 secs before midnight
    Do
        ; Wait 1 sec
        Sleep(1000) 
    Until @HOUR & ":" & @MIN & ":" & @SEC = $sReqTime
    ; Now pass date,password as parameters of function
    MyLeave(GUICtrlRead($Date2), GUICtrlRead($Input1))

Just make sure your system clock is accurate! :party:

M23

Edit: When you post code please use Code tags. Put [autoit ] before and [/autoit ] after your posted code (but omit the trailing space - it is only there so the tags display here). Or press the blue button just under the BOLD toolbar button. :P

Thank you very much.

Is there anyway I can make my $date1 time that I select the $sReqTime? So I may have some flexibility with when the script starts.

Thank you again

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Making your control logic something like the following will at least allow you to bust out of your delay loop in a civilized manner, rather than killing the process in the task manager.

#include <Array.au3>
#include <Date.au3>
#include <GUIConstants.au3>
#include <GuiDateTimePicker.au3>
#include <IE.au3>

Global $delay

$Form2 = GUICreate("ALR", 265, 245, 320, 253)
GUISetIcon("D:\004.ico")
$Button1 = GUICtrlCreateButton("&Get my leave", 94, 200, 75, 25)
GUIStartGroup()
$Date2 = GUICtrlCreateDate("", 88, 16, 90, 21)
$hDTP = GUICtrlGetHandle($Date2)
_GUICtrlDTP_SetFormat($hDTP, "MM/dd/yyyy")
$Label2 = GUICtrlCreateLabel("Date you would like leave", 72, 48, 126, 17)
$Input1 = GUICtrlCreateInput("", 72, 80, 120, 21) ; password
$Label1 = GUICtrlCreateLabel("Password", 104, 110, 50, 17)

$Date1 = _GUICtrlDTP_Create($Form2, 70, 140, 120)
_GUICtrlDTP_SetFormat($Date1, "yyyy/MM/dd HH:mm")
$Label3 = GUICtrlCreateLabel("Time to run script", 88, 170, 85, 17)
$Label4 = GUICtrlCreateLabel("", 60, 230, 200, 17)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            $delay = _GUICtrlDTP_GetSystemTime($Date1)
            $delay = $delay[0] & "/" & $delay[1] & "/" & $delay[2] & " " & $delay[3] & ":" & $delay[4]
    EndSwitch
    If $delay Then
        $remaining = _DateDiff("n", _NowCalc(), $delay) + 1
        GUICtrlSetData($Label4, "Minutes remaining: " & $remaining)
        If $remaining < 1 Then
            Beep(800,100)
            GUICtrlSetData($Label4, "Processing request...")
            ; pass date,password as parameters of function
            MyLeave(GUICtrlRead($Date2), GUICtrlRead($Input1))
            $delay = ""
        Else
            Sleep(50)
        EndIf
    EndIf
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 = "myname"
;~ $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://website.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

It drives me nuts that the DTP controls don't recognize the mouse wheel, so adding an #include, one more Global definition, a GUIRegisterMsg() statement, and 20 lines of code to the very bottom of the script gets you this:

#include <Array.au3>
#include <Date.au3>
#include <GuiDateTimePicker.au3>
#include <GUIConstants.au3>
#include <GuiDateTimePicker.au3>
#include <IE.au3>
#include <WindowsConstants.au3>

Global $delay, $DTP_Flag

$Form2 = GUICreate("ALR", 265, 245, 320, 253)
GUISetIcon("D:\004.ico")
$Button1 = GUICtrlCreateButton("&Get my leave", 94, 200, 75, 25)
GUIStartGroup()
$Date2 = GUICtrlCreateDate("", 88, 16, 90, 21)
$hDTP = GUICtrlGetHandle($Date2)
_GUICtrlDTP_SetFormat($hDTP, "MM/dd/yyyy")
$Label2 = GUICtrlCreateLabel("Date you would like leave", 72, 48, 126, 17)
$Input1 = GUICtrlCreateInput("", 72, 80, 120, 21) ; password
$Label1 = GUICtrlCreateLabel("Password", 104, 110, 50, 17)

$Date1 = _GUICtrlDTP_Create($Form2, 70, 140, 120)
_GUICtrlDTP_SetFormat($Date1, "yyyy/MM/dd HH:mm")
$Label3 = GUICtrlCreateLabel("Time to run script", 88, 170, 85, 17)
$Label4 = GUICtrlCreateLabel("", 60, 230, 200, 17)
GUISetState(@SW_SHOW)
GUIRegisterMsg($WM_SETCURSOR, "WM_SETCURSOR")


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            $delay = _GUICtrlDTP_GetSystemTime($Date1)
            $delay = $delay[0] & "/" & $delay[1] & "/" & $delay[2] & " " & $delay[3] & ":" & $delay[4]
    EndSwitch
    If $delay Then
        $remaining = _DateDiff("n", _NowCalc(), $delay) + 1
        GUICtrlSetData($Label4, "Minutes remaining: " & $remaining)
        If $remaining < 1 Then
            Beep(800,100)
            GUICtrlSetData($Label4, "Processing request...")
            ; pass date,password as parameters of function
;           MyLeave(GUICtrlRead($Date2), GUICtrlRead($Input1))
            $delay = ""
        Else
            Sleep(50)
        EndIf
    EndIf
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 = "myname"
;~ $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://website.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

;-------------------------------------------------------------------------------
Func WM_SETCURSOR($hWnd, $iMsg, $iWParam, $iLParam) ; set flag if within DTP control
    If $iWParam = $Date1 Then
        If $DTP_Flag = 0 Then
            GUIRegisterMsg($WM_MOUSEWHEEL, "WM_DTP_MOUSEWHEEL") ; enable when entering DTP control
        EndIf
        $DTP_Flag = 1
    Else
        If $DTP_Flag = 1 Then
            GUIRegisterMsg($WM_MOUSEWHEEL, "") ; disable when exiting
        EndIf
        $DTP_Flag = 0
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc

Func WM_DTP_MOUSEWHEEL($hWnd, $iMsg, $iwParam, $ilParam)
    If $DTP_Flag Then
        If _WinAPI_HiWord($iwParam) > 0 Then ; mouse wheel up
            Send("{DOWN}")
        Else                                ; mouse wheel down
            Send("{UP}")
        EndIf
    EndIf
    Return 0
EndFunc
Edited by Spiff59

Share this post


Link to post
Share on other sites

Thank you very much Spiff59.

This is better then I was thinking. It is perfect.

The people in this forum are great! Thank you everyone.

Making your control logic something like the following will at least allow you to bust out of your delay loop in a civilized manner, rather than killing the process in the task manager.

#include <Array.au3>
#include <Date.au3>
#include <GUIConstants.au3>
#include <GuiDateTimePicker.au3>
#include <IE.au3>

Global $delay

$Form2 = GUICreate("ALR", 265, 245, 320, 253)
GUISetIcon("D:\004.ico")
$Button1 = GUICtrlCreateButton("&Get my leave", 94, 200, 75, 25)
GUIStartGroup()
$Date2 = GUICtrlCreateDate("", 88, 16, 90, 21)
$hDTP = GUICtrlGetHandle($Date2)
_GUICtrlDTP_SetFormat($hDTP, "MM/dd/yyyy")
$Label2 = GUICtrlCreateLabel("Date you would like leave", 72, 48, 126, 17)
$Input1 = GUICtrlCreateInput("", 72, 80, 120, 21) ; password
$Label1 = GUICtrlCreateLabel("Password", 104, 110, 50, 17)

$Date1 = _GUICtrlDTP_Create($Form2, 70, 140, 120)
_GUICtrlDTP_SetFormat($Date1, "yyyy/MM/dd HH:mm")
$Label3 = GUICtrlCreateLabel("Time to run script", 88, 170, 85, 17)
$Label4 = GUICtrlCreateLabel("", 60, 230, 200, 17)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            $delay = _GUICtrlDTP_GetSystemTime($Date1)
            $delay = $delay[0] & "/" & $delay[1] & "/" & $delay[2] & " " & $delay[3] & ":" & $delay[4]
    EndSwitch
    If $delay Then
        $remaining = _DateDiff("n", _NowCalc(), $delay) + 1
        GUICtrlSetData($Label4, "Minutes remaining: " & $remaining)
        If $remaining < 1 Then
            Beep(800,100)
            GUICtrlSetData($Label4, "Processing request...")
            ; pass date,password as parameters of function
            MyLeave(GUICtrlRead($Date2), GUICtrlRead($Input1))
            $delay = ""
        Else
            Sleep(50)
        EndIf
    EndIf
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 = "myname"
;~ $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://website.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

It drives me nuts that the DTP controls don't recognize the mouse wheel, so adding an #include, one more Global definition, a GUIRegisterMsg() statement, and 20 lines of code to the very bottom of the script gets you this:

#include <Array.au3>
#include <Date.au3>
#include <GuiDateTimePicker.au3>
#include <GUIConstants.au3>
#include <GuiDateTimePicker.au3>
#include <IE.au3>
#include <WindowsConstants.au3>

Global $delay, $DTP_Flag

$Form2 = GUICreate("ALR", 265, 245, 320, 253)
GUISetIcon("D:\004.ico")
$Button1 = GUICtrlCreateButton("&Get my leave", 94, 200, 75, 25)
GUIStartGroup()
$Date2 = GUICtrlCreateDate("", 88, 16, 90, 21)
$hDTP = GUICtrlGetHandle($Date2)
_GUICtrlDTP_SetFormat($hDTP, "MM/dd/yyyy")
$Label2 = GUICtrlCreateLabel("Date you would like leave", 72, 48, 126, 17)
$Input1 = GUICtrlCreateInput("", 72, 80, 120, 21) ; password
$Label1 = GUICtrlCreateLabel("Password", 104, 110, 50, 17)

$Date1 = _GUICtrlDTP_Create($Form2, 70, 140, 120)
_GUICtrlDTP_SetFormat($Date1, "yyyy/MM/dd HH:mm")
$Label3 = GUICtrlCreateLabel("Time to run script", 88, 170, 85, 17)
$Label4 = GUICtrlCreateLabel("", 60, 230, 200, 17)
GUISetState(@SW_SHOW)
GUIRegisterMsg($WM_SETCURSOR, "WM_SETCURSOR")


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            $delay = _GUICtrlDTP_GetSystemTime($Date1)
            $delay = $delay[0] & "/" & $delay[1] & "/" & $delay[2] & " " & $delay[3] & ":" & $delay[4]
    EndSwitch
    If $delay Then
        $remaining = _DateDiff("n", _NowCalc(), $delay) + 1
        GUICtrlSetData($Label4, "Minutes remaining: " & $remaining)
        If $remaining < 1 Then
            Beep(800,100)
            GUICtrlSetData($Label4, "Processing request...")
            ; pass date,password as parameters of function
;           MyLeave(GUICtrlRead($Date2), GUICtrlRead($Input1))
            $delay = ""
        Else
            Sleep(50)
        EndIf
    EndIf
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 = "myname"
;~ $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://website.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

;-------------------------------------------------------------------------------
Func WM_SETCURSOR($hWnd, $iMsg, $iWParam, $iLParam) ; set flag if within DTP control
    If $iWParam = $Date1 Then
        If $DTP_Flag = 0 Then
            GUIRegisterMsg($WM_MOUSEWHEEL, "WM_DTP_MOUSEWHEEL") ; enable when entering DTP control
        EndIf
        $DTP_Flag = 1
    Else
        If $DTP_Flag = 1 Then
            GUIRegisterMsg($WM_MOUSEWHEEL, "") ; disable when exiting
        EndIf
        $DTP_Flag = 0
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc

Func WM_DTP_MOUSEWHEEL($hWnd, $iMsg, $iwParam, $ilParam)
    If $DTP_Flag Then
        If _WinAPI_HiWord($iwParam) > 0 Then ; mouse wheel up
            Send("{DOWN}")
        Else                                ; mouse wheel down
            Send("{UP}")
        EndIf
    EndIf
    Return 0
EndFunc

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