Jump to content
Sign in to follow this  
Unholy_Pony

Date/Time Woes w/ window resizing

Recommended Posts

Unholy_Pony

Greetings All,

I am recent newcomer to the program, and still learning. However, I've encountered a bump that I cannot seem to bypass and would dearly appreciate any insight. 

The script I've created works fantastically, save at one point that puts the mouse near my desired location and pauses for me to click the first field. The window resizes every time a new request is made, so using coordinates fails hard. I tried using {TAB}, but similarly the cursor goes seemingly to a random selection of any of the 6 fields in the date box (dd/mm/yyyy hh:mm am/pm). 

I've noted the part ***** where the script could use some assistance.

My ideal would be to {TAB} into the box, determine the cursor location, then fill in the desired dates. It's that second step I am in trouble with.

Would there be a way to run an if then statement that could determine the cursors location and put it to the leftmost point? Or have it detect whether the value selected by the cursor is AM/PM? If I can make the cursor go to definate starting point I can build from there, but I'm still learning and any guidance would help tremendously. 

I'll provide any window info needed if I can. 

#region --- Au3Recorder generated code Start (v3.3.9.5 KeyboardLayout=00000409)  ---

#region --- Internal functions Au3Recorder Start ---
Func _Au3RecordSetup()
Opt('WinWaitDelay',100)
Opt('WinDetectHiddenText',1)
Opt('MouseCoordMode',0)
Local $aResult = DllCall('User32.dll', 'int', 'GetKeyboardLayoutNameW', 'wstr', '')
If $aResult[1] <> '00000409' Then
  MsgBox(64, 'Warning', 'Recording has been done under a different Keyboard layout' & @CRLF & '(00000409->' & $aResult[1] & ')')
EndIf

EndFunc

Func _WinWaitActivate($title,$text,$timeout=0)
    WinWait($title,$text,$timeout)
    If Not WinActive($title,$text) Then WinActivate($title,$text)
    WinWaitActive($title,$text,$timeout)
EndFunc

_AU3RecordSetup()
#endregion --- Internal functions Au3Recorder End ---
; Loop and ask how many repeats
$Number = InputBox("", "How many times repeat?", 1)
For $i = 1 To $Number
;end loop part minus the next at the very end of script

;Script here

;Get Device ID from notepad. Moves cursor to the top left and copies the line, as the ID's are not uniform. Sleep to allow system to catchup

_WinWaitActivate("Thing PID - Notepad","")
Send("{UP}{UP}{UP}{UP}{UP}{UP}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{SHIFTDOWN}{END}{SHIFTUP}{CTRLDOWN}c{CTRLUP}{DEL}{DEL}")
Sleep(100)

;Goto Ticketing program, paste in Device ID. Sleep allows program to load, as there is a marginal delay
_WinWaitActivate("New service work order - [ - ]","")
MouseClick("left",188,124,1,0)
Send("{CTRLDOWN}v{CTRLUP}{ENTER}")
SLEEP(800)

;Wait for Ticketing Prog to load, the extra click, pause, and space are in case a warning appears about existing work orders
_WinWaitActivate("New service work order","")
MouseClick("left",420,341,1,0)
Sleep(800)
SEND("{SPACE}")
MouseClick("left",420,341,1,0)

;START filling work order. This part grabs the specific description for what the requests will be
_WinWaitActivate("CHANGNIG BLAG - Notepad","")
MouseClick("left",105,12,1,0)
Send("{UP}{LEFT}{HOME}{SHIFTDOWN}{END}{SHIFTUP}{CTRLDOWN}c{CTRLUP}{DEL}{DEL}")
_WinWaitActivate("New service work order ","")
MouseClick("left",50,12,1,0)
MouseClick("left",153,326,1,0)
Send("{CTRLDOWN}v{CTRLUP}")
SEND("{END}")

;This copies the generic description for the work request
_WinWaitActivate("bLAH - Notepad","")
MouseClick("left",70,22,1,0)
Send("{HOME}{CTRLDOWN}ac{CTRLUP}{HOME}")
_WinWaitActivate("New service work order ","")
MouseClick("left",50,12,1,0)
MouseClick("left",153,326,1,0)
SEND("{END}")
Send("{CTRLDOWN}v{CTRLUP}")

;Places caller name in ticket field
MouseClick("left",406,307,1,0)
Send("{SHIFTDOWN}sarah{SPACE}stephens{SHIFTUP}{TAB}{TAB}loc{TAB}")


;****The part I am having trouble with****
;The ticketing window itself resizes every time a new ticket is made, based on the location description assoicated with a device.
;The problem is when it gets to the date field, I cannot 100% guarentee where the cursor will land, even using tab doesn't deliver 100% accurate results.
;Sometimes the current mouse click position is to the left of date, sometimes the right. Tab can land on any valid field from the previous box, it's maddening
;(needs to be dd/mm/yyyy hh/mm am/pm ex: 02/21/2018 03/37 PM)
;My current solution is to have AutoIT alert me with a msg window, then move the mouse nearby so I can easily click.
;the window helpfully reminds which field to click. LOL

msgbox(0,"First Message!","Click Due By Day.")
_WinWaitActivate("New service work order","")
MouseClick("left",674,412,1,0)
Sleep(1900)
Send("2{RIGHT}22{RIGHT}2018{RIGHT}7{RIGHT}00{RIGHT}P")

;****End date part 1

;Date part 2
;Same problem, but a solution to the above will address

msgbox(0,"Second Message!","Click Start Time Day")
_WinWaitActivate("New service work order","")
MouseClick("left",674,417,1,0)
Sleep(1500)
Send("2{RIGHT}22{RIGHT}2018{RIGHT}7{RIGHT}00{RIGHT}P")

;Wrap up. This section creates the call, copies the Ticket number and technician into files to be moved and sent as needed.
_WinWaitActivate("New service work order","")
Send("{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{SPACE}")

;Copy tech from message
_WinWaitActivate("Text message","")
Send("{CTRLDOWN}c{CTRLUP}")

;Copy tech to notepad
_WinWaitActivate("tech - Notepad","")
Send("{CTRLDOWN}v{CTRLUP}{ENTER}")

;Copy ticket number
_WinWaitActivate("Text message","")
MouseClick("left",297,131,1,0)
Send("{CTRLDOWN}a{CTRLUP}{CTRLDOWN}c{CTRLUP}")

;Copy number to notepad
_WinWaitActivate("ticket numbers - Notepad","")
Send("{CTRLDOWN}v{CTRLUP}{ENTER}")

;Send message, start new ticket
_WinWaitActivate("Text message","")
MouseClick("left",529,18,1,0)
Sleep(100)
Send("{TAB}{TAB}{TAB}{SPACE}")
Sleep(1500)
Next
#endregion --- Au3Recorder generated code End ---



 

Working Script help needed.au3

Screenshot.png

Share this post


Link to post
Share on other sites
Unholy_Pony

Please delete this thread/topic.

Edited by Unholy_Pony

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  

×