Forum Discussion

Amrendra's avatar
Amrendra
Occasional Contributor
8 years ago

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

  • 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")
                }
          } 
    } 

     

    • shankar_r's avatar
      shankar_r
      Community Hero

      Hi,

       

      Not sure what you are exactly expecting,

       

      Instead of going to Notepad and copy/paste, you can using aqFile.ReadWholeTextFile

       

      def ReadWholeFile(AFileName):
        s = aqFile.ReadWholeTextFile(AFileName, aqFile.ctANSI)
        Log.Message("File entire contents:")
        Log.Message(s)
      • Amrendra's avatar
        Amrendra
        Occasional Contributor

        Hi sir,

         

        I have a notepad with some data, and I have to copy that data and paste into specific field in my application. I hope I am clear with my question sir