Sign in to follow this  
Followers 0
TheMax

Script paused when minimized

6 posts in this topic

Hi !

I've read the help file and i've searched this board too but i'm still in the dark...

Here's my script :

#include <GUIConstants.au3>
#Include <Date.au3>

$test = GUICreate("test", 327, 173, 193, 125)
$check = GUICtrlCreateCheckbox("check1", 136, 104, 57, 17)
$inputH = GUICtrlCreateInput("", 88, 45, 33, 21)
$label1 = GUICtrlCreateLabel("H", 128, 48, 12, 17)
$input = GUICtrlCreateInput("", 176, 45, 33, 21)
$label2 = GUICtrlCreateLabel("MIN", 216, 48, 24, 17)
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    
    $time = _DateTimeFormat( _NowCalc(),5)
    $h = ControlGetText("", "", $inputH)
    $m = ControlGetText("", "", $input)
    
    If $msg = $GUI_EVENT_CLOSE Then
        Exit
    EndIf
    
    If ControlCommand("", "", $check, "IsChecked", "") = 1 And $time = $h&":"&$m&":00" Then
        MsgBox(0, "", "It's time !!")
    EndIf
WEnd

If the Windows time is the one you entered AND the checkbox is checked, there is a msgbox. But if the GUI is minimized or doesn't have the focus... nothing happends... ;)

I've made some sort of mp3player (using soundplay) and the "shuffle mode" is a checkbox and it works unless the mp3player's window is minimized or doesn't have the focus.

Did I miss somethings ? Is it an autoit limitation ?

If somebody can help me, it would be greatly appreciated. :)

Share this post


Link to post
Share on other sites



Not really sure if u really want the second to be "00" everytime? Work with this...

#include <GUIConstants.au3>
#Include <Date.au3>

$test = GUICreate("test", 327, 173, 193, 125)
$check = GUICtrlCreateCheckbox("check1", 136, 104, 57, 17)
$inputH = GUICtrlCreateInput("", 88, 45, 33, 21)
$label1 = GUICtrlCreateLabel("H", 128, 48, 12, 17)
$input = GUICtrlCreateInput("", 176, 45, 33, 21)
$label2 = GUICtrlCreateLabel("MIN", 216, 48, 24, 17)
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    
    Select
        
        Case $msg = $GUI_EVENT_CLOSE
        Exit
        
        Case $msg = $check
        $time = _DateTimeFormat( _NowCalc(),5)
        If GUICtrlRead($check) = 1 then 
        ;MsgBox(4096,"",$time)
            If $time = $inputH & ":" & $input & ":00" Then
            MsgBox(0, "", "It's time !!")
            EndIf
        EndIf
    
    EndSelect

WEnd

Share this post


Link to post
Share on other sites

To explain a bit why yours didn't work, and what I did to test it and fix it (so now you can troubleshoot a lot of your own issues )

#include <GUIConstants.au3>
#Include <Date.au3>
HotKeySet( "!t", "test" ) ;  This is how I was testing the variables data, and noticed that while minimized, your $h and $m vars had no data
$test = GUICreate("test", 327, 173, 193, 125)
$check = GUICtrlCreateCheckbox("check1", 136, 104, 57, 17)
$inputH = GUICtrlCreateInput("", 88, 45, 33, 21)
$label1 = GUICtrlCreateLabel("H", 128, 48, 12, 17)
$input = GUICtrlCreateInput("", 176, 45, 33, 21)
$label2 = GUICtrlCreateLabel("MIN", 216, 48, 24, 17)
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()

    $time = _DateTimeFormat(_NowCalc(), 5)
    $h = GUICtrlRead($inputH)  ;  Replaced ControlGetText with GUICtrlRead......  ControlGetText is more for getting text from another apps controlls
    If StringLen($h) = 1 Then $h = "0" & $h  ;  If the user only put 1 digit this will add a zero before it since thats what $time is set as
    $m = GUICtrlRead($input)  ;  Replaced ControlGetText with GUICtrlRead......  ControlGetText is more for getting text from another apps controlls
    If StringLen($m) = 1 Then $m = "0" & $m  ;  If the user only put 1 digit this will add a zero before it since thats what $time is set as
    If $msg = $GUI_EVENT_CLOSE Then
        Exit
    EndIf
    If GUICtrlRead($check) = 1 And $time = $h & ":" & $m & ":00"  Then
        MsgBox(0, "", "It's time !!")
    EndIf
    If GUICtrlRead($check) = 1 And $time = $h & ":" & $m & ":30"  Then
        MsgBox(0, "", "It's time !!")
    EndIf
    If GUICtrlRead($check) = 1 And $time = $h & ":" & $m & ":15"  Then
        MsgBox(0, "", "It's time !!")
    EndIf
    If GUICtrlRead($check) = 1 And $time = $h & ":" & $m & ":45"  Then
        MsgBox(0, "", "It's time !!")
    EndIf
    Sleep(10)
WEnd

Func test() ;  This is the function I am using to display the variables
    MsgBox(0, "test", "Check = " & GUICtrlRead( $check ) & @CRLF & "$h = " & $h & @CRLF & "$m = " & $m & @CRLF & "$time = " & $time)
EndFunc

Share this post


Link to post
Share on other sites

It's working ! Even minimized ! ;)

I'm gonna look closer to understand...

For instance I don't really understand the use of HotKeySet... I mean, of course I know how to use it but I don't see what it is doing to make the script work when minimized.

By the way... THANKS ! :)

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

The HotKeySet is not making the script work.... I left it there so you can see how I got to the root of the problem. I pressed Alt-t when the window was not minimized and saw that all variables were ok, but then when I had the window minimized and pressed Alt-t I saw that you were not getting values for $h or $m, so I then looked in your code where you obtain these values (" $h = ControlGetText("", "", $inputH) AND $m = ControlGetText("", "", $input)") and noticed they are not called in the traditional way (GuiCtrlRead).

Does that clear things up for you?

EDIT: more info:

You can delete the hotkey line and the test function, they were only for testing, but learn from the troubleshooting technique :)

Edited by danwilli

Share this post


Link to post
Share on other sites

Oh yeah, ok.

It'll help me later to debug my scripts...

Here I was juste using the wrong method to get data, that's all.

thanks a lot :)

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