how to get a working powershell command working in AHK v2 ?
-
- Posts: 23
- Joined: 03 Jan 2022, 14:40
how to get a working powershell command working in AHK v2 ?
Any idea how to get the following Capture2Text_CLI instruction working
in the powershell prompt this works
C:\Capture2Text\Capture2Text_CLI.exe --screen-rect "1000 335 1130 350" --whitelist "0123456789"
it gives the correct result : 736927
But how to run this command in AHK v2 ?
i tried :
Run "(C:\Capture2Text\Capture2Text_CLI.exe --screen-rect "1000 335 1130 350" --whitelist "0123456789")"
but this gives the following error in Visual studio Code:
[Running] "C:\Program Files\Autohotkey\AutoHotkey.exe" /ErrorStdOut=utf-8 "c:\Users\alber\OneDrive\Documents\Autohotkey\Untitled-1.ahk"
[Error] C:\Users\alber\OneDrive\Documents\Autohotkey\Untitled-1.ahk (4) : ==> Missing space or operator before this.
Specifically: 1000 335 1130 350" --whitelist "0123456789")")
in the powershell prompt this works
C:\Capture2Text\Capture2Text_CLI.exe --screen-rect "1000 335 1130 350" --whitelist "0123456789"
it gives the correct result : 736927
But how to run this command in AHK v2 ?
i tried :
Run "(C:\Capture2Text\Capture2Text_CLI.exe --screen-rect "1000 335 1130 350" --whitelist "0123456789")"
but this gives the following error in Visual studio Code:
[Running] "C:\Program Files\Autohotkey\AutoHotkey.exe" /ErrorStdOut=utf-8 "c:\Users\alber\OneDrive\Documents\Autohotkey\Untitled-1.ahk"
[Error] C:\Users\alber\OneDrive\Documents\Autohotkey\Untitled-1.ahk (4) : ==> Missing space or operator before this.
Specifically: 1000 335 1130 350" --whitelist "0123456789")")
- Attachments
-
- Screenshot 2022-08-09 143811.png (239 KiB) Viewed 2675 times
Last edited by gregster on 09 Aug 2022, 07:44, edited 1 time in total.
Reason: Topic moved from 'Scripts and Functions'.
Reason: Topic moved from 'Scripts and Functions'.
Re: how to get a working powershell command working in AHK v2 ?
In v2, you can use single quotes to mark the beginning and end of the literal string and double quotes inside of it:
(Moved topic to v2 section of "Ask For Help")
Code: Select all
Run '(C:\Capture2Text\Capture2Text_CLI.exe --screen-rect "1000 335 1130 350" --whitelist "0123456789")'
Re: how to get a working powershell command working in AHK v2 ?
Why the parenthesis?
Re: how to get a working powershell command working in AHK v2 ?
I was wondering the same. Just fixed the syntax issue. The parentheses are probably a misplaced attempt at adding the optional parentheses for the Run function.
-
- Posts: 23
- Joined: 03 Jan 2022, 14:40
Re: how to get a working powershell command working in AHK v2 ?
Run '(C:\Capture2Text\Capture2Text_CLI.exe --screen-rect "1000 335 1130 350" --whitelist "0123456789")'
not working, see screenshot
Error: Failed attempt to launch program or document
not working, see screenshot
Error: Failed attempt to launch program or document
- Attachments
-
- Screenshot 2022-08-09 145939.png (18.14 KiB) Viewed 2646 times
Re: how to get a working powershell command working in AHK v2 ?
Yes, did you see the comments about the parentheses not belonging? I previously was just pointing out how to handle the quotation marks issue without really looking at what you trying to do inside of them.
You also need to remove the parentheses or at least implement them correctly if you meant to include a function's optional parentheses. So it's either:
or:
You also need to remove the parentheses or at least implement them correctly if you meant to include a function's optional parentheses. So it's either:
Code: Select all
Run 'C:\Capture2Text\Capture2Text_CLI.exe --screen-rect "1000 335 1130 350" --whitelist "0123456789"'
Code: Select all
Run('C:\Capture2Text\Capture2Text_CLI.exe --screen-rect "1000 335 1130 350" --whitelist "0123456789"')
-
- Posts: 23
- Joined: 03 Jan 2022, 14:40
Re: how to get a working powershell command working in AHK v2 ?
i have enlarged the rectangle to search but still no results.
The following script still keeps returning an empty clipboard,so both statements don`t fill the clipboard. The powershell command :
C:\Capture2Text\Capture2Text_CLI.exe --screen-rect "1 1 1130 900" --whitelist "0123456789" returns lots of numbers.
[Mod edit: [code][/code] tags added.]
The following script still keeps returning an empty clipboard,so both statements don`t fill the clipboard. The powershell command :
C:\Capture2Text\Capture2Text_CLI.exe --screen-rect "1 1 1130 900" --whitelist "0123456789" returns lots of numbers.
Code: Select all
#Requires AutoHotkey v2.0-beta.1
sleep 3000
A_Clipboard := ""
Run 'C:\Capture2Text\Capture2Text_CLI.exe --screen-rect "1 1 1130 900" --whitelist "0123456789"'
msgbox A_Clipboard
sleep 3000
Run('C:\Capture2Text\Capture2Text_CLI.exe --screen-rect "1 1 1130 900" --whitelist "0123456789"')
msgbox A_Clipboard
-
- Posts: 23
- Joined: 03 Jan 2022, 14:40
Re: how to get a working powershell command working in AHK v2 ?
solved !! This worked
[Mod edit: [code][/code] tags added.]
Code: Select all
#Requires AutoHotkey v2.0-beta.1
sleep 3000
A_Clipboard := ""
Run('C:\Capture2Text\Capture2Text_CLI.exe --screen-rect "1 1 1130 900" --whitelist "0123456789" --clipboard')
sleep 3000
msgbox A_Clipboard
-
- Posts: 23
- Joined: 03 Jan 2022, 14:40
Re: how to get a working powershell command working in AHK v2 ?
All, thx for the help
-
- Posts: 23
- Joined: 03 Jan 2022, 14:40
Re: how to get a working powershell command working in AHK v2 ?
damm, i get numbers that i can´t explain so still not working correctly.
Re: how to get a working powershell command working in AHK v2 ?
Sounds just like the nature of OCR. Sometimes changing some of Capture2Text's settings can make a big difference. Whitelist is a big one, but you're already doing that. If you haven't whitelisted things like the decimal point (dot), then it won't find those and will try to force fit something else.
-
- Posts: 23
- Joined: 03 Jan 2022, 14:40
Re: how to get a working powershell command working in AHK v2 ?
If it was only for a few characters that went strange i would try on but it just produces totally rubbish. One realy can´t explain how even the --screen -rect should look like. I tried all kind of numbers for the coordinates and even there i see not much logic. So i stopped, after a few hours experimenting, trying to get this working. Any suggestions for other OCR solutions combined with AHK v2 ?
Re: how to get a working powershell command working in AHK v2 ?
I haven't done any OCR with v2, so I can't say. But in v1, I found other OCR libraries to be more reliable than Capture2Text.