wan Posted October 27, 2022 Posted October 27, 2022 (edited) Hello, I have create a script to change the date and time value . It just send a mouseclick to adjust the value using the arrow up and down from the application interface. It is possible for me to to change the date based on current date in the box ? For example if the date is 1 Nov , change it to 31 October , if it is 2 Nov change to 1 Nov instead of send arrow down to reduce the date . I have see replace string function but i not know how to script it. ;Click "Time Box" ControlClick( "sVMS2000", "", $hWnd, "left", 1, 407, 142 ) Sleep(1000) ;Send UP Click 23x Send("{UP} 23") Sleep(100) ;Click "Date Box" ControlClick( "sVMS2000", "", $hWnd, "left", 1, 344, 140 ) Sleep(1000) ;Send DOWN Click Send("{DOWN}") Sleep(1000) Edited October 27, 2022 by wan
Nine Posted October 27, 2022 Posted October 27, 2022 Look at ControlSetText in help file. Can you do it manually, I mean can you for example double-click Date field and enter date with keyboard ? “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy
wan Posted October 27, 2022 Author Posted October 27, 2022 Yes but this mean i need to do 30 times as the text to set is not the same value . This is why i try figure on how auto it can recognized what value in the date field and change it accordingly
Dan_555 Posted October 27, 2022 Posted October 27, 2022 Hmm. Maybe do this: 1st - clear the clipboard. Send a click into the date box. Send ctrl a (should select all text, you can test it by manually clicking into the date box and pressing ctrl a) Then Send Ctrl C to copy the text into clipboard Read clipboard out. Check which date it is and change it. Copy the new value into clipboard Send Ctrl V - pasting the new text into the field. Some of my script sourcecode
wan Posted November 2, 2022 Author Posted November 2, 2022 Update on my problem . I have figure on how to change the date based on system current date and get the value (NewDate) . But how I want to copy the date value and paste it in my application to change the date in the date box? Because I use clipget , it copied something else Local $sDate = _DateAdd('d', -2, _NowCalcDate()) ;Local $sDate = StringFormat("%02u/%02u/", @YEAR, @MON) & StringRight(@MDAY, 4) ; Format = MM/DD/YYYY local $sNewDate = StringRegExpReplace($sDate, "[/]", "-") MsgBox($MB_SYSTEMMODAL, "", "The following data is now stored in the clipboard: " & @CRLF & $sNewDate) Local $sDate = ClipGet() MsgBox($MB_SYSTEMMODAL, "", "The following data is now stored in the clipboard: " & @CRLF & $sDate)
Dan_555 Posted November 2, 2022 Posted November 2, 2022 ClipPut($sDate) copies the $sDate into clipboard. Some of my script sourcecode
abberration Posted November 3, 2022 Posted November 3, 2022 Local $sDate = _DateAdd('d', -2, _NowCalcDate()) local $sNewDate = StringRegExpReplace($sDate, "[/]", "-") MsgBox($MB_SYSTEMMODAL, "", "The date of 2 days ago is: " & @CRLF & $sNewDate) ; this is NOT in the clipboard yet. ClipPut($sNewDate) ; puts the $sNewDate into the clipboard MsgBox($MB_SYSTEMMODAL, "", "The following data is now stored in the clipboard: " & @CRLF & ClipGet()) ; use ClipGet to read the clipboard. Alternatively, if ControlSetText or ControlSend works with the control, then you can bypass the ClipPut and ClipGet and send the $sNewDate directly. Easy MP3 | Software Installer | Password Manager
wan Posted November 10, 2022 Author Posted November 10, 2022 On 11/3/2022 at 8:03 AM, abberration said: Local $sDate = _DateAdd('d', -2, _NowCalcDate()) local $sNewDate = StringRegExpReplace($sDate, "[/]", "-") MsgBox($MB_SYSTEMMODAL, "", "The date of 2 days ago is: " & @CRLF & $sNewDate) ; this is NOT in the clipboard yet. ClipPut($sNewDate) ; puts the $sNewDate into the clipboard MsgBox($MB_SYSTEMMODAL, "", "The following data is now stored in the clipboard: " & @CRLF & ClipGet()) ; use ClipGet to read the clipboard. Alternatively, if ControlSetText or ControlSend works with the control, then you can bypass the ClipPut and ClipGet and send the $sNewDate directly. This one works for me, but after several days. The script fail to paste the value to the date box
abberration Posted November 10, 2022 Posted November 10, 2022 You may need to use WinActivate, WinWaitActive and ControlGetHandle to make sure you are targeting the correct window and control. I am sure if you meant that it worked for several days and then quit working, but if that is the case, you may have instances of the program still running in the background. Try restarting your PC to ensure everything is cleared. Easy MP3 | Software Installer | Password Manager
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