Sign in to follow this  
Followers 0
Paulie

Random msgbox

21 posts in this topic

is there a wayy to make a box that appears when you use the "MsgBox" Command be created at a randm place on the screen, I browsed through an autoit function list but found no way to un-center the message box

an example of a portion of my code:

$i = 0
Do
    MsgBox(0, "Value of $i is:", $i)
    $i = $i + 1
Until $i = 10

I just want the message box to appear randomly on the screen

Ty in advance

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

ill look i saw a thread on this not to long ago

Edited by thatsgreat2345

Share this post


Link to post
Share on other sites

Your question is contradicting, do you want the text in the MsgBox() randomly placed or centered or the MsgBox() randomly placed on the screen or centered? If it is the MsgBox(), you'll need to create your own GUI MsgBox() because when MsgBox() is activated it basically pauses the script, So WinMove() (Unless maybe with a Hotkey (don't know never tried it) isn't effective).


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

yes i know i was confused so here is a topic that can help you [urlhttp://www.autoitscript.com/forum/index.php?showtopic=22374&hl

linked wrong topic

u can change the random the 1, is the minumum and the 50 is the maximum to either add or subtract

;requires beta
;sure seems like a GUI would be easier

_MoveMsgBox(0, "testTitle", "testText", 0 + Random(1,50), 100 - Random(1,50))

Func _MoveMsgBox($MBFlag, $MBTitle, $MBText, $x , $y)
    Local $file = FileOpen(EnvGet("temp") & "\MoveMB.au3", 2)
    If $file = -1 Then Return;if error, give up on the move
    
    Local $line1 = 'AutoItSetOption(' & '"WinWaitDelay", 0' & ')'
    Local $line2 = 'WinWait("' & $MBTitle & '", "' & $MBText & '")'
    Local $line3 = 'WinMove("' & $MBTitle & '", "' & $MBText & '"' & ', ' & $x & ', ' & $y & ')'
    FileWrite($file, $line1 & @CRLF & $line2 & @CRLF & $line3)
    FileClose($file)
    
    Run(@AutoItExe & " /AutoIt3ExecuteScript " & EnvGet("temp") & "\MoveMB.au3")
    
    MsgBox($MBFlag, $MBTitle, $MBText)
    
    FileDelete(EnvGet("temp") & "\MoveMB.au3")
EndFunc;==>_MoveMsgBox
Edited by thatsgreat2345

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Who wrote that? That's pretty damn nice!

Edit:

Hmmm, so this wouldn't run a PC that didn't have AutoIt.exe?

Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

i unistalled autoit to test and yeah it works

If you uninstalled it... Wonder how this worked - Run(@AutoItExe & " /AutoIt3ExecuteScript " & EnvGet("temp") & "\MoveMB.au3")

I'm not being a smartass, I'm being quite serious.

Can you post the link to where you found this udf?


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

right ehre http://www.autoitscript.com/forum/index.ph...wtopic=22374&hl

but i think its just cuz i added in the random + and - of the msgbox that it worked... cuz i have deepfreeze restarted my comp which theres no autoit on my comp and it still made it randomly, i was curious about that myself but it worked so whatever

Edited by thatsgreat2345

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Who wrote that? That's pretty damn nice!

Edit:

Hmmm, so this wouldn't run a PC that didn't have AutoIt.exe?

Why thanks...

direct link:

http://www.autoitscript.com/forum/index.ph...ndpost&p=155680

Edit1:

Here is a bit more info:

http://www.autoitscript.com/forum/index.ph...ndpost&p=153249

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

Wow, a whole new world!! Thanks plato!

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Nice one plato

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

If you uninstalled it... Wonder how this worked - Run(@AutoItExe & " /AutoIt3ExecuteScript " & EnvGet("temp") & "\MoveMB.au3")

I'm not being a smartass, I'm being quite serious.

Can you post the link to where you found this udf?

Herewasplato linked to good information, but I've answered this question a few times before and so I thought I'd add my input.

When AutoIt is compiled, the @AutoItExe points to the compiled exe itself (it wouldn't be very useful if you had to have AutoIt installed in order to run things). In each compiled exe are all the built-in functions available; the only things that are missing are the UDF's, hence the #include files. So, if you have the #include files copied in to your au3 script, or don't use any UDF's, you can run the script from the current compiled exe.

Share this post


Link to post
Share on other sites

Wow, a whole new world!! Thanks plato!

Credit goes to jpm for this tidbit of info:

"... it will reuse the AutoIt executable which allow your main script to run."

which prompted my little demo in that other thread.

Apparently it has been around a while:

27th November, 2005 - v3.1.1.91 (beta)

Changed : /c command line switch change to /AutoIt3ExecuteLine to allow /c to be use by the scripter in compiled scripts. (Thanks ..., Valik, SlimShady)

Updated : /AutoIt3ExecuteScript scriptfilename allow compiled script to execute script already install or just install by fileinstall. (Thanks Valik, SlimShady)

Fixed : FileRead returning @error=-1 on empty file. (Thanks AutoIt Smith)

A search of the beta help file for AutoIt3ExecuteScript showed this:

Form3: Compiled.exe [/ErrorStdOut][/AutoIt3ExecuteScript file] [params ...]

Execute from an compiled AutoIt3 Script File another script file. Like that you don't need to fileinstall another copy of the AutoIT3.exe in you compiled file.

The little UDF that I posted to that other thread is a lot of code/work just to move a msgbox - it was intended for those that don't want to build a GUI just yet... and as a demo for those that can see the power in that AutoIt3ExecuteScript feature.

Thanks goes to Valik and SlimShady for the feature.

Thanks for the include/UDF info greenmachine - I had not though of that :-)


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

[....]

Thanks for the include/UDF info greenmachine - I had not though of that :-)

I hadn't thought about it either until I was posting - I had to take a 5-minute break from the post and make a few scripts to test on my other computer to make sure. But it makes sense since they're external, and when compiling the whole file is copied into the script anyway.

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

...I just want the message box to appear randomly on the screen...

The code below requires the beta version of AutoIt3.
; Random Move Message Box
; Author - herewasplato

_RandomMoveMsgBox(0, "testTitle", "testText", 0, 10, 22, 333)

Func _RandomMoveMsgBox($MBFlag, $MBTitle, $MBText, $x, $y, $moves, $speed)
    Local $file = FileOpen(EnvGet("temp") & "\RandomMoveMB.au3", 2)
    If $file = -1 Then Return;if error, give up on the move
    
    Local $line1 = 'AutoItSetOption(' & '"WinWaitDelay", 0' & ')'
    Local $line2 = 'WinWait("' & $MBTitle & '", "' & $MBText & '")'
    Local $line3 = 'For $m = 1 to ' & $moves
    Local $line4 = '    WinMove("' & $MBTitle & '", "' & $MBText & '"' & ', Random(0, @DesktopWidth - 150, 1), Random(0, @DesktopHeight - 150, 1))'
    Local $line5 = '    Sleep(' & $speed & ')'
    Local $line6 = 'Next'
    FileWrite($file, $line1 & @CRLF & $line2 & @CRLF & $line3 & @CRLF)
    FileWrite($file, $line4 & @CRLF & $line5 & @CRLF & $line6)
    FileClose($file)
    
    Run(@AutoItExe & " /AutoIt3ExecuteScript " & EnvGet("temp") & "\RandomMoveMB.au3")
    
    MsgBox($MBFlag, $MBTitle, $MBText)
    
    FileDelete(EnvGet("temp") & "\RandomMoveMB.au3")
EndFunc ;==>_RandomMoveMsgBox
Edit: An updated version of this code can be found here:

http://www.autoitscript.com/forum/index.ph...showtopic=22531

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

Man, I didn't realize how cool that is until I ran it. Nice code.

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

Man, I didn't realize how cool that is until I ran it. Nice code.

Thanks - if you get really bored sometime, you can write the one that spirals the MsgBox from the center out or better yet, from the outter edge of the screen to the center :-) Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

Thanks - if you get really bored sometime, you can write the one that spirals the MsgBox from the center out or better yet, from the outter edge of the screen to the center :-)

Yes, I could do a lot with that...

I can see it now: _ChaosMsgBox() - moves the box around in a spiral, plus the window shake that someone made (sorry but I don't remember who), plus a beep every second to remind the user that it's still there... you might even be able to colorize it. That would be an incredible msgbox.

But I was just thinking, what if the user wants a timeout on the msgbox?

Share this post


Link to post
Share on other sites

#19 ·  Posted (edited)

...But I was just thinking, what if the user wants a timeout on the msgbox?

I almost put that into my first post the other day, but this is for someone that is not ready to make a GUI - the real solution. I feared making the parms too complicated.

I might just add a timeout parm to the code posted in Scripts and Scraps:

http://www.autoitscript.com/forum/index.ph...showtopic=22531

Edit: added timeout version.

@Paulie - sorry for all of the traffic - hope that you can find what you want in all of this.

and BTW - Welcome to the forums...

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

Ok, sounds good.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0