Jump to content

Recommended Posts

Dunno why this isnt working...

HotKeySet("~", "Exit")
Func Exit()
Exit
EndFunc
While 1
MsgBox(0, "test", "test")
Sleep(6000)
Wend

I want message boxes to popup until ~ is pressed.

Thanks!

I hope you know what a spoiler is...[u]"title WOOPS:Var_start "WOOPS" %0goto Var_"-A true n00b at work[/u]
Link to comment
Share on other sites

You can't name a function after an AutoIt instruction. Try this:

HotKeySet("~", "Quit")
Func Quit()
    Exit
EndFunc
While 1
    MsgBox(0, "test", "test")
    Sleep(6000)
Wend
Link to comment
Share on other sites

msgbox is a standard windows popup box. AutoIt basically stops doing anything until that box is closed.

The timeout option is just a callout for that standard box, autoit itself is not doing anything to close it after x seconds.

If you want to do this, use the GUI fuctions, the gui will allow script steps to continue in the backround, and thus will allow you to close the gui itself with a hotkey, or by timed function, etc.

I would keep more standard naming for functions, and not use exit, run, or any other autoit script built in function names for UDFs. as well.

MsgBox, InputBox, and the open dialog all act this way.

HotKeySet("~", "Quit")

Func Quit()
    Exit
EndFunc

#include <GUIConstants.au3>

GUICreate("test",300,150); will create a dialog box that when displayed is centered
GUICtrlCreateLabel ("test",  10, 30, 50)
Opt("GUICoordMode",2)
$ok=GUICtrlCreateButton ("OK",  10, 30, 50)
$cancel=GUICtrlCreateButton ( "Cancel",  0, -1)

GUISetState ()   ; will display an  dialog box with 2 button

; Run the GUI until the dialog is closed
While 1
   tooltip(@min & ":" & @sec,0,0)
    $msg = GUIGetMsg()
    sleep(10)
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    If $msg = $ok Then
       ExitLoop
    EndIf
Wend

example2:

HotKeySet("~", "Quit")

Func Quit()
    Exit
EndFunc

#include <GUIConstants.au3>

GUICreate("test",200,100) ; will create a dialog box that when displayed is centered
$label=GUICtrlCreateLabel ("test",  10, 3, 150)
;
$ok=GUICtrlCreateButton ("OK",  30, 30, 50)
Opt("GUICoordMode",2)
$cancel=GUICtrlCreateButton ( "Cancel",  30, -1)

GUISetState ()    ; will display an  dialog box with 2 button

; Run the GUI until the dialog is closed
While 1
   GUICtrlSetData ($label,"test   " & @min & ":" & @sec); shows min:sec
    $msg = GUIGetMsg()
    sleep(10)
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    If $msg = $ok or $msg = $cancel Then
       ExitLoop
    EndIf
 Wend
 $msg1=GUICtrlRead ( $msg )
 GUIDelete()
msgbox(1,"button pressed was ", $msg1 )
Edited by scriptkitty

AutoIt3, the MACGYVER Pocket Knife for computers.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...