How to use " and ' in run command. Topic is solved

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
hancre
Posts: 251
Joined: 02 Jul 2021, 20:51

How to use " and ' in run command.

Post by hancre » 04 Mar 2024, 20:37

When I try these following codes, I've got the error.
Error: Failed attempt to launch program or document:
Action: <C:\Program Files\Microsoft VS Code\Code.exe"D:\common\source\AHK\V2-autohotkey-startup-gram.ahk", , Max>
Params: <>

Code: Select all

!l::Run "C:\Program Files\Microsoft VS Code\Code.exe" ('"D:\common\source\AHK\V2-autohotkey-startup-gram.ahk", , Max') 
!5::Run('"D:\common\source\AHK\V2-autohotkey-startup-gram.ahk"', , 'Max') 
!5::Run('D:\common\source\AHK\V2-autohotkey-startup-gram.ahk', , 'Max')

!c:: {
   A_clipboard :=""  
   Sleep 50
   SendInput "^c"
   Sleep 50
   searchTerm:=StrReplace(A_Clipboard," ","+")
   Run  'C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe' ("http://dic.naver.com/search.nhn?sLn=kr&searchOption=all&query= searchTerm")
   Run "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" ('https://dic.daum.net/search.do?q=' searchTerm)
   }
I've confirmed the path of program and files a few times.
How can i fix the issue? Thanks for any help in advance.

User avatar
mikeyww
Posts: 27366
Joined: 09 Sep 2014, 18:38

Re: How to use " and ' in run command.

Post by mikeyww » 04 Mar 2024, 21:11

Hello,

I am seeing a different error message. Are you running the script that you posted, or a different script?

1. Post your script.
2. Post a screenshot of the error message.

hancre
Posts: 251
Joined: 02 Jul 2021, 20:51

Re: How to use " and ' in run command.

Post by hancre » 04 Mar 2024, 21:27

Thanks for your help. ^^

I've attached 3 file image for error screenshot.

and I should make a image url due to an error during upload.
Visit https://imgur.com/a/yeYpdqj ( image tag : not available )
The codes're not different with the previous codes.
Attachments
temp_20240305_002.jpg
temp_20240305_002.jpg (52.86 KiB) Viewed 156 times
temp_20240305_003.jpg
temp_20240305_003.jpg (42.12 KiB) Viewed 156 times
temp_20240305_004.jpg
temp_20240305_004.jpg (95.5 KiB) Viewed 156 times

User avatar
mikeyww
Posts: 27366
Joined: 09 Sep 2014, 18:38

Re: How to use " and ' in run command.  Topic is solved

Post by mikeyww » 05 Mar 2024, 07:04

Your post is puzzling. Perhaps the script below will help.

Code: Select all

#Requires AutoHotkey v2.0
edge := EnvGet('ProgramFiles(x86)') '\Microsoft\Edge\Application\msedge.exe'
find := 'test+this'
url  := 'https://www.google.com/search?q='
Run edge ' ' url find

Code: Select all

#Requires AutoHotkey v2.0
edge := EnvGet('ProgramFiles(x86)') '\Microsoft\Edge\Application\msedge.exe'
find := 'test this'
url  := 'https://www.google.com/search?q='
Run edge ' ' url EncodeDecodeURI(find)

EncodeDecodeURI(str, encode := true, component := true) {
    ; Adapted from teadrinker: https://www.autohotkey.com/boards/viewtopic.php?p=372134#p372134
    ; https://www.autohotkey.com/boards/viewtopic.php?p=516899#p516899
    static Doc, JS
    if !IsSet(Doc) {
        Doc := ComObject("htmlfile")
        Doc.write('<meta http-equiv="X-UA-Compatible" content="IE=9">')
        JS := Doc.parentWindow
        ( Doc.documentMode < 9 && JS.execScript() )
    }
    Return JS.%( (encode ? "en" : "de") . "codeURI" . (component ? "Component" : "") )%(str)
}

hancre
Posts: 251
Joined: 02 Jul 2021, 20:51

Re: How to use " and ' in run command.

Post by hancre » 06 Mar 2024, 01:22

Thank you for your help.
I realized the way.

Code: Select all

Run '"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" "https://dic.daum.net/search.do?q="' IB.Value

User avatar
boiler
Posts: 17387
Joined: 21 Dec 2014, 02:44

Re: How to use " and ' in run command.

Post by boiler » 06 Mar 2024, 02:22

That looks wrong. You really would want the " before the value on the end? The whole URL should be enclosed in quotes, like this:

Code: Select all

Run '"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" "https://dic.daum.net/search.do?q=' IB.Value '"'

This demonstrates the difference:

Code: Select all

#Requires AutoHotkey v2.0
IB := InputBox('Enter search term: ', 'Search', 'h100')
MsgBox '"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" "https://dic.daum.net/search.do?q="' IB.Value, 'Your version'
MsgBox '"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" "https://dic.daum.net/search.do?q=' IB.Value '"', 'Corrected version'

Post Reply

Return to “Ask for Help (v2)”