Paulie Posted March 4, 2006 Share Posted March 4, 2006 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 Link to comment Share on other sites More sharing options...
Thatsgreat2345 Posted March 4, 2006 Share Posted March 4, 2006 (edited) ill look i saw a thread on this not to long ago Edited March 4, 2006 by thatsgreat2345 Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 4, 2006 Moderators Share Posted March 4, 2006 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). 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. Link to comment Share on other sites More sharing options...
Thatsgreat2345 Posted March 4, 2006 Share Posted March 4, 2006 (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 March 4, 2006 by thatsgreat2345 Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 4, 2006 Moderators Share Posted March 4, 2006 (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 March 4, 2006 by SmOke_N 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. Link to comment Share on other sites More sharing options...
Thatsgreat2345 Posted March 4, 2006 Share Posted March 4, 2006 (edited) i unistalled autoit to test and yeah it workshttp://www.autoitscript.com/forum/index.ph...wtopic=22374&hlit looks like herewasplato made it Edited March 4, 2006 by thatsgreat2345 Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 4, 2006 Moderators Share Posted March 4, 2006 i unistalled autoit to test and yeah it worksIf 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? 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. Link to comment Share on other sites More sharing options...
Thatsgreat2345 Posted March 4, 2006 Share Posted March 4, 2006 (edited) right ehre http://www.autoitscript.com/forum/index.ph...wtopic=22374&hlbut 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 March 4, 2006 by thatsgreat2345 Link to comment Share on other sites More sharing options...
herewasplato Posted March 4, 2006 Share Posted March 4, 2006 (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=155680Edit1:Here is a bit more info:http://www.autoitscript.com/forum/index.ph...ndpost&p=153249 Edited March 4, 2006 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 4, 2006 Moderators Share Posted March 4, 2006 Why thanks...direct link:http://www.autoitscript.com/forum/index.ph...ndpost&p=155680Edit1:Here is a bit more info:http://www.autoitscript.com/forum/index.ph...ndpost&p=153249Wow, a whole new world!! Thanks plato! 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. Link to comment Share on other sites More sharing options...
Valuater Posted March 4, 2006 Share Posted March 4, 2006 Nice one plato 8) Link to comment Share on other sites More sharing options...
greenmachine Posted March 4, 2006 Share Posted March 4, 2006 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. Link to comment Share on other sites More sharing options...
herewasplato Posted March 4, 2006 Share Posted March 4, 2006 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] Link to comment Share on other sites More sharing options...
greenmachine Posted March 4, 2006 Share Posted March 4, 2006 [....] 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. Link to comment Share on other sites More sharing options...
herewasplato Posted March 4, 2006 Share Posted March 4, 2006 (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 ;==>_RandomMoveMsgBoxEdit: An updated version of this code can be found here: http://www.autoitscript.com/forum/index.ph...showtopic=22531 Edited March 4, 2006 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
greenmachine Posted March 4, 2006 Share Posted March 4, 2006 Man, I didn't realize how cool that is until I ran it. Nice code. Link to comment Share on other sites More sharing options...
herewasplato Posted March 4, 2006 Share Posted March 4, 2006 (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 March 4, 2006 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
greenmachine Posted March 4, 2006 Share Posted March 4, 2006 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? Link to comment Share on other sites More sharing options...
herewasplato Posted March 4, 2006 Share Posted March 4, 2006 (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=22531Edit: 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 March 4, 2006 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
greenmachine Posted March 4, 2006 Share Posted March 4, 2006 Ok, sounds good. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now