1

Тема: AHK: Вывести msgbox поверх всех окон не останавливая работу

Всем привет. Необходимо вывести на экран msgbox  с заранее скопированным текстом. Но msgbox  должен быть поверх всех окон, давая возможность его прочитать, в то время как скрипт продолжает выполняться.
Пробовал такие опции, но все равно ждет нажатия кнопки Ок.

MsgBox, 4096,, %clipboard%

2

Re: AHK: Вывести msgbox поверх всех окон не останавливая работу

Используйте обычное окно Gui вместо MsgBox.

Разработка AHK-скриптов:
e-mail dfiveg@mail.ru
Telegram jollycoder

3 (изменено: serzh82saratov, 2020-02-16 14:37:24)

Re: AHK: Вывести msgbox поверх всех окон не останавливая работу


SetTimer, Continue, -111
MsgBox
Continue:
Loop
	MsgBox,,, %A_TickCount%,0.3
Return
По вопросам возмездной помощи пишите на E-Mail: serzh82saratov@mail.ru Telegram: https://t.me/sergiol982
Win10x64 AhkSpy, Hotkey, ClockGui

4

Re: AHK: Вывести msgbox поверх всех окон не останавливая работу

Или так:


Text := clipboard

WTSSendMessage(Text, "", 0x0, 0, 0)
 
Loop
	MsgBox,,, %A_TickCount%, 0.6
Return

WTSSendMessage(Text, Title := "", Options := 0, Timeout := 0, Wait := True, Session := -1, Server := 0, ByRef Response := 0) {
    DllCall("winsta.dll\WinStationSendMessage"
        , "Ptr" , Server
        , "UInt", Session
        , "Str" , Title
        , "UInt", StrLen(Title) * 2
        , "Str" , Text
        , "UInt", StrLen(Text) * 2
        , "UInt", Options
        , "UInt", Timeout
        , "Int*", Response
        , "UInt", !Wait)

    Return {1: "OK", 2: "Cancel", 3: "Abort", 4: "Retry", 5: "Ignore", 6: "Yes", 7: "No", 10: "Try Again", 11: "Continue", 32000: "Timeout"}[Response]
}	
По вопросам возмездной помощи пишите на E-Mail: serzh82saratov@mail.ru Telegram: https://t.me/sergiol982
Win10x64 AhkSpy, Hotkey, ClockGui

5 (изменено: teadrinker, 2020-02-16 18:48:49)

Re: AHK: Вывести msgbox поверх всех окон не останавливая работу

serzh82saratov, последний код выдаёт сообщение с заголовком "Ошибка", которое не пропадает при завершении скрипта.

Разработка AHK-скриптов:
e-mail dfiveg@mail.ru
Telegram jollycoder

6

Re: AHK: Вывести msgbox поверх всех окон не останавливая работу

Заголовок во втором параметре задаётся.

teadrinker пишет:

не пропадает при завершении скрипта.

Да, оно принадлежит рабочему столу.

По вопросам возмездной помощи пишите на E-Mail: serzh82saratov@mail.ru Telegram: https://t.me/sergiol982
Win10x64 AhkSpy, Hotkey, ClockGui

7

Re: AHK: Вывести msgbox поверх всех окон не останавливая работу

Это для каких-нибудь системных уведомлений, я б такое не стал в скрипте использовать.

Разработка AHK-скриптов:
e-mail dfiveg@mail.ru
Telegram jollycoder

8

Re: AHK: Вывести msgbox поверх всех окон не останавливая работу

Согласен.
Можно для начала отсюда взять, я добавил параметр Wait.



MsgBoxEx("Text", "Title", "", [27, "imageres.dll"], "", "AlwaysOnTop", "", 0, "s18 c0x000000", "Showcard Gothic", "0x00FF00", 0)
MsgBox

MsgBoxEx(Text, Title := "", Buttons := "", Icon := "", ByRef CheckText := "", Styles := "", Owner := "", Timeout := "", FontOptions := "", FontName := "", BGColor := "", Wait := 1, Callback := "") {
    Static hWnd, y2, p, px, pw, c, cw, cy, ch, f, o, gL, hBtn, lb, DHW, ww, Off, k, v, RetVal
    Static Sound := {2: "*48", 4: "*16", 5: "*64"}

    Gui New, hWndhWnd LabelMsgBoxEx -0xA0000
    Gui % (Owner) ? "+Owner" . Owner : ""
    Gui Font
    Gui Font, % (FontOptions) ? FontOptions : "s9", % (FontName) ? FontName : "Segoe UI"
    Gui Color, % (BGColor) ? BGColor : "White"
    Gui Margin, 10, 12

    If (IsObject(Icon)) {
        Gui Add, Picture, % "x20 y24 w32 h32 Icon" . Icon[1], % (Icon[2] != "") ? Icon[2] : "shell32.dll"
    } Else If (Icon + 0) {
        Gui Add, Picture, x20 y24 Icon%Icon% w32 h32, user32.dll
        SoundPlay % Sound[Icon]
    }

    Gui Add, Link, % "x" . (Icon ? 65 : 20) . " y" . (InStr(Text, "`n") ? 24 : 32) . " vc", %Text%
    GuicontrolGet c, Pos
    GuiControl Move, c, % "w" . (cw + 30)
    y2 := (cy + ch < 52) ? 90 : cy + ch + 34

    Gui Add, Text, vf -Background ; Footer

    Gui Font
    Gui Font, s9, Segoe UI
    px := 42
    If (CheckText != "") {
        CheckText := StrReplace(CheckText, "*",, ErrorLevel)
        Gui Add, CheckBox, vCheckText x12 y%y2% h26 -Wrap -Background AltSubmit Checked%ErrorLevel%, %CheckText%
        GuicontrolGet p, Pos, CheckText
        px := px + pw + 10
    }

    o := {}
    Loop Parse, Buttons, |, *
    {
        gL := (Callback != "" && InStr(A_LoopField, "...")) ? Callback : "MsgBoxExBUTTON"
        Gui Add, Button, hWndhBtn g%gL% x%px% w90 y%y2% h26 -Wrap, %A_Loopfield%
        lb := hBtn
        o[hBtn] := px
        px += 98
    }
    GuiControl +Default, % (RegExMatch(Buttons, "([^\*\|]*)\*", Match)) ? Match1 : StrSplit(Buttons, "|")[1]

    Gui Show, Autosize Center Hide, %Title%
    DHW := A_DetectHiddenWindows
    DetectHiddenWindows On
    WinGetPos,,, ww,, ahk_id %hWnd%
    GuiControlGet p, Pos, %lb% ; Last button
    Off := ww - (((px + pw + 14) * A_ScreenDPI) // 96)
    For k, v in o {
        GuiControl Move, %k%, % "x" . (v + Off)
    }
    Guicontrol MoveDraw, f, % "x-1 y" . (y2 - 10) . " w" . ww . " h" . 48

    Gui Show
    Gui +SysMenu %Styles%
    DetectHiddenWindows %DHW%

    If (Timeout) {
        SetTimer MsgBoxExTIMEOUT, % Round(Timeout) * 1000
    }

    If (Owner) {
        WinSet Disable,, ahk_id %Owner%
    }

    GuiControl Focus, f
    Gui Font
	If Wait
		WinWaitClose ahk_id %hWnd%
    Return RetVal

    MsgBoxExESCAPE:
    MsgBoxExCLOSE:
    MsgBoxExTIMEOUT:
    MsgBoxExBUTTON:
        SetTimer MsgBoxExTIMEOUT, Delete

        If (A_ThisLabel == "MsgBoxExBUTTON") {
            RetVal := StrReplace(A_GuiControl, "&")
        } Else {
            RetVal := (A_ThisLabel == "MsgBoxExTIMEOUT") ? "Timeout" : "Cancel"
        }

        If (Owner) {
            WinSet Enable,, ahk_id %Owner%
        }

        Gui Submit
        Gui %hWnd%: Destroy
    Return
}
По вопросам возмездной помощи пишите на E-Mail: serzh82saratov@mail.ru Telegram: https://t.me/sergiol982
Win10x64 AhkSpy, Hotkey, ClockGui