ControleSend发送奇怪的输出Autohotkey

时间:2017-05-24 07:09:08

标签: autohotkey

我编写了一个脚本,可以向我的命令行发送一些按键。然而,价值观完全搞砸了。可能是什么原因?

BlockInput, on
WinGetActiveTitle, Title
DetectHiddenWindows, on
ControlClick, x660 y391, Notepad
ControlSend, , {Backspace}{Backspace}{Backspace}{Backspace}{Backspace}{Backspace}, Notepad
Sleep 30
ControlSend, ,  2, Notepad
Sleep 30
ControlSend, , echo stat_id: 78 : SETTING PRICE TO 2 toactivate: %Title% >>  logs.txt{Enter} , ahk_exe cmd.exe
ControlClick, x668 y640, Notepad
ControlSend, , echo  ACTION NEXT (after SETTING PRICE) >> logs.txt{Enter} , ahk_exe cmd.exe
WinActivate, %Title%
Send {Ctrl down}+{Ctrl up}
Send {Ctrl down}+{Ctrl up}
Send {Ctrl down}+{Ctrl up}
Send {Ctrl down}+{Ctrl up}
Send {Ctrl down}+{Ctrl up}
BlockInput, off
ExitApp
Return

这是输出的一个例子:

at-idec; ho78   B: EFSOETRTEI SNGCR PERENIC ESH TOOOT  2 DOTNOEAC >T>I valotges;. tixqt

echo  ACTION NEXT (after SETTING PREICCEHO)  >A>CT lioogn s.ntexxtt

2 个答案:

答案 0 :(得分:3)

有几件事需要提及

1)您不应该使用controlsend将文本发送到cmd提示符。相反,您应该使用Run, % Compsec。 ComSpec只是cmd.exe的快捷方式。所以,当你执行Run, % Compsec时,你真的只是传递cmd提示旁边的内容。运行ipconfig的示例:Run, % ComSpec " /k ipconfig"

要轻松记住要使用哪个开关,请记住/k将“在命令提示完成后保持命令提示”,并且/c将“在命令运行后关闭它”。

另外,请确保您了解Expression和非表达式之间的区别。 以下代码行看起来不同,但每行都完全相同:

Run, % ComSpec " /k ipconfig"
Run, %ComSpec% /k ipconfig

2)而不是写{Backspace}{Backspace}{Backspace}{Backspace}{Backspace}{Backspace},而是包括您希望在键名后但在结束大括号之前重复键的次数。 {Backspace 6}。这适用于任何密钥。

3)BlockInput可能是一个危险的命令,通常,我建议其他人尽可能避免使用它。通过使用Run ComSpec而不是control send,您可以删除任何使用BlockInput的需要。

4)您最初遇到的问题很可能与文本发送速度过快有关。使用SetKeyDelay降低发送速度。

尝试替换它:

ControlSend, , echo stat_id: 78 : SETTING PRICE TO 2 toactivate: %Title% >>  logs.txt{Enter} , ahk_exe cmd.exe

有了这个:

Run, % ComSpec " /k echo stat_id: 78 : SETTING PRICE TO 2 toactivate: " Title " >>  logs.txt"

答案 1 :(得分:0)

如果您确实想要发送到控制台,还有其他选择:

  • ConsoleSend()https://autohotkey.com/board/topic/25446-consolesend/
  • Windows 10 :您可以尝试粘贴文本,然后发送回车。 较旧的版本的Windows - 需要其他软件:我发现Clink是可靠的,因为您可以Send ^v安装它后cd to C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\bin then run command python dev_appserver.py C:\000_hello_endpoints(location) this will deploy your app locally on http://localhost:8080 Output : INFO 2017-05-25 13:51:20,782 devappserver2.py:692] Skipping SDK update check. INFO 2017-05-25 13:51:22,221 api_server.py:272] Starting API server at: http://localhost:21018 INFO 2017-05-25 13:51:22,232 dispatcher.py:205] Starting module "default" running at: localhost:8080 INFO 2017-05-25 13:51:22,232 admin_server.py:116] Starting admin server at: http://localhost:8000 2) Cloud app Deployment on Google app engine: Run gcloud init command in google cloud sdk shell: Choose the account you would like to use to perform operations for this configuration: [1] karanchaparwalops@gmail.com [2] Log in with a new account Please enter your numeric choice: 1 You are logged in as: [karanchaparwalops@gmail.com]. Pick cloud project to use: [1] machine-nebula-168 [2] Create a new project Please enter numeric choice or text value (must exactly match list item): 1 Your current project has been set to: [machine-nebula-168]. Do you want to configure Google Compute Engine (cloud.google.com/compute) settings (Y/n)? Y Which Google Compute Engine zone would you like to use as project default? If you do not specify a zone via a command line flag while working with Compute Engine resources, the default is assumed. [1] asia-east1-b [2] asia-east1-a [3] asia-east1-c [4] asia-northeast1-c [5] asia-northeast1-a [6] asia-northeast1-b [7] asia-southeast1-b [8] asia-southeast1-a [9] europe-west1-d [10] europe-west1-c [11] europe-west1-b [12] us-central1-b [13] us-central1-f [14] us-central1-a [15] us-central1-c [16] us-east1-d [17] us-east1-c [18] us-east1-b [19] us-east4-b [20] us-east4-c [21] us-east4-a [22] us-west1-b [23] us-west1-a [24] Do not set default zone Please enter numeric choice or text value (must exactly match list item): 1 Your project default Compute Engine zone has been set to [asia-east1-b]. You can change it by running [gcloud config set compute/zone NAME]. Your project default Compute Engine region has been set to [asia-east1]. You can change it by running [gcloud config set compute/region NAME]. Your Google Cloud SDK is configured and ready to use! * Commands that require authentication will use karanchaparwalops@gmail.com by default * Commands will reference project `machine-nebula-168` by default * Compute Engine commands will use region `asia-east1` by default * Compute Engine commands will use zone `asia-east1-b` by default Run `gcloud help config` to learn how to change individual settings This gcloud configuration is called [default]. You can create additional configurations if you work with multiple accounts and/or projects. Run `gcloud topic configurations` to learn more. Some things to try next: * Run `gcloud --help` to see the Cloud Platform services you can interact with. And run `gcloud help COMMAND` to get help on any gcloud command. * Run `gcloud topic -h` to learn about advanced features of the SDK like arg files and output formatting C:\000_Hello_Endpoints>gcloud app deploy You are creating an app for project [machine-nebula-168]. WARNING: Creating an App Engine application for a project is irreversible and the region cannot be changed. More information about regions is at cloud.google.com/appengine/docs/locations. Please choose the region where you want your App Engine application located: [1] europe-west (supports standard and flexible) [2] us-east1 (supports standard and flexible) [3] us-central (supports standard and flexible) [4] asia-northeast1 (supports standard and flexible) [5] us-east4 (supports standard and flexible) [6] cancel Please enter your numeric choice: 4 Creating App Engine application in project [machine-nebula-168] and region [asia-northeast1]....done. You are about to deploy the following services: - machine-nebula-168/default/20170525t134403 (from [C:\000_Hello_Endpoints\app.yaml]) Deploying to URL: [machine-nebula-168.appspot] Do you want to continue (Y/n)? Y Beginning deployment of service [default]... Some files were skipped. Pass `--verbosity=info` to see which ones. You may also view the gcloud log file, found at [C:\Users\KaranC\AppData\Roaming\gcloud\logs\2017.05.25\13.43.24.426000.log]. ╔════════════════════════════════════════════════════════════╗ ╠═ Uploading 4 files to Google Cloud Storage ═╣ ╚══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝ File upload done. Updating service [default]...done. Deployed service [default] to [machine-nebula-168.appspot] You can stream logs from the command line by running: $ gcloud app logs tail -s default To view your application in the web browser run: $ gcloud app browse C:\000_Hello_Endpoints>gcloud app browse Opening [https://machine-nebula-168.appspot.com] in a new tab in your default browser.