Jump to content

Doesn't work without focus


Recommended Posts

Hello all :)

Here is an example of script which doesn't work if the GUI is minimize, or unfocus.

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

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

While 1
    $msg = GUIGetMsg()
    
    $time = _DateTimeFormat( _NowCalc(),5)
    $heure = ControlGetText("", "", $inputHeure)
    $min = ControlGetText("", "", $inputMinute)
    
    If $msg = $GUI_EVENT_CLOSE Then
        Exit
    EndIf
    
    If ControlCommand("", "", $check, "IsChecked", "") = 1 And $time = $heure&":"&$min&":00" Then
        MsgBox(0, "", "C'est l'heure !!")
    EndIf
WEnd

Is there a way to resolve that problem, or is it a limit of AutoIt?

Thank you very much ;)

Edited by Killerthibs
Link to comment
Share on other sites

$heure = ControlGetText("", "", $inputHeure)

This is saying get the active window, with what ever text, and look for that command. You aren't specifying any specific window to look for so of course the window has to be active because it grabs what ever window is active meaning if you GUI isn't the active one it won't do what you want. I'd recommend not using Control.... with GUI as there are other and more functions that will do it more successfully.

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...