Hi guys,
I'm trying to setup a script which pastes all the text content of my clipboard to a custom site like amazon (&wiki) and do a search.
problem is that it only paste's the 1st word of the string from the clipboard and puts every other word in the address line in a new tab.
it only does this with the "chrome.exe" in front
!s::
Send, ^c
Sleep 200
Run, chrome.exe https://www.amazon.com/s/ref=nb_sb_noss ... %ClipBoard%
return
!w::
Send, ^c
Sleep 200
Run, chrome.exe https://en.wikipedia.org/wiki/%ClipBoard%
return
If you remove the "chrome.exe" it works fine and takes the whole string from %clipboard%
however I don't want to do that because I don't want it to open my default browser and don't want to change it.
Anybody knows what goes wrong here?
thanks a million, i can't seem to figure out how to fix being a newbie to this stuff
Need help with Run, %clipboard% command
Re: Need help with Run, %clipboard% command
Web addresses don't support spaces in them, so when you are copying more than one word, the space is seen as a new tab. You would have to StringReplace the space with either a _ and if a Wiki page exists for those words, it will load it.
Example:
https://en.wikipedia.org/wiki/Panel_painting
Example:
https://en.wikipedia.org/wiki/Panel_painting
Re: Need help with Run, %clipboard% command
Here is example code
With this, you should be able to apply the same thing to your Amazon searches
Code: Select all
!w::
Send, ^c
Sleep 200
wiki := "https://en.wikipedia.org/wiki/"
clip = %Clipboard%
StringReplace, clip, clip, %A_Space%,_, All
;MsgBox %wiki%%clip% ;debug
Run, chrome.exe %wiki%%Clip%
return
Re: Need help with Run, %clipboard% command
.... and wikipedia want stringupper in names ...
Code: Select all
transform,s,chr,32
c1="alex van warmerdam"
StringReplace,c1,c1,`",, All
Loop,parse,c1,%s%
{
x:=a_loopfield
if x in da,do,de,van
{
e .= x . "_"
continue
}
StringUpper,x,x,T
e .= x . "_"
}
stringtrimright,c1,e,1
run, https://en.wikipedia.org/wiki/%c1%
return
Re: Need help with Run, %clipboard% command
Thanks Crashm87 I have tested your code and it works however it puts -as you said- the _ in between the kw's which influences the amazon algorithm. It does not show ads which is what I need for research purposes.
Please note that when removing the chrome.exe it works:
Please note that when removing the chrome.exe it works:
Code: Select all
!a::
Send, ^c
Sleep 200
Run, https://www.amazon.com/s/ref=nb_sb_noss_2?url=search-alias`%3Daps&field-keywords=%ClipBoard%
return
!w::
Send, ^c
Sleep 200
Run, https://en.wikipedia.org/wiki/%ClipBoard%
return
Re: Need help with Run, %clipboard% command
Code: Select all
!a::
Send, ^c
Sleep 200
enc_Clipboard:=UriEncode(clipboard)
Run, chrome.exe https://www.amazon.com/s/ref=nb_sb_noss_2?url=search-alias`%3Daps&field-keywords=%enc_Clipboard%
return
UriEncode(Uri) {
VarSetCapacity(Var, StrPut(Uri, "UTF-8"), 0)
StrPut(Uri, &Var, "UTF-8")
f := A_FormatInteger
SetFormat, IntegerFast, H
while Code := NumGet(Var, A_Index - 1, "UChar")
if (Code >= 0x30 && Code <= 0x39 ; 0-9
|| Code >= 0x41 && Code <= 0x5A ; A-Z
|| Code >= 0x61 && Code <= 0x7A) ; a-z
Res .= Chr(Code)
else
Res .= "%" . SubStr(Code + 0x100, -1)
SetFormat, IntegerFast, %f%
return, Res
}
Re: Need help with Run, %clipboard% command
wow thats alot of code, it works perfectly thanks so much. Can you tell some more how you got this code, did you write it or got it from somewhere else? I would NEVER be able to pull off that kind of code lolnoname wrote:Code: Select all
!a:: Send, ^c Sleep 200 enc_Clipboard:=UriEncode(clipboard) Run, chrome.exe https://www.amazon.com/s/ref=nb_sb_noss_2?url=search-alias`%3Daps&field-keywords=%enc_Clipboard% return UriEncode(Uri) { VarSetCapacity(Var, StrPut(Uri, "UTF-8"), 0) StrPut(Uri, &Var, "UTF-8") f := A_FormatInteger SetFormat, IntegerFast, H while Code := NumGet(Var, A_Index - 1, "UChar") if (Code >= 0x30 && Code <= 0x39 ; 0-9 || Code >= 0x41 && Code <= 0x5A ; A-Z || Code >= 0x61 && Code <= 0x7A) ; a-z Res .= Chr(Code) else Res .= "%" . SubStr(Code + 0x100, -1) SetFormat, IntegerFast, %f% return, Res }
I tried to merge it into wiki too this doesn't seem to match,
I just did this after I tested your code working on amazon:
Code: Select all
!a::
Send, ^c
Sleep 200
enc_Clipboard:=UriEncode(clipboard)
Run, chrome.exe https://www.amazon.com/s/ref=nb_sb_noss_2?url=search-alias`%3Daps&field-keywords=%enc_Clipboard%
return
!w::
Send, ^c
Sleep 200
enc_Clipboard:=UriEncode(clipboard)
Run, chrome.exe https://en.wikipedia.org/wiki/%enc_ClipBoard%
return
UriEncode(Uri) {
VarSetCapacity(Var, StrPut(Uri, "UTF-8"), 0)
StrPut(Uri, &Var, "UTF-8")
f := A_FormatInteger
SetFormat, IntegerFast, H
while Code := NumGet(Var, A_Index - 1, "UChar")
if (Code >= 0x30 && Code <= 0x39 ; 0-9
|| Code >= 0x41 && Code <= 0x5A ; A-Z
|| Code >= 0x61 && Code <= 0x7A) ; a-z
Res .= Chr(Code)
else
Res .= "%" . SubStr(Code + 0x100, -1)
SetFormat, IntegerFast, %f%
return, Res
}
Re: Need help with Run, %clipboard% command
UriEncode is as old as the "web" UNIVERSE there must be dozens of versions on the forum.
Just google : uriencode site:https://autohotkey.com
Here is one : https://autohotkey.com/board/topic/7539 ... -function/
The wiki works for me maybe you used a exceptional character in your search item?
It is a nice way of using Wikipedia thanks I will keep the shortcut !!
Just google : uriencode site:https://autohotkey.com
Here is one : https://autohotkey.com/board/topic/7539 ... -function/
The wiki works for me maybe you used a exceptional character in your search item?
It is a nice way of using Wikipedia thanks I will keep the shortcut !!
Re: Need help with Run, %clipboard% command
yes it now seems to work on mine as well, my system apparenly needed a reboot hehe.
Thanks for the links, you mean with that that you didnt write that code yourself?
Thanks for the help in any case!
Thanks for the links, you mean with that that you didnt write that code yourself?
Thanks for the help in any case!
Re: Need help with Run, %clipboard% command
No i did not write the code , i keep note of functions i see in scripts/functions forum if they are looking interesting.This one has been modified a lot so i do not know the original post.
If you look closely you see it is rather simple ,if a character is a-z or A-Z or 0-9 keep it , otherwise use the hex value with prefix % so space is 0x20 hex convert it to %20.
Ha the good old reset button did it again.........
If you look closely you see it is rather simple ,if a character is a-z or A-Z or 0-9 keep it , otherwise use the hex value with prefix % so space is 0x20 hex convert it to %20.
Ha the good old reset button did it again.........
Who is online
Users browsing this forum: adam86shadow, balawi28, Bing [Bot], Google [Bot], JKJadan and 252 guests