Jump to content
Sign in to follow this  
lockito

Open file, copy and paste from internet

Recommended Posts

lockito

Good evening

I'm new of this forum and i'm not english, so i'm sorry if i don't write very well.

i want to create a program to open an existent file notepad and a page from internet, copy all its contents (i thought with ctrl+a) and paste it in the file notepad.

I tried to do it but i found a lot of problems:

first of all, i don't know how open the file notepad. I tried with run and fileopen, but they didn't work. Then i tried with shellexecute and i opened it, but the program don't wait the opening before do the next instruction. So i tried with winwait and winwaitactive but they doesn't work.

The second problem are the operations of copy and paste. The time to open the internet page is variable by the conditions of the system, and much times the program doesn't copy.

I think it's a simple program to do for you, so i'm asking if there is some good soul who can write in response where i was wrong and the correct code please.

Share this post


Link to post
Share on other sites
mLipok

Welcome to the forum.

to learn how Run('Notepad.exe') look here:

http://www.autoitscript.com/autoit3/docs/functions/SendKeepActive.htm

There is a good example.

 

For getting content of IE you can start from

_IECreate

_IENavigate

and finaly

_IEPropertyGet($oIE, "innertext")

Read the help file for this function, and when you have a more precise formulation of the question right back to this topic.

I'm sure someone will help you.
Edited by mlipok

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2018-03-17

Share this post


Link to post
Share on other sites
lockito

If i don't want to use IE but chrome, how can i do?

I tried again and i made this:

; Open a txt file and erase the content
ShellExecute("test.txt")
WinWait("[CLASS:Notepad]")  
Send("^{Numpad5}")
Send("{del}")

; Open an internet page and select the content
ShellExecute("http://www.autoitscript.com/autoit3/docs/functions/SendKeepActive.htm")
WinWait("[CLASS:Chrome_WidgetWin_1]")
SendKeepActive("[CLASS:Chrome_WidgetWin_1]")
Send("^{a}")

MsgBox(0,"Test message", "")

The opening of the .txt file and delete it content works well, but in the second part the command Send("^{a}") doesn't work. Why?

Share this post


Link to post
Share on other sites
mLipok

You forget

Send("^{c}")

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2018-03-17

Share this post


Link to post
Share on other sites
mrflibblehat

Could you not do it like this

$vFileName = "test.txt"
$vFileOpen = FileOpen($vFileName, 2)

$vReadWeb = BinaryToString(InetRead("http://www.autoitscript.com/autoit3/docs/functions/SendKeepActive.htm"))

FileWriteLine($vFileOpen, $vReadWeb)

ShellExecute($vFileName)

[font="'courier new', courier, monospace;"]Pastebin UDF | Prowl UDF[/font]

Share this post


Link to post
Share on other sites
lockito

for mlipok: i know, but the problem is that the program doesn't do Send("^{a}"). Why?

for mrflibblehat: thank you for your solution, but it write the html code of the page. I want to simulate the sequence of operations select all-copy-active file.txt-paste. Do you know how can i do it?

Share this post


Link to post
Share on other sites
somdcomputerguy

So you want to get the text off a webpage, and write that text to a text file then open that file in Notepad, correct?

 

Is this webpage private, or can you post the URL? If it is too private that you don't want to post it publicly, but not private enough that you don't mind sharing it with me, feel free to PM it to me.

 

I have more questions to ask, but seeing the webpage in question would answer most of them.

 

Here is a simple example that works with a text only file.

InetGet("http://somdcomputerguy.com/lockito.txt", "lockito.txt")
ShellExecute("lockito.txt")
Here is another example that will work on a formatted HTML page, using the _IEPropertyGet function, as mlipok suggested earlier.

#include <IE.au3>

$oIE  = _IECreate("http://www.autoitscript.com/autoit3/docs/functions/SendKeepActive.htm", 0, 0)
$Text = _IEPropertyGet($oIE, "innertext")
$File = FileOpen("lockito.txt", 2)

