これを行う最も簡単な方法は、/AutoIt3ExecuteLine
コマンド ライン オプションを使用することです。これにより、コマンド ラインから 1 行のコードを実行できます。最も簡単には、次のように実装できます。
_ShowAnotherTooltip(1000, "Hello", 100, 100)
_ShowAnotherTooltip(1000, "World", 200, 200)
Func _ShowAnotherTooltip($time, $text, $x = Default, $y = Default, $title = "", $icon = Default, $options = Default)
Local $cmd = StringFormat("ToolTip(%s,%s,%s,%s,%s)", "'" & $text & "'", $x, $y, "'" & $title & "'", $icon, $options)
Run("""" & @AutoItExe & """ /AutoIt3ExecuteLine ""Sleep(" & $cmd & "*0+" & $time & ")""")
EndFunc ;==>_ShowAnotherTooltip
ここでの本当のトリッキーは、ツールチップを取得して 1 行でスリープすることだけです。生成されるコードは次のようになります。
Sleep(ToolTip('Hello', 100, 100, '', Default, Default)*0+1000)
お使いのコンピューターの性能によっては、2 つのツールチップが表示されるまでにかなりの遅延が見られる場合があります。それらをすべて同時に表示したい場合、コードはもう少し複雑になります。
If $CmdLine[0] And $CmdLine[1] = "/ExecuteLine" Then
; This is the child script
; Wait for the window to appear
WinWait($CmdLine[2])
; Then execute the line.
Execute($CmdLine[3])
Exit
EndIf
_AddAnotherTooltip(1000, "Hello", 100, 100)
_AddAnotherTooltip(1000, "World", 200, 200)
_ShowTheTooltips()
Func _ShowTheTooltips()
GUICreate("ShowThoseTooltipsNow")
Sleep(1000)
EndFunc ;==>_ShowTheTooltips
Func _AddAnotherTooltip($time, $text, $x = Default, $y = Default, $title = "", $icon = Default, $options = Default)
Local $cmd = StringFormat("ToolTip(%s,%s,%s,%s,%s)", "'" & $text & "'", $x, $y, "'" & $title & "'", $icon, $options)
Local $iPid
If @Compiled Then
$iPid = Run("""" & @AutoItExe & """ /ExecuteLine ShowThoseTooltipsNow ""Sleep(" & $cmd & "*0+" & $time & ")""")
Else
$iPid = Run("""" & @AutoItExe & """ """ & @ScriptFullPath & """ /ExecuteLine ShowThoseTooltipsNow ""Sleep(" & $cmd & "*0+" & $time & ")""")
EndIf
ProcessWait($iPid)
EndFunc ;==>_AddAnotherTooltip
プロセス間通信のより良い方法がありますが、これは非常に単純です。
最後に、おそらくGUITooltip * 関数を使用するより良い方法があります。