Sign in to follow this  
Followers 0
Killerthibs

Doesn't work without focus

4 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



Are you trying to know if "check1" is checked with this?

ControlCommand("", "", $check, "IsChecked", "")=1

Use this instead:

GUICtrlRead($check)=$GUI_CHECKED

Share this post


Link to post
Share on other sites

That doesn't matter, the code here is just un example of a code which doesn't work if the script hasn't got focus.

So my question is just: How to make that script, for example, works without the focus?

Share this post


Link to post
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.

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