FileWrite($File, $Text)
FileClose($File)

ShellExecute("lockito.txt")
This code does use Internet Explorer, but because you stated that you didn't want to use that browser, the IECreate function will be hidden. Refer to the Docs for more information about the functions used, and what those functions do. Edited by somdcomputerguy

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites
mLipok

for mlipok: i know, but the problem is that the program doesn't do Send("^{a}"). Why?

 

This is strange

I start new thread:

'?do=embed' frameborder='0' data-embedContent>>

Edited by mlipok

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2018-03-17

Share this post


Link to post
Share on other sites
lockito

I read the thread and i tried all the solutions. The only solution that works is this:

#include <WinAPI.au3>

; Open a txt file and erase the content
ShellExecute("test.txt")
WinWait("[CLASS:Notepad]")  
Send("^{Numpad5}")
Send("{del}") 

; Open a second txt file and erase the content
ShellExecute("test2.txt")
WinWait("[CLASS:Notepad]")  
Send("^{Numpad5}")
Send("{del}") 

; Open an internet page and select the content
ShellExecute("http://www.autoitscript.com/autoit3/docs/functions/SendKeepActive.htm")
WinWait("[CLASS:Chrome_WidgetWin_1]")
$hWnd = WinGetHandle("[CLASS:Chrome_WidgetWin_1]")
WinActivate(_WinAPI_GetParent($hWnd))
Send("^{a}")
Send("^{c}")

;Paste in .txt File
WinActivate("[CLASS:Notepad]")
WinWaitActive("[CLASS:Notepad]")
Send("^{v}")

MsgBox(0,"Test message", "")
But it works only sometimes. If the time to open the web page is long, it doesn't wait. Why?

Another question: if i have two opened notepad file, like in the code, how can i choose which file to activate? Now it open the last i used..

 

For Somdcomputerguy: i want to put in notepad statistics like this:

 

http://stats.betradar.com/s4/?clientid=219#2_1,3_1,22_1,5_6311,9_summary

 

I tried InetGet, but it copies the HTML code. For the site in example, i want instead this:

 

Statistiche
 
Aussie regole
Badminton
Bandy
Baseball
Beach Soccer
Calcio
Europa
Nazioni più popolari
Italia
Olanda
Inghilterra
Premier League
Championship
League One
League Two
Conference National
FA Cup
Community Shield
League Cup
Football League Trophy
Amatori
Germania
Spagna
Clubs Int.
Internazionale
A - G
I - N
O - U
Giovanile
Nord America
Sud America
Africa
Asia
Mondo
Ciclismo
Darts
Floorball
Football americano
Futsal
Hockey su ghiaccio
Motori
Pallacanestro
Pallamano
Pallanuoto
Pallavolo
Pesapallo
Rugby
Snooker
Sport invernali
Tennis
Tennis da Tavolo
Italiano
Calcio
Europa
Inghilterra
Premier League 13/14
Riepilogo
Classifiche
Giocatori
Squadre
Testa a Testa
Statistiche
Calendario / Risultati
Archivio
Premier League
RU Squadra G V P P Gol DR PU
1 
0
Arsenal 7 5 1 1 14-8 6 16
2 
0
Liverpool 7 5 1 1 11-5 6 16
3 
-1
Chelsea 7 4 2 1 10-4 6 14
4 
-1
Southampton 7 4 2 1 7-2 5 14
5 
-1
Man City 7 4 1 2 17-8 9 13
6 
1
Tottenham 7 4 1 2 6-5 1 13
7 
1
Everton 7 3 3 1 10-9 1 12
8 
0
Hull City 7 3 2 2 6-7 -1 11
9 
-1
Man United 7 3 1 3 10-9 1 10
10 
1
Aston Villa 7 3 1 3 9-8 1 10
11 
-1
Newcastle 7 3 1 3 9-12 -3 10
12 
1
West Bromwich 7 2 3 2 7-6 1 9
13 
-1
West Ham 7 2 2 3 7-5 2 8
14 
1
Cardiff City 7 2 2 3 7-9 -2 8
15 
1
Swansea City 7 2 1 4 8-11 -3 7
16 
1
Stoke City 7 2 1 4 4-7 -3 7
17 
-1
Fulham 7 2 1 4 5-9 -4 7
17 
1
Norwich City 7 2 1 4 5-9 -4 7
19 
0
Crystal Palace 7 1 0 6 5-13 -8 3
20 
0
Sunderland 7 0 1 6 5-16 -11 1
Prestazioni
RU SQ Punti V%P%P%
1  Arsenal 
16 
2  Liverpool 
13 
3  Chelsea 
11 
4  Southampton 
11 
5  Everton 
11 
6  Hull City 
11 
7  Man City 
10 
8  Newcastle 
10 
9  Tottenham 
10 
10  West Bromwich 
9 
11  Cardiff City 
8 
12  Swansea City 
7 
13  Aston Villa 
7 
14  Man United 
7 
15  Stoke City 
7 
16  Norwich City 
6 
17  West Ham 
5 
18  Fulham 
4 
19  Crystal Palace 
3 
20  Sunderland 
1 
Risultati
DA Incontro RF TU
06-10-2013 
West Bromwi… - Arsenal
1-1  7
06-10-2013 
Tottenham - West Ham
0-3  7
06-10-2013 
Southampton - Swansea City
2-0  7
06-10-2013 
Norwich City - Chelsea
1-3  7
05-10-2013 
Sunderland - Man United
1-2  7
05-10-2013 
Liverpool - Crystal Pal…
3-1  7
05-10-2013 
Hull City - Aston Villa
0-0  7
05-10-2013 
Fulham - Stoke City
1-0  7
05-10-2013 
Cardiff City - Newcastle
1-2  7
05-10-2013 
Man City - Everton
3-1  7
Calendario / Risultati
DA Incontro TU
19-10-2013 13:45 
Newcastle - Liverpool
8
19-10-2013 16:00 
Arsenal - Norwich City
8
19-10-2013 16:00 
Chelsea - Cardiff City
8
19-10-2013 16:00 
Everton - Hull City
8
19-10-2013 16:00 
Man United - Southampton
8
19-10-2013 16:00 
Stoke City - West Bromwi…
8
19-10-2013 16:00 
Swansea City - Sunderland
8
19-10-2013 18:30 
West Ham - Man City
8
20-10-2013 17:00 
Aston Villa - Tottenham
8
21-10-2013 21:00 
Crystal Pal… - Fulham
8
Calendario eventi
 
Partite Disputate 70
Totale Vittorie Casalinghe 42.9%
Totale Pareggiate 20%
Totale Vittorie in Trasferta 37.1%
Gol 162
Gol a partita 2.31
Gol in casa 1.24
Gol in trasferta 1.07
Over 0.5 Gol 90%
Over 1.5 Gol 63%
Over 2.5 Gol 41%
Over 3.5 Gol 27%
Classifica marcatori
PO Giocatore Squadra Ruolo IN GO RI
1 Sturridge, Daniel Liverpool attaccante 7 6 0
2 Remy, Loic Newcastle attaccante 5 5 0
3 Aguero, Sergio Manchester City attaccante 6 4 0
3 Toure, Yaya Manchester City Centrocampista 7 4 0
3 Ramsey, Aaron Arsenal Centrocampista 7 4 0
Provvedimenti disciplinari
PO Giocatore Squadra Ruolo IN Rosso Giallo/Rosso Giallo
1 Noble, Mark West Ham Centrocampista 7 1 1 1
2 O'Shea, John Sunderland Difensore 6 1 0 1
3 Taylor, Steven Newcastle Difensore 1 1 0 0
3 Dikgacoi, Kagisho Crystal Palace Centrocampista 5 1 0 0
3 Sagbo, Yannick Hull City attaccante 5 1 0 0
Edited by Melba23
Added tags

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  

×