How to make a simple MsgBox spammer?

Get help with using AutoHotkey and its commands and hotkeys
SomebodyUnknown
Posts: 2
Joined: 12 May 2020, 09:59

How to make a simple MsgBox spammer?

12 May 2020, 10:06

How do I make a script that sends a MsgBox every second? Here is my current code:

Code: Select all

Loop
{
MsgBox, Hi!
Sleep, 1000
}
The problem is that the script pauses while the MsgBox is active, so there is only one box on the screen at a time. I'm new to AutoHotkey, so simple help would be appreciated.
User avatar
Tomer
Posts: 314
Joined: 21 Aug 2016, 05:11

Re: How to make a simple MsgBox spammer?

12 May 2020, 10:17

MsgBox is wating for user respond before continue,
You can use Gui instead.

Code: Select all

#NoEnv

Title := ""
Text  := "Hi!"

ShowGui:
MsgBox(Title,Text)
sleep, 1000
Return

MsgBox(Title,Text) {
   static WhiteBox,TextBox
   
   FontName     := "Segoe UI"    ; Name of font for text in Gui
   FontSize     := 9             ; Gui font size
   Gap          := 26            ; Spacing above and below text in top area of the Gui
   LeftMargin   := 12            ; Left Gui margin
   RightMargin  := 8             ; Space between right side of button and right Gui edge
   ButtonWidth  := 88            ; Width of OK button
   ButtonHeight := 26            ; Height of OK button
   ButtonOffset := 30            ; Offset between the right side of text and right edge of button
   MinGuiWidth  := 138           ; Minimum width of Gui
   SS_WHITERECT := 0x0006        ; Gui option for white rectangle (http://ahkscript.org/boards/viewtopic.php?p=20053#p20053)

   BottomGap := LeftMargin                          ; Set the distance between the bottom of the white box and the top of the OK button
   BottomHeight := ButtonHeight+2*LeftMargin+3      ; Calculate the height of the bottom section of the Gui
   Gui, Font, s%FontSize%, %FontName%               ; Set the font size and name
   Gui, +ToolWindow -MinimizeBox -MaximizeBox       ; Set the Gui so it doesn't have the icon, the minimize button, and the maximize button
   Gui, Add, Text, x0 y0 %SS_WHITERECT% vWhiteBox   ; Add a white box at the top of the window
   if Text                                                                    ; If the text field is not blank ...
   {  Gui, Add, Text, x%LeftMargin% y%Gap% BackgroundTrans vTextBox, %Text%   ; Add the text to the Gui
      GuiControlGet, Size, Pos, TextBox                                       ; Get the position of the text box
      GuiWidth := LeftMargin+SizeW+ButtonOffset+RightMargin+1                 ; Calculate the Gui width
      GuiWidth := GuiWidth < MinGuiWidth ? MinGuiWidth : GuiWidth             ; Make sure that it's not smaller than MinGuiWidth
      WhiteBoxHeight := SizeY+SizeH+Gap                                       ; Calculate the height of the white box
   }
   else                                                                       ; If the text field is blank ...
   {  GuiWidth := MinGuiWidth                                                 ; Set the width of the Gui to MinGuiWidth
      WhiteBoxHeight := 2*Gap+1                                               ; Set the height of the white box
      BottomGap++                                                             ; Increase the gap above the button by one
      BottomHeight--                                                          ; Decrease the height of the bottom section of the Gui
   }
   GuiControl, Move, WhiteBox, w%GuiWidth% h%WhiteBoxHeight%   ; Adjust the width and height of the white box
   ButtonX := GuiWidth-RightMargin-ButtonWidth                 ; Calculate the horizontal position of the button
   ButtonY := WhiteBoxHeight+BottomGap                         ; Calculate the vertical position of the button
   Gui, Add, Button, x%ButtonX% y%ButtonY% w%ButtonWidth% h%ButtonHeight% Default, OK   ; Add the OK button
   GuiHeight := WhiteBoxHeight+BottomHeight                    ; Calculate the overall height of the Gui
   Gui, Show, w%GuiWidth% h%GuiHeight%, %Title%                ; Show the Gui
   Gui, -ToolWindow                                            ; Remove the ToolWindow option so that the Gui has rounded corners and no icon
                                                               ; Trick from http://ahkscript.org/boards/viewtopic.php?p=11519#p1151
   Gui, Destroy
   gosub, ShowGui
   Return
   


   ButtonOK:
   GuiClose:
   GuiEscape:
   Gui Destroy
   Return
}
Last edited by Tomer on 12 May 2020, 10:18, edited 1 time in total.
User avatar
Smile_
Posts: 232
Joined: 03 May 2020, 00:51

Re: How to make a simple MsgBox spammer?

12 May 2020, 10:18

Use Time Out option to close current message box so the next can be displayed.

Code: Select all

Loop
{
    MsgBox,,, Hi!, 1  ; 1 means hold the message for 1 second then close it.
}
Documentation :arrow: https://www.autohotkey.com/docs/commands/MsgBox.htm#Timeout
Last edited by Smile_ on 12 May 2020, 11:37, edited 1 time in total.
User avatar
Tomer
Posts: 314
Joined: 21 Aug 2016, 05:11

Re: How to make a simple MsgBox spammer?

12 May 2020, 10:29

if you still want using MsgBox,
you can accept the msgbox by some key

Code: Select all

SetTimer, Ok, On

Loop
{
MsgBox, , MsgBox, Hi!
}

Ok:
WinWaitActive, MsgBox
Send, {Enter}
return
SomebodyUnknown
Posts: 2
Joined: 12 May 2020, 09:59

Re: How to make a simple MsgBox spammer?

12 May 2020, 14:10

Thanks everyone! The simple automatically closing MsgBox worked great.

Return to “Ask For Help”

Who is online

Users browsing this forum: boiler, rfmarves and 52 guests