ShrutiW Posted March 29, 2019 Share Posted March 29, 2019 Can I paste a value copied from a cell in the excel sheet to the text box in an application? using like ClipGet() or any other functions? Is it possible? Here's the code that I've tried so far. Local $oRange = $oWorkbook.ActiveSheet.Range("A1:R1") ; Reading excel sheet _Excel_RangeCopyPaste($oWorkbook.ActiveSheet, $oRange, "E1") ;copying value from cell "E1" Local $sData = ClipGet() WinWait ("New Contact","") ; Activating the window of application where I want to paste the cell value WinActivate("New Contact","") WinWaitActive("New Contact") Sleep(2000) ControlGetHandle("New Contact",ClipGet() , "[CLASS:ThunderRT6TextBox ; INSTANCE:6]") ;TextBox where I want to paste the copied value Link to comment Share on other sites More sharing options...
water Posted March 29, 2019 Share Posted March 29, 2019 No need to use _Excel_RangeCopyPaste. Simply use _Excel_RangeRead to read the cell value to a variable and then use ControlSend to"paste" the value to the other application. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
ShrutiW Posted March 29, 2019 Author Share Posted March 29, 2019 Hi @water, I tried using ReadRange, didn't get result . Please have a look at the code. Local $aResult = _Excel_RangeRead($oWorkbook, Default, $oWorkbook.ActiveSheet.Usedrange.Columns("A:R"), 1) Local $sResult = _Excel_RangeRead($oWorkbook, Default, "E2") WinWait ("New Contact","") WinActivate("New Contact","") WinWaitActive("New Contact") Local $hWnd = WinWait("New Contact","") Sleep(2000) ControlSend($hWnd,$sResult ,"[CLASS:ThunderRT6TextBox ; INSTANCE:6]" , "") What changes are expected? Link to comment Share on other sites More sharing options...
Nine Posted March 29, 2019 Share Posted March 29, 2019 ControlSend is badly formated...read help file carefully. “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 Link to comment Share on other sites More sharing options...
ShrutiW Posted April 1, 2019 Author Share Posted April 1, 2019 Hi @Nine, I am confused about how to use the parameter "$sResult" in controlSend command? Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted April 1, 2019 Share Posted April 1, 2019 (edited) @ShrutiW ControlSend ( "title", "text", controlID, "string" [, flag = 0] ) - Title: the title/hwnd of the window where the control exists; - Text: the text of the window where the control exists (you can leave it blank); - ControlID: the control ID/handle/text... of the control, in order to interact with it; - String: the string to send to the control; - Flag: how to send the string: - Use $SEND_DEFAULT (0) to send special characters like + or !, which are respectively Shift and Alt key presses; - Use $SEND_RAW (1) to send the text as is to the control. Switch your second parameter with the fourth one in the ControlSend function, and you should be done Edited April 1, 2019 by FrancescoDiMuro Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
ShrutiW Posted April 1, 2019 Author Share Posted April 1, 2019 (edited) Hey @FrancescoDiMuro, As per your suggestions I made changes in ControlSend command as :- ControlSend($hWnd,"","[CLASS:ThunderRT6TextBox ; INSTANCE:6]" ,$sResult) I am not getting the desired result . Edited April 1, 2019 by ShrutiW Link to comment Share on other sites More sharing options...
water Posted April 1, 2019 Share Posted April 1, 2019 What's the return value of ControlSend? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
ShrutiW Posted April 1, 2019 Author Share Posted April 1, 2019 Hi @water, I have used $sResult variable to store the value in the cell, and I am passing "$sResult" as a return value in control send. Is it a right way to do? Link to comment Share on other sites More sharing options...
water Posted April 1, 2019 Share Posted April 1, 2019 You need to define "not desired result". Do you get no text in the control, the wrong text (e.g. characters missing, wrong encoding) or do you get an error? To check for an error you need to have a look at the return value: $iReturnValue = ControlSend($hWnd,"","[CLASS:ThunderRT6TextBox ; INSTANCE:6]" ,$sResult) If $iReturnValue <> 1 Then MsgBox(0, "Error!", "window/control is not found!") My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
ShrutiW Posted April 1, 2019 Author Share Posted April 1, 2019 (edited) Hi @water, I checked with above code,I do not get any text in the control. Got an error message box. Edited April 1, 2019 by ShrutiW Link to comment Share on other sites More sharing options...
water Posted April 1, 2019 Share Posted April 1, 2019 The error message describes what happens: Either the window or control could not be found. As the window handle has been derived from a WinWait it seems that the control could not be found. Searching for "ThunderRT6" shows a lot of threads describing problems with this type of controls. Maybe one of them sheds some light onto the subject and delivers a solution? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
ShrutiW Posted April 1, 2019 Author Share Posted April 1, 2019 Hi @water, It is not working in either way, It is getting in over my head now.😥 Is there any other way I can retrieve cell values from excel and send them to text boxes and combo boxes in a windows application? Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted April 1, 2019 Share Posted April 1, 2019 You should try SimpleSpy from UIAutomation (you can find more here) ShrutiW 1 Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
water Posted April 1, 2019 Share Posted April 1, 2019 The part about reading Excel values has been solved. If your application provides an API for automation I would use this and drop automating the GUI. Have a look at the documentation of your application and see if you find something about COM, API or programming. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
ShrutiW Posted April 2, 2019 Author Share Posted April 2, 2019 Okay @water. I will check. Thanks for the advice and 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