【问题标题】:How to insert a line break in Autohotkey message box text如何在 Autohotkey 消息框文本中插入换行符
【发布时间】:2022-03-15 21:53:48
【问题描述】:

真的可以在消息框文本中插入换行符吗? 我进行了广泛搜索,每个人都在谈论'n\n,但这不起作用。 谁能给我一个实际有效的代码示例?

【问题讨论】:

  • 看来您使用的是撇号/单引号,看起来非常接近重音符。那将是失败的原因。它与标准英文键盘上的波浪号按钮是同一个键盘键。
  • 你能接受关闭问题的答案吗?

标签: autohotkey


【解决方案1】:

在 AutoHotkey 中,序列

`n

(后跟n 的反引号)表示换行符。

例如:

MsgBox, "line1`nline2`nline3"

产生如下输出:

line1
line2
line3

【讨论】:

  • 谢谢! “反引号”这个词是关键。我使用的是单引号,难怪我一无所获。
  • 是否可以将一个特别长的 200+ 个字符的 MsgBox 字符串分成多行? (即MsgBox This job may not have been added properly.`nPlease manually attach the job once this script has finished.
【解决方案2】:

你想要一个continuation section

这是一个示例脚本:

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

lorem = 
(
Lorem ipsum dolor sit? Knowin' embark a sword tharrr. Much bucket har, avast, Flying Dutchmen shaft craft legend sails runnin'. Poopdeck barrel shaft, scimitar captain brothel. West poopdeck cannon-ball gunpowder deck. Much kill sink many scalawag. Davey east direction davey shaft direction avast scimitar off drunk travel, crew. Bottle scurvy, pirates a. 

Strike stars, mast treasure. Arrrgh, boom bow strike her crows-nest brothel, bar be. 'Til ahoy bow smuggle stars crew mast myth head. Wreck many, bar sea scimitar har harbor. Other sea west bread death, raft poopdeck locker be matey ahoy? 

Embark explosion patch scalawag washed-up rudder pirate devil be, mast, with. Raft death shipment drink, those. Myth raid east, Kraken stars raid cannon-ball with scimitar gold, avast. Bread together runnin'? Be dispatch, her ahoy be Flying Dutchmen. Ahoy bread myth. Flying Dutchmen vessel bottle, poopdeck.
)

msgbox %lorem%

输出:

【讨论】:

    【解决方案3】:

    备选方案#1:在您的数据周围使用“( )”调用 Msgbox。

    Msgbox,
    (
        SUMMARY:
        ========================
        TOTAL : ALL______: %ALL%
        TOTAL : NON_BLANK: %TOT%
        BLANK : B4    TRM: %B_F%
        BLANK : AFTER TRM: %BAT%
        DUPES :__________: %NTS% ;;num_tok_skip
        UNIQUE:__________: %NTA% ;;num_tok_added
        ========================
    )
    ;; Above prints out a table of values: ALL, TOT, B_F, BAT, NTS, NTA
    ;; The are variables defined elsewhere in my code I wanted a printout 
    ;; in table from of.
    

    备选方案 #2: 这是我在创建要从自动热键粘贴的文本块时使用的另一种方法。我只是喜欢“CHR”命令而不是反引号。

    global cr_char := CHR(13)  ;AKA:  'r (return char)
    global lf_char := CHR(10)  ;AKA:  'n (newline char)
    global windows_newline := cr_char . lf_char
    

    【讨论】:

    • 哇,你真是个天才~!
    【解决方案4】:

    您可以在反引号中使用“r”。

    > `r`
    

    喜欢:

    ::@ph::Content-Type:application/json r X-Auth-Token:

    【讨论】:

    【解决方案5】:

    上面提到的答案 `n 真的很有帮助。

    我想我曾多次尝试包含 {Enter} 之类的内容,但此解决方案有效。 (对于命令行,否则,它会留下最后一行未发送...)

    ;; standard galactic ;;
    
    :*:myaliases::
    (
    alias ='alias'
    alias ='cd'
    alias ='less'
    alias ='ls'
    alias ='mkdir'
    alias ='echo $(moontop)'    
    alias ='touch'   
    alias ='vim'`n
    )
    

    :*: 导致它立即被评估 无需按空格或回车,因此不得不再次按回车来评估最后一行很烦人

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-09-07
      • 1970-01-01
      相关资源
      最近更新 更多