What's the difference of these two scripts ?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
hancre
Posts: 248
Joined: 02 Jul 2021, 20:51

What's the difference of these two scripts ?

22 Jul 2021, 19:40

I've used the first script(A) for web search.
but the second scipt works well.
What's the advantage and disadvantage of A and B?
I like a simple script like B. but I always want to get a perfect results.

Script A :

Code: Select all

^F12:: 
clipboard =   
Sleep 100
Send ^c
ClipWait, 1   
if ErrorLevel
 return
clipboard :=  Trim(clipboard)   
clipboard :=  RegExReplace(clipboard, "\.|,", "") 
DetectSave := A_DetectHiddenWindows
DetectHiddenWindows On    
SetTitleMatchMode 2
 clipboard :=  RegExReplace(clipboard, " ", "%20") 
 run, http://www.google.com/search?q=" clipboard
script B :

Code: Select all

Capslock & 4:: 
SendInput,^c 
Sleep 50
run, https://search.naver.com/search.naver?where=nexearch&query=%clipboard%
return
[Mod edit: [code][/code] tags added.]
User avatar
mikeyww
Posts: 26851
Joined: 09 Sep 2014, 18:38

Re: What's the difference of these two scripts ?

22 Jul 2021, 21:40

The first script has some good features to handle the clipboard properly and normalize URLs with spaces. Some of the features have questionable relevance. Use whichever script works for you. Multi-line routines should generally end in Return.
hancre
Posts: 248
Joined: 02 Jul 2021, 20:51

Re: What's the difference of these two scripts ?

22 Jul 2021, 23:44

mikeyww wrote:
22 Jul 2021, 21:40
The first script has some good features to handle the clipboard properly and normalize URLs with spaces. Some of the features have questionable relevance. Use whichever script works for you. Multi-line routines should generally end in Return.
Ok. I'll use the first script to prevent a few wrong case.
thanks for your reply.

ps. I have a question. I can use only quote, not reply.
If you know the reason, please let me know it.
gregster
Posts: 8990
Joined: 30 Sep 2013, 06:48

Re: What's the difference of these two scripts ?

23 Jul 2021, 02:01

hancre wrote:
22 Jul 2021, 23:44
ps. I have a question. I can use only quote, not reply.
If you know the reason, please let me know it.
Tried the Post Reply button at the bottom (or top) of the page, below the last post of the topic ?!?
It will take you to the full editor.

reply button.png
reply button.png (26.05 KiB) Viewed 317 times
User avatar
mikeyww
Posts: 26851
Joined: 09 Sep 2014, 18:38

Re: What's the difference of these two scripts ?

23 Jul 2021, 06:46

An example of this kind of script is below.

Code: Select all

^F12:: 
Clipboard =
Send ^c
ClipWait, 1
If ErrorLevel
 MsgBox, 48, Error, An error occurred while waiting for the clipboard.
Else Run, % "http://www.google.com/search?q=" StrReplace(Trim(Clipboard), " ", "%20")
Return
hancre
Posts: 248
Joined: 02 Jul 2021, 20:51

Re: What's the difference of these two scripts ?

23 Jul 2021, 07:25

mikeyww wrote:
23 Jul 2021, 06:46
An example of this kind of script is below.
Thanks for your clear code.
It looks perfect. ^^
Have a nice weekend.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: mikeyww, ReyAHK and 279 guests