Forum Discussion

Amrendra's avatar
Amrendra
Occasional Contributor
7 years ago
Solved

How to Copy Data from Notepad and paste it in application under test through notepad

I have around 200 number like(qbc123,876rd etc) . I want to copy those number from Notepad and put it in my application under test. I have to do this in python. Please and please help me
  • shankar_r's avatar
    shankar_r
    7 years ago

    Sample code would like this in JavaScript,

     

     

    function Tst()
    {
          Sys.OleObject("WScript.Shell").Exec("cmd /c Notepad D:\\Users\\\\Desktop\\notes.txt");
          var notepadobj = Sys.Process("notepad").Window("Notepad", "notes.txt - Notepad", 1).Window("Edit", "", 1);
          
          if(notepadobj.Exists)
          {
                //Copy from Notepad
                notepadobj.SetFocus();
                notepadobj.Keys("^A");
                notepadobj.Keys("^C");
                
                if(yourObject.Exists){
                yourObject.SetFocus();
                yourObject.Keys("^V")
                }
          } 
    }