Simulate CTRL+A and CTRL+C
Re: Simulate CTRL+A and CTRL+C
Hello Allen,
I tested the code but in the debug, I get the copy of the program code!
I tested the code but in the debug, I get the copy of the program code!
Re: Simulate CTRL+A and CTRL+C
What's the URL for musical bases, so I can test?
Re: Simulate CTRL+A and CTRL+C
Hello BarryG
I looked at this site but I don't know how to use it
https://musicbrainz.org/
I also looked in this list but did not find any database that I could exploit
https://en.wikipedia.org/wiki/List_of_o ... _databases
I looked at this site but I don't know how to use it
https://musicbrainz.org/
I also looked in this list but did not find any database that I could exploit
https://en.wikipedia.org/wiki/List_of_o ... _databases
Re: Simulate CTRL+A and CTRL+C
@Jak64,
to
and try again.
Thanks
Allen
Please changeHello Allen,
I tested the code but in the debug, I get the copy of the program code!
Code: Select all
WebPage2Clipboard()
Code: Select all
WebPage2Clipboard():Delay(3000)
Thanks
Allen
Re: Simulate CTRL+A and CTRL+C
Hi Allen
Here's the program I'm testing and it doesn't work.
Here's the program I'm testing and it doesn't work.
Code: Select all
Procedure WebPage2Clipboard()
Protected.INPUT InputKey
; Control key Down
InputKey\Type = #INPUT_KEYBOARD
InputKey\ki\wVk = #VK_CONTROL
InputKey\ki\dwFlags = 0
SendInput_(1, @InputKey, SizeOf(INPUT))
Delay(20)
;a press
InputKey\Type = #INPUT_KEYBOARD
InputKey\ki\wVk = 65
InputKey\ki\dwFlags = 0
SendInput_(1, @InputKey, SizeOf(INPUT))
Delay(20)
; a release
InputKey\Type = #INPUT_KEYBOARD
InputKey\ki\wVk = 65
InputKey\ki\dwFlags = #KEYEVENTF_KEYUP
SendInput_(1, @InputKey, SizeOf(INPUT))
Delay(20)
;c press
InputKey\Type = #INPUT_KEYBOARD
InputKey\ki\wVk = 67
InputKey\ki\dwFlags = 0
SendInput_(1, @InputKey, SizeOf(INPUT))
Delay(20)
;c release
InputKey\Type = #INPUT_KEYBOARD
InputKey\ki\wVk = 67
InputKey\ki\dwFlags = #KEYEVENTF_KEYUP
SendInput_(1, @InputKey, SizeOf(INPUT))
Delay(20)
;Control key up
InputKey\Type = #INPUT_KEYBOARD
InputKey\ki\wVk = #VK_CONTROL
InputKey\ki\dwFlags = #KEYEVENTF_KEYUP
SendInput_(1, @InputKey, SizeOf(INPUT))
Delay(20)
EndProcedure
#debut_url="https://www.google.com/search?q="
#fin_url=""
Chanson$="date chanson Michael Jackson Thriller"
RequeteGoogle$=URLEncoder(#debut_url + Chanson$ + #fin_url )
RunProgram("C:\Program Files (x86)\Google\Chrome\Application\chrome_proxy.exe",RequeteGoogle$,"")
Delay(4000); wait till chrome becomes stable
;OriginalClipBoard$=GetClipboardText()
WebPage2Clipboard():Delay(3000)
A$=GetClipboardText()
Debug a$
;SetClipboardText(OriginalClipBoard$)
Re: Simulate CTRL+A and CTRL+C
@Jak64,
One reason I can think of is the delay time is not enough and the web page is not completly loaded. Please take a look at below video. You should be able to see the CTRL-A, CTRL-C effect on the chrome page.
https://streamable.com/5b8k7g
Please change the delay time at line 48 to delay(20000) and line 50 to delay(10000) and try again.
Thanks.
Allen Wong
One reason I can think of is the delay time is not enough and the web page is not completly loaded. Please take a look at below video. You should be able to see the CTRL-A, CTRL-C effect on the chrome page.
https://streamable.com/5b8k7g
Please change the delay time at line 48 to delay(20000) and line 50 to delay(10000) and try again.
Thanks.
Allen Wong
Re: Simulate CTRL+A and CTRL+C
Change:
RunProgram("C:\Program Files (x86)\Google\Chrome\Application\chrome_proxy.exe",RequeteGoogle$,"")
by
RunProgram("C:\Program Files\Google\Chrome\Application\chrome_proxy.exe",RequeteGoogle$,"")
RunProgram("C:\Program Files (x86)\Google\Chrome\Application\chrome_proxy.exe",RequeteGoogle$,"")
by
RunProgram("C:\Program Files\Google\Chrome\Application\chrome_proxy.exe",RequeteGoogle$,"")
Re: Simulate CTRL+A and CTRL+C
Hello Allen and Caronte3D,
I removed all the delays and changed the line
RunProgram("C:\Program Files\Google\Chrome\Application\chrome_proxy.exe",GoogleRequest$,"")
As Caront3D advised me and it works perfectly.
On the other hand, if I run the program 10 times, it opens 10 web pages. How to close them programmatically?
THANKS
Here is the code that works
I removed all the delays and changed the line
RunProgram("C:\Program Files\Google\Chrome\Application\chrome_proxy.exe",GoogleRequest$,"")
As Caront3D advised me and it works perfectly.
On the other hand, if I run the program 10 times, it opens 10 web pages. How to close them programmatically?
THANKS
Here is the code that works
Code: Select all
Procedure WebPage2Clipboard()
Protected.INPUT InputKey
; Control key Down
InputKey\Type = #INPUT_KEYBOARD
InputKey\ki\wVk = #VK_CONTROL
InputKey\ki\dwFlags = 0
SendInput_(1, @InputKey, SizeOf(INPUT))
Delay(20)
;a press
InputKey\Type = #INPUT_KEYBOARD
InputKey\ki\wVk = 65
InputKey\ki\dwFlags = 0
SendInput_(1, @InputKey, SizeOf(INPUT))
Delay(20)
; a release
InputKey\Type = #INPUT_KEYBOARD
InputKey\ki\wVk = 65
InputKey\ki\dwFlags = #KEYEVENTF_KEYUP
SendInput_(1, @InputKey, SizeOf(INPUT))
Delay(20)
;c press
InputKey\Type = #INPUT_KEYBOARD
InputKey\ki\wVk = 67
InputKey\ki\dwFlags = 0
SendInput_(1, @InputKey, SizeOf(INPUT))
Delay(20)
;c release
InputKey\Type = #INPUT_KEYBOARD
InputKey\ki\wVk = 67
InputKey\ki\dwFlags = #KEYEVENTF_KEYUP
SendInput_(1, @InputKey, SizeOf(INPUT))
Delay(20)
;Control key up
InputKey\Type = #INPUT_KEYBOARD
InputKey\ki\wVk = #VK_CONTROL
InputKey\ki\dwFlags = #KEYEVENTF_KEYUP
SendInput_(1, @InputKey, SizeOf(INPUT))
Delay(20)
EndProcedure
#debut_url="https://www.google.com/search?q="
#fin_url=""
Chanson$="date chanson Michael Jackson Thriller"
RequeteGoogle$=URLEncoder(#debut_url + Chanson$ + #fin_url )
RunProgram("C:\Program Files\Google\Chrome\Application\chrome_proxy.exe",RequeteGoogle$,"")
WebPage2Clipboard();:Delay(2000)
A$=GetClipboardText()
Debug a$
Re: Simulate CTRL+A and CTRL+C
Really the best advice is BarryG's You should use a music database through her API.
Maybe you need to investigate more how to access it, but that way is far better than the google scraper one
Maybe you need to investigate more how to access it, but that way is far better than the google scraper one
Re: Simulate CTRL+A and CTRL+C
Hello caronte3D,
I agree with you but I want to do this just once to update the release date in my database which has 5000 MP3 songs and empty tags.
For new songs, I will read the tags after ripping the CD to mp3.
I agree with you but I want to do this just once to update the release date in my database which has 5000 MP3 songs and empty tags.
For new songs, I will read the tags after ripping the CD to mp3.
Re: Simulate CTRL+A and CTRL+C
Hello, jak64.
To be honest, it's all crutches. And it's not safe! I agree with Caronte3D and BarryG.
But... If you insist on this option, then I would do this:
then you can list all running processes in the system and kill the one you need. There have already been such examples on this forum somewhere. Try searching.
To be honest, it's all crutches. And it's not safe! I agree with Caronte3D and BarryG.
But... If you insist on this option, then I would do this:
Code: Select all
Program = RunProgram(...)
ProcessID = ProgramID(Program)
Re: Simulate CTRL+A and CTRL+C
This works for me:
Code: Select all
Procedure ExtractRegExMatch (text$, Array result$(1), regex$ = "")
Static iRegEx
Protected iRetVal = -1 ; regex error
If regex$
If iRegEx > 0:FreeRegularExpression(iRegEx):EndIf
iRegEx = CreateRegularExpression(#PB_Any, regex$)
EndIf
If iRegEx
iRetVal = ExtractRegularExpression(iRegEx, text$, result$())
EndIf
ProcedureReturn iRetVal
EndProcedure
Procedure.s ExtractRegExString(text$, regex$ = "")
Dim result$(0)
ExtractRegExMatch (text$, result$(), regex$)
ProcedureReturn result$(0)
EndProcedure
Procedure.s scrapString(String$,StartString$,EndString$)
stS.i = FindString(String$,StartString$)
stE.i = FindString(String$,EndString$,stS)
If stS = 0 And stE = Len(EndString$):stE = 0:EndIf
ProcedureReturn Mid(String$,stS,stE)
EndProcedure
Procedure.s GetURLText(url$)
*Buffer = ReceiveHTTPMemory(URLEncoder(url$))
If *Buffer
Size = MemorySize(*Buffer)
text$ = PeekS(*Buffer, Size, #PB_UTF8 | #PB_ByteLength)
FreeMemory(*Buffer)
EndIf
ProcedureReturn text$
EndProcedure
Debug ExtractRegExString(scrapString(GetURLText("https://www.google.com/search?q=Lionel Richie Can't get over you release date"),"Released","img"),"(?!>)[0-9]{1,4}(?=</)")
WARNING: I dont know what I am doing! I just put stuff here and there and sometimes like magic it works. So please improve on my code and post your changes so I can learn more. TIA
Re: Simulate CTRL+A and CTRL+C
@Jak64,
Close the tap after you got the clipboard content.
Thanks.
Allen
You can send another short cut key sequence to the chrome window to close it.On the other hand, if I run the program 10 times, it opens 10 web pages. How to close them programmatically?
Code: Select all
Procedure CloseChromeTap()
Protected.INPUT InputKey
; Control key Down
InputKey\Type = #INPUT_KEYBOARD
InputKey\ki\wVk = #VK_CONTROL
InputKey\ki\dwFlags = 0
SendInput_(1, @InputKey, SizeOf(INPUT))
Delay(20)
;w press
InputKey\Type = #INPUT_KEYBOARD
InputKey\ki\wVk = 87 ;87
InputKey\ki\dwFlags = 0
SendInput_(1, @InputKey, SizeOf(INPUT))
Delay(20)
;w release
InputKey\Type = #INPUT_KEYBOARD
InputKey\ki\wVk = 87 ;87
InputKey\ki\dwFlags = #KEYEVENTF_KEYUP
SendInput_(1, @InputKey, SizeOf(INPUT))
Delay(20)
;Control key up
InputKey\Type = #INPUT_KEYBOARD
InputKey\ki\wVk = #VK_CONTROL
InputKey\ki\dwFlags = #KEYEVENTF_KEYUP
SendInput_(1, @InputKey, SizeOf(INPUT))
Delay(20)
EndProcedure
Code: Select all
A$=GetClipboardText()
CloseChromeTap()
Allen
Re: Simulate CTRL+A and CTRL+C
Thank you Allen
Re: Simulate CTRL+A and CTRL+C
If you send 5000 identical requests from the same IP to the same server, the firewall of the remote site will consider it a flooding attempt and will block you (at least for a while).
If you want to update a large number of titles, you will have to use a remote database (and sometimes get a login, sometimes pay).
Otherwise, you have to do it one by one. Some sites allow free access with a certain limit per day (e.g. 200 queries / day).
As for the analysis of a standard page of google or other, as you can see, it changes every day.
So you can easily build something based on RegEx, but it will have to be modified often.
If you want to update a large number of titles, you will have to use a remote database (and sometimes get a login, sometimes pay).
Otherwise, you have to do it one by one. Some sites allow free access with a certain limit per day (e.g. 200 queries / day).
As for the analysis of a standard page of google or other, as you can see, it changes every day.
So you can easily build something based on RegEx, but it will have to be modified often.