Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Auto script for msgboxs


  • Please log in to reply
13 replies to this topic
sleepyy35
  • Members
  • 193 posts
  • Last active: Apr 23 2008 08:18 PM
  • Joined: 22 Jul 2004
here is a tiny program i made to auto script msgboxs
i think you might have to right click then save target as to download

http://sleepyssin-fr... ... reator.zip
^sleepy^

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
nice. specially for newbies.

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


BoBo
  • Guests
  • Last active:
  • Joined: --
Guess what, a few days ago I thought about that ! Thx for sharing it. :D

Now to the other side of the coin :wink:

Would be nice to paste the generated code instead/additionaly to the clipboard.

The appeareance of the buttons needs some tweaking (yes, I'm a beancounter and I love symetric forms. No, not regarding women ... :lol: ) Currently the orientation of those buttons reminds me a little at a Pablo Picasso painting (just kidding) 8)

Ooops - its a BETA. Forget my above nonsense :wink:

oldbug
  • Members
  • 5 posts
  • Last active: Dec 21 2004 07:06 PM
  • Joined: 19 Dec 2004
Very Good!!!
But if change Buttons on GroupBox and RadioButton, will more understandable...

GroupButtons:
OK
OK/Cancel
Abort/Retry/Ignore
Yes/No/Cancel
Yes/No
Retry/Cancel

GroupIcons:
Icon None
Icon Hand
Icon Question
Icon Exclamation
Icon Asterisk

GroupModal:
Application
System Modal
Task Modal

sleepyy35
  • Members
  • 193 posts
  • Last active: Apr 23 2008 08:18 PM
  • Joined: 22 Jul 2004
Thank you guys for the nice words i'm going to do more with it i like the idea of the clipboard and the groupboxs thanx for the ideas :lol:
^sleepy^

ranomore
  • Members
  • 171 posts
  • Last active: Mar 01 2013 01:41 PM
  • Joined: 06 Nov 2004
I think this is really cool--I'm always going back to the help file to remember the numbers for the different box types. Maybe add the number in () next to the name of the button, like Yes No (4) or System Modal (4096), since numbers can be combined to make different button combinations for boxes?

...I had to look at the help file to make sure I got the right numbers in my post... :lol:

oldbug
  • Members
  • 5 posts
  • Last active: Dec 21 2004 07:06 PM
  • Joined: 19 Dec 2004
Hi. Here is simple MsgBox generator.
there is more correct code (without use *.ini, *.tmp and AutoHotkey.exe) but he big ~15kb


;Code
;#################### if extension *.ahk is not registered

IfNotExist, %A_ScriptDir%\msg.ini
{
FileSelectFile, SelectDirAHK, 1, %A_ProgramFiles%, Select  AutoHotkey.exe, AutoHotkey (AutoHotkey.exe)
if SelectDirAHK =
	{
	MsgBox, 4144, Exit, Cancel !
	ExitApp
	}
else
	IniWrite, %SelectDirAHK%, msg.ini, AHK, Dir
}

IfExist, %A_ScriptDir%\msg.ini
{
IniRead, AhkPath, %A_ScriptDir%\msg.ini, AHK, Dir
}
IfNotExist, %AhkPath%
{
	MsgBox, 4112, Error, AutoHotkey.exe not found !
	FileDelete, %A_ScriptDir%\msg.ini
	ExitApp
}


;#################### Form

Gui, Add, Button, gButtonClose x326 y360 w80 h33, Close
Gui, Add, Button, gButtonTest x226 y360 w80 h33, Clipboard

Gui, Add, GroupBox, x16 y127 w190 h145, Buttons
Gui, Add, Radio, vRadioOK x26 y147 w170 h20, OK
Gui, Add, Radio, vRadioOK_Cancel x26 y167 w170 h20, OK/Cancel
Gui, Add, Radio, vRadioAbort_Retry_Ignore x26 y187 w170 h20, Abort/Retry/Ignore
Gui, Add, Radio, vRadioYes_No_Cancel x26 y207 w170 h20, Yes/No/Cancel
Gui, Add, Radio, vRadioYes_No x26 y227 w170 h20, Yes/No
Gui, Add, Radio, vRadioRetry_Cancel x26 y247 w170 h20, Retry/Cancel

Gui, Add, GroupBox, x226 y127 w180 h220, Icon
Gui, Add, Radio, vRadioNone x236 y147 w110 h20, None
Gui, Add, Radio, vRadioHand x236 y187 w110 h20, Error
Gui, Add, Radio, vRadioQuestion x236 y227 w110 h20, Question
Gui, Add, Radio, vRadioExclamation x236 y267 w110 h20, Exclamation
Gui, Add, Radio, vRadioAsterisk x236 y307 w110 h20, Asterisk

Gui, Add, GroupBox, x16 y277 w190 h70, Modal
Gui, Add, Radio, vRadioTask x26 y297 w170 h20, Task
Gui, Add, Radio, vRadioSystem x26 y317 w170 h20, System                                                                       

Gui, Add, Text, x16 y7 w60 h15, Title
Gui, Add, Text, x16 y50 w60 h15, Message

Gui, Add, Edit, vEditTitle x16 y27 w390 h20,  
Gui, Add, Edit, vEditMessage x16 y67 w390 h50,    

;testing Win98
Gui, add, Picture, icon6 x356 y140 w32 h32, user.exe
Gui, add, Picture, icon4 x356 y177 w32 h32, user.exe
Gui, add, Picture, icon3 x356 y217 w32 h32, user.exe
Gui, add, Picture, icon2 x356 y257 w32 h32, user.exe
Gui, add, Picture, icon5 x356 y297 w32 h32, user.exe
;for XP do not know ???( user32.dll - icon100 - 104)

Gui, Add, GroupBox, x16 y353 w190 h40, Default Button
Gui, Add, Radio, vRadio1st x26 y367 w40 h20, 1st
Gui, Add, Radio, vRadio2nd x96 y367 w40 h20, 2nd
Gui, Add, Radio, vRadio3rd x164 y367 w40 h20, 3rd

GuiControl,, RadioOK, 1
GuiControl,, RadioNone, 1
GuiControl,, RadioTask, 1
GuiControl,, Radio1st, 1

Gui, Show, x148 y10 h410 w425, MsgBox Code Generator (for AHK)
Return

;#################### Main

ButtonTest:

GuiControlGet, RadioOK
GuiControlGet, RadioOK_Cancel
GuiControlGet, RadioAbort_Retry_Ignore
GuiControlGet, RadioYes_No_Cancel
GuiControlGet, RadioYes_No
GuiControlGet, RadioRetry_Cancel

GuiControlGet, RadioNone
GuiControlGet, RadioHand
GuiControlGet, RadioQuestion
GuiControlGet, RadioExclamation
GuiControlGet, RadioAsterisk

GuiControlGet, RadioTask
GuiControlGet, RadioSystem

GuiControlGet, EditTitle
GuiControlGet, EditMessage

GuiControlGet, Radio2nd
GuiControlGet, Radio3rd

EnvSet, VarInfo, 0

;#################### Radio Modal

if RadioSystem = 1
{
VarInfo = 4096
}
if RadioTask = 1
{
VarInfo = 8192
}

;#################### Radio Buttons

if RadioOK = 1
{
EnvAdd, VarInfo, 0
}
if RadioOK_Cancel = 1
{
EnvAdd, VarInfo, 1
}
if RadioAbort_Retry_Ignore = 1
{
EnvAdd, VarInfo, 2
}
if RadioYes_No_Cancel = 1
{
EnvAdd, VarInfo, 3
}
if RadioYes_No = 1
{
EnvAdd, VarInfo, 4
}
if RadioRetry_Cancel = 1
{
EnvAdd, VarInfo, 5
}

;#################### Radio Icons


if RadioNone = 1
{
EnvAdd, VarInfo, 0
}
if RadioHand = 1
{
EnvAdd, VarInfo, 16
}
if RadioQuestion = 1
{
EnvAdd, VarInfo, 32
}
if RadioExclamation = 1
{
EnvAdd, VarInfo, 48
}

if RadioAsterisk = 1
{
EnvAdd, VarInfo, 64
}

;#################### Radio Default Button

if Radio2nd = 1
{
EnvAdd, VarInfo, 256
}
if Radio3rd = 1
{
EnvAdd, VarInfo, 512
}

;#################### Output

IniRead, AhkPath, %A_ScriptDir%\msg.ini, AHK, Dir
OutputVar = MsgBox`, %VarInfo%`, %EditTitle%`, %EditMessage%
Clipboard = %OutputVar%
FileAppend, %OutputVar%, %A_ScriptDir%\~msg.tmp
RunWait, %AhkPath% %A_ScriptDir%\~msg.tmp
IfExist, %A_ScriptDir%\~msg.tmp, FileDelete, %A_ScriptDir%\~msg.tmp
Return

;#################### Close
ButtonClose:
FileDelete, %A_ScriptDir%\~msg.tmp
ExitApp

GuiClose:
FileDelete, %A_ScriptDir%\~msg.tmp
ExitApp;#################### if extension *.ahk is not registered

IfNotExist, %A_ScriptDir%\msg.ini
{
FileSelectFile, SelectDirAHK, 1, %A_ProgramFiles%, Select  AutoHotkey.exe, AutoHotkey (AutoHotkey.exe)
if SelectDirAHK =
	{
	MsgBox, 4144, Exit, Cancel !
	ExitApp
	}
else
	IniWrite, %SelectDirAHK%, msg.ini, AHK, Dir
}

IfExist, %A_ScriptDir%\msg.ini
{
IniRead, AhkPath, %A_ScriptDir%\msg.ini, AHK, Dir
}
IfNotExist, %AhkPath%
{
	MsgBox, 4112, Error, AutoHotkey.exe not found !
	FileDelete, %A_ScriptDir%\msg.ini
	ExitApp
}


;#################### Form

Gui, Add, Button, gButtonClose x326 y360 w80 h33, Close
Gui, Add, Button, gButtonTest x226 y360 w80 h33, Clipboard

Gui, Add, GroupBox, x16 y127 w190 h145, Buttons
Gui, Add, Radio, vRadioOK x26 y147 w170 h20, OK
Gui, Add, Radio, vRadioOK_Cancel x26 y167 w170 h20, OK/Cancel
Gui, Add, Radio, vRadioAbort_Retry_Ignore x26 y187 w170 h20, Abort/Retry/Ignore
Gui, Add, Radio, vRadioYes_No_Cancel x26 y207 w170 h20, Yes/No/Cancel
Gui, Add, Radio, vRadioYes_No x26 y227 w170 h20, Yes/No
Gui, Add, Radio, vRadioRetry_Cancel x26 y247 w170 h20, Retry/Cancel

Gui, Add, GroupBox, x226 y127 w180 h220, Icon
Gui, Add, Radio, vRadioNone x236 y147 w110 h20, None
Gui, Add, Radio, vRadioHand x236 y187 w110 h20, Error
Gui, Add, Radio, vRadioQuestion x236 y227 w110 h20, Question
Gui, Add, Radio, vRadioExclamation x236 y267 w110 h20, Exclamation
Gui, Add, Radio, vRadioAsterisk x236 y307 w110 h20, Asterisk

Gui, Add, GroupBox, x16 y277 w190 h70, Modal
Gui, Add, Radio, vRadioTask x26 y297 w170 h20, Task
Gui, Add, Radio, vRadioSystem x26 y317 w170 h20, System                                                                       

Gui, Add, Text, x16 y7 w60 h15, Title
Gui, Add, Text, x16 y50 w60 h15, Message

Gui, Add, Edit, vEditTitle x16 y27 w390 h20,  
Gui, Add, Edit, vEditMessage x16 y67 w390 h50,    

;testing Win98
Gui, add, Picture, icon6 x356 y140 w32 h32, user.exe
Gui, add, Picture, icon4 x356 y177 w32 h32, user.exe
Gui, add, Picture, icon3 x356 y217 w32 h32, user.exe
Gui, add, Picture, icon2 x356 y257 w32 h32, user.exe
Gui, add, Picture, icon5 x356 y297 w32 h32, user.exe
;for XP do not know ???( user32.dll - icon100 - 104)

Gui, Add, GroupBox, x16 y353 w190 h40, Default Button
Gui, Add, Radio, vRadio1st x26 y367 w40 h20, 1st
Gui, Add, Radio, vRadio2nd x96 y367 w40 h20, 2nd
Gui, Add, Radio, vRadio3rd x164 y367 w40 h20, 3rd

GuiControl,, RadioOK, 1
GuiControl,, RadioNone, 1
GuiControl,, RadioTask, 1
GuiControl,, Radio1st, 1

Gui, Show, x148 y10 h410 w425, MsgBox Code Generator (for AHK)
Return

;#################### Main

ButtonTest:

GuiControlGet, RadioOK
GuiControlGet, RadioOK_Cancel
GuiControlGet, RadioAbort_Retry_Ignore
GuiControlGet, RadioYes_No_Cancel
GuiControlGet, RadioYes_No
GuiControlGet, RadioRetry_Cancel

GuiControlGet, RadioNone
GuiControlGet, RadioHand
GuiControlGet, RadioQuestion
GuiControlGet, RadioExclamation
GuiControlGet, RadioAsterisk

GuiControlGet, RadioTask
GuiControlGet, RadioSystem

GuiControlGet, EditTitle
GuiControlGet, EditMessage

GuiControlGet, Radio2nd
GuiControlGet, Radio3rd

EnvSet, VarInfo, 0

;#################### Radio Modal

if RadioSystem = 1
{
VarInfo = 4096
}
if RadioTask = 1
{
VarInfo = 8192
}

;#################### Radio Buttons

if RadioOK = 1
{
EnvAdd, VarInfo, 0
}
if RadioOK_Cancel = 1
{
EnvAdd, VarInfo, 1
}
if RadioAbort_Retry_Ignore = 1
{
EnvAdd, VarInfo, 2
}
if RadioYes_No_Cancel = 1
{
EnvAdd, VarInfo, 3
}
if RadioYes_No = 1
{
EnvAdd, VarInfo, 4
}
if RadioRetry_Cancel = 1
{
EnvAdd, VarInfo, 5
}

;#################### Radio Icons


if RadioNone = 1
{
EnvAdd, VarInfo, 0
}
if RadioHand = 1
{
EnvAdd, VarInfo, 16
}
if RadioQuestion = 1
{
EnvAdd, VarInfo, 32
}
if RadioExclamation = 1
{
EnvAdd, VarInfo, 48
}

if RadioAsterisk = 1
{
EnvAdd, VarInfo, 64
}

;#################### Radio Default Button

if Radio2nd = 1
{
EnvAdd, VarInfo, 256
}
if Radio3rd = 1
{
EnvAdd, VarInfo, 512
}

;#################### Output

IniRead, AhkPath, %A_ScriptDir%\msg.ini, AHK, Dir
OutputVar = MsgBox`, %VarInfo%`, %EditTitle%`, %EditMessage%
Clipboard = %OutputVar%
FileAppend, %OutputVar%, %A_ScriptDir%\~msg.tmp
RunWait, %AhkPath% %A_ScriptDir%\~msg.tmp
IfExist, %A_ScriptDir%\~msg.tmp, FileDelete, %A_ScriptDir%\~msg.tmp
Return

;#################### Close
ButtonClose:
FileDelete, %A_ScriptDir%\~msg.tmp
ExitApp

GuiClose:
FileDelete, %A_ScriptDir%\~msg.tmp
ExitApp


polyethene
  • Members
  • 5519 posts
  • Last active: May 17 2015 06:39 AM
  • Joined: 26 Oct 2012
Cool, I've made one myself some time ago: http://get.filehosting.org/au16932.exe you could use some features that my one has. 8)

jchristl
  • Members
  • 42 posts
  • Last active: Apr 03 2016 10:27 PM
  • Joined: 13 Jan 2006
I think the first link is dead. Anyone have a copy on hand they could post here?

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005
Mmm, the script posted by oldbug is interesting.
Note he pasted the code twice...
It is a bit outdated (using EnvAdd for example), but the GUI isn't so bad, once I changed to order of controls for a more natural tab order.
So, after dusting it off, here is the 2006 version: :-)
/*
MsgBox generator by oldbug
http://www.autohotkey.com/forum/viewtopic.php?t=1631&p=9742#9742
Updated/Improved by Philippe Lhoste (PhiLho)
*/

;#################### Form

Gui Add, Text, x16 y7 w60 h15, Title
Gui Add, Text, x16 y50 w60 h15, Message

Gui Add, Edit, vtitle x16 y27 w390 h20,
Gui Add, Edit, vmessage x16 y67 w390 h50,

Gui Add, GroupBox, x16 y127 w190 h145, Buttons
Gui Add, Radio, vbuttonOK Checked x26 y147 w170 h20, OK
Gui Add, Radio, vbuttonOK_Cancel x26 y167 w170 h20, OK/Cancel
Gui Add, Radio, vbuttonAbort_Retry_Ignore x26 y187 w170 h20, Abort/Retry/Ignore
Gui Add, Radio, vbuttonYes_No_Cancel x26 y207 w170 h20, Yes/No/Cancel
Gui Add, Radio, vbuttonYes_No x26 y227 w170 h20, Yes/No
Gui Add, Radio, vbuttonRetry_Cancel x26 y247 w170 h20, Retry/Cancel

Gui Add, GroupBox, x16 y277 w190 h70, Modal
Gui Add, Radio, vmodalTask Checked x26 y297 w170 h20, Task
Gui Add, Radio, vmodalSystem x26 y317 w170 h20, System

Gui Add, GroupBox, x16 y353 w190 h40, Default Button
Gui Add, Radio, vdefault1st Checked x26 y367 w40 h20, 1st
Gui Add, Radio, vdefault2nd x96 y367 w40 h20, 2nd
Gui Add, Radio, vdefault3rd x164 y367 w40 h20, 3rd

Gui Add, GroupBox, x226 y127 w180 h220, Icon
Gui Add, Radio, viconNone Checked x236 y147 w110 h20, None
Gui Add, Radio, viconHand x236 y187 w110 h20, Error
Gui Add, Radio, viconQuestion x236 y227 w110 h20, Question
Gui Add, Radio, viconExclamation x236 y267 w110 h20, Exclamation
Gui Add, Radio, viconAsterisk x236 y307 w110 h20, Asterisk

If A_OSType = WIN32_WINDOWS
{
	; Win98
	Gui Add, Picture, icon6 x356 y140 w32 h32, user.exe
	Gui Add, Picture, icon4 x356 y177 w32 h32, user.exe
	Gui Add, Picture, icon3 x356 y217 w32 h32, user.exe
	Gui Add, Picture, icon2 x356 y257 w32 h32, user.exe
	Gui Add, Picture, icon5 x356 y297 w32 h32, user.exe
}
Else
{
	; WinXP
;~ 	Gui Add, Picture, icon50 x356 y140 w32 h32, shell32.dll
	Gui Add, Picture, icon4 x356 y177 w32 h32, user32.dll
	Gui Add, Picture, icon3 x356 y217 w32 h32, user32.dll
	Gui Add, Picture, icon2 x356 y257 w32 h32, user32.dll
	Gui Add, Picture, icon5 x356 y297 w32 h32, user32.dll
}

Gui Add, Button, gTestAndCopy Default x226 y360 w80 h33, Clipboard
Gui Add, Button, gGuiClose x326 y360 w80 h33, Close

Gui Show, x148 y10 h410 w425, MsgBox Code Generator (for AHK)
Return

;#################### Main

TestAndCopy:
	Gui Submit, NoHide

;#################### Radio buttons

options =
( Join|
buttonOK=0
buttonOK_Cancel=1
buttonAbort_Retry_Ignore=2
buttonYes_No_Cancel=3
buttonYes_No=4
buttonRetry_Cancel=5
iconNone=0
iconHand=16
iconQuestion=32
iconExclamation=48
iconAsterisk=64
default1st=0
default2nd=256
default3rd=512
modalSystem=4096
modalTask=8192
)

option = 0
; Check for each radio button if it is set, looping on the variable names
Loop Parse, options, |
{
	StringSplit option, A_LoopField, =
	If (%option1% = 1)
	{
		option += option2
	}
}

;#################### Message

If (InStr(message, "`n"))
{
	; Multiline
	If (StrLen(message) > 78)
	{
		; Long message: use a continuation section
		message = `n(`n%message%`n)
	}
	Else
	{
		; Replace newlines by the corresponding AHK escape sequence
		StringReplace message, message, `n, ``n, All
	}
}

;#################### Output

output = MsgBox %option%`, %title%`, %message%
Clipboard = %output%
; Test
FileAppend %output%, %A_ScriptDir%\~msg.tmp
RunWait %A_AhkPath% "%A_ScriptDir%\~msg.tmp"
FileDelete %A_ScriptDir%\~msg.tmp
Return

;#################### Close
GuiClose:
GuiEscape:
FileDelete %A_ScriptDir%\~msg.tmp
ExitApp

Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

jchristl
  • Members
  • 42 posts
  • Last active: Apr 03 2016 10:27 PM
  • Joined: 13 Jan 2006

Mmm, the script posted by oldbug is interesting.
Note he pasted the code twice...

Yeah, I thought that was my mistake at first when I tested them out.

It is a bit outdated (using EnvAdd for example), but the GUI isn't so bad, once I changed to order of controls for a more natural tab order.
So, after dusting it off, here is the 2006 version: :-)

Thanks. I kinda like these sorta things. Allows me to not use my head too much... if I want a quick message, I can just pound one out using these.

Koro
  • Guests
  • Last active:
  • Joined: --

output = MsgBox %option%`, %title%`, %message%
Clipboard = %output%
; Test
FileAppend %output%, %A_ScriptDir%\~msg.tmp
RunWait %A_AhkPath% %A_ScriptDir%\~msg.tmp
FileDelete %A_ScriptDir%\~msg.tmp
Return

;#################### Close
GuiClose:
GuiEscape:
FileDelete %A_ScriptDir%\~msg.tmp
ExitApp


What is that file handling for? Anyway it gives an error if the path to the script has a name with spaces on it (like "documents and settings"). I deleted all the file handling and it works perfect tho. I guess that was some 'debug' thing? :)

Thalon
  • Members
  • 641 posts
  • Last active: Jan 02 2017 12:17 PM
  • Joined: 12 Jul 2005
@sleepyy35
The zip-file is corrupt after downloading it :(
So, I can't test it...

Here is my version of a MessageBox Creator.
It is up to date (including also Help-Button and Allignment), but uses a higher GUI.

Thalon

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005

What is that file handling for? Anyway it gives an error if the path to the script has a name with spaces on it (like "documents and settings"). I deleted all the file handling and it works perfect tho. I guess that was some 'debug' thing? :)

No, it is just a kind of preview, ie. it shows the resulting real message box. Not essential, but nice.
I corrected my script to enclose the path to the generated script between double quotes in the RunWait, should work better.
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")