Sign in to follow this  
Followers 0
nylo

GUI Hide & Show

3 posts in this topic

Hi,

Ok i have written a tiny proggy... an now i got some problems:

Heres the code:

Use the Pause Key on ur keyboard to hide and show(pauses the script) while its running

CODE

; Key Delay Options

Opt("SendKeyDownDelay", 1)

Opt("SendKeyDelay", 1)

; Key Delay Options End

Global $Paused

; Hotkey Settings

; Hotkey Settings End

HotKeySet("{PAUSE}", "TogglePause")

#include <GUIConstants.au3>

$Form1 = GUICreate("test", 234, 257, 525, 322)

While 1

; main PROGRAM goes here

WEnd

Func TogglePause()

$Paused = NOT $Paused

While $Paused

sleep(100)

ToolTip('Paused!',0,0)

GUISetState(@SW_SHOW)

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

EndSwitch

WEnd

WEnd

ToolTip("Running!")

GUISetState(@SW_HIDE)

endfunc

unfortunetly i have no practice with gui elements ;(

My idea:

1. Program is running

2. Pressing "Pause" Key > program stops and show the window

3. change some configs(for example 3 checkboxes)

4. Pressing "Pause" key again the program continues with the new values

ok, for example there are 3 checkboxes in the window, how to read their values

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

GUICtrlCreateCheckBox() has an example of how to read the state of an AutoIt GUI CheckBox (GUICtrlRead()).

If you mean another programs checkbox, then take a look at ControlCommand() in the help file.

Edited by SmOke_N

[center]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.[/center]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

#include <GuiConstants.au3>

HotKeySet("{PAUSE}", "TogglePause")

Opt("GUIOnEventMode", 1)

Global $pause[1], $chkstate[4]

For $i = 1 To 3 
$chkstate[$i] = "CheckBox" & $i & " Unchecked"
Next

$hmain = GuiCreate("CheckBoxes", 139, 140,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
GUISetOnEvent($GUI_EVENT_CLOSE, "close")
$Chkbox1 = GuiCtrlCreateCheckbox("Checkbox1", 20, 20, 100, 20)
GUICtrlSetOnEvent(-1, "chkstr")
$Chkbox2 = GuiCtrlCreateCheckbox("Checkbox2", 20, 50, 100, 20)
GUICtrlSetOnEvent(-1, "chkstr")
$Chkbox3 = GuiCtrlCreateCheckbox("Checkbox3", 20, 80, 90, 20)
GUICtrlSetOnEvent(-1, "chkstr")

GuiSetState()

While 1 
    Sleep(10)
WEnd

Func chkstr()
    Select
        Case @GUI_CTRLID = $Chkbox1
            $chkb1 = GUICtrlRead($Chkbox1)
            If $chkb1 = $GUI_UNCHECKED Then
                $chkstate[1] = "CheckBox 1 Unchecked"
            ElseIf $chkb1 = $GUI_CHECKED Then
                $chkstate[1] = "CheckBox 1 Checked"
            EndIf
        Case @GUI_CTRLID = $Chkbox2
            $chkb2 = GUICtrlRead($Chkbox2)
            If $chkb2 = $GUI_UNCHECKED Then
                $chkstate[2] = "CheckBox 2 Unchecked"
            ElseIf $chkb2 = $GUI_CHECKED Then
                $chkstate[2] = "CheckBox 2 Checked"
            EndIf
        Case @GUI_CTRLID = $Chkbox3
            $chkb3 = GUICtrlRead($Chkbox3)
            If $chkb3 = $GUI_UNCHECKED Then
                $chkstate[3] = "CheckBox 3 Unchecked"
            ElseIf $chkb3 = $GUI_CHECKED Then
                $chkstate[3] = "CheckBox 3 Checked"
            EndIf           
    EndSelect
EndFunc


Func TogglePause()
    If $pause[0] = "" Then
        GUISetState(@SW_HIDE,$hmain)
        $pause[0] = "Running"
        ToolTip($chkstate[1] & @LF & $chkstate[2] & @LF & $chkstate[3], @DesktopWidth/2, @DesktopHeight/2, $pause[0],1)
        Sleep(2000)
        ToolTip("")
        $pause[0] = "Paused"
    ElseIf $pause[0] = "Running" Then
        GUISetState(@SW_HIDE,$hmain)
        ToolTip($chkstate[1] & @LF & $chkstate[2] & @LF & $chkstate[3], @DesktopWidth/2, @DesktopHeight/2, $pause[0],1)
        Sleep(2000)
        ToolTip("")
        $pause[0] = "Paused"
    ElseIf $pause[0] = "Paused" Then
        GUISetState(@SW_SHOW,$hmain)
        ToolTip($chkstate[1] & @LF & $chkstate[2] & @LF & $chkstate[3], @DesktopWidth/2, @DesktopHeight/2, $pause[0],1)
        Sleep(2000)
        ToolTip("")
        $pause[0] = "Running"
    EndIf   
EndFunc

Func close()
    Exit
EndFunc

An example of GUICtrlRead with CheckBoxes (probly a bad example at that..lol)

Cheers

Edited by smashly

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