1 votes

AHK besoin d'aide pour faire un bouton gui AHK pour lancer 3 différents scripts.

Nouveau à la programmation et AHK besoin d'aide pour construire AHK GUI avec au moins trois boutons pour exécuter 3 différents scripts, et pour montrer la couleur dans le bouton pourrait être vert pour montrer que le scripts est en cours d'exécution et si je clique à nouveau pour le faire arrêter alors devient rouge. J'ai quelque chose mais je voudrais ajouter comme une couleur aux boutons pour savoir que le scripts n'est pas en cours d'exécution ou qu'il l'est.

Gui, Add, Button, w200 h50 gTest1 , Run test1.AHK Script
Gui, Add, Button, w200 h50 gTest2 , Run test2.AHK Script
Gui, Show,, Print Options
Return

Test1:
Run combine_scripts.ahk
Return

Test2:
Run fast.ahk
Return

1voto

user3419297 Points 2735

Essayez ceci

#NoEnv
#SingleInstance Force
SetWorkingDir %A_ScriptDir%

DetectHiddenWindows On
SetTitleMatchMode 2

If WinExist("Script1.ahk - AutoHotkey v1 ahk_class AutoHotkey")
    S1 := true
else
    S1 := false
If WinExist("Script2.ahk - AutoHotkey v1 ahk_class AutoHotkey")
    S2 := true
else
    S2 := false
If WinExist("Script3.ahk - AutoHotkey v1 ahk_class AutoHotkey")
    S3 := true
else
    S3 := false

Gui -Caption +AlwaysOnTop 
Gui, Font, s12, Verdana 

If (S1)
{
    Gui, Add, Button, x5 w70 h20 gRunStopScript1, Stop
    Gui, Add, Progress, vA1 x80 ym w300 h20 cGreen, 100
}
else
{
    Gui, Add, Button, x5 w70 h20 gRunStopScript1, Run
    Gui, Add, Progress, vA1 x80 ym w300 h20 cRed, 100
}
Gui, Add, Text, xp+20 vB1 w200 cWhite +BackgroundTrans, Script1.ahk

If (S2)
{
    Gui, Add, Button, x5 w70 h20 gRunStopScript2, Stop
    Gui, Add, Progress, vA2 x80 y37 w300 h20 cGreen, 100
}
else
{
    Gui, Add, Button, x5 w70 h20 gRunStopScript2, Run
    Gui, Add, Progress, vA2 x80 y37 w300 h20 cRed, 100
}
Gui, Add, Text, xp+20 vB2 w200 cWhite +BackgroundTrans, Script2.ahk

If (S3)
{
    Gui, Add, Button, x5 w70 h20 gRunStopScript3, Stop
    Gui, Add, Progress, vA3 x80 y67 w300 h20 cGreen, 100
}
else
{
    Gui, Add, Button, x5 w70 h20 gRunStopScript3, Run
    Gui, Add, Progress, vA3 x80 y67 w300 h20 cRed, 100
}
Gui, Add, Text, xp+20 vB3 w200 cWhite +BackgroundTrans, Script3.ahk

SetTimer, ReloadScript, 1000 

Gui, Show, x10 y10, Run/Stop a Script
Return

RunStopScript1:
If (S1)
    WinClose, Script1.ahk - AutoHotkey v1 ahk_class AutoHotkey
else
    Run, Script1.ahk
Reload
Return

RunStopScript2:
If (S2)
    WinClose, Script2.ahk - AutoHotkey v1 ahk_class AutoHotkey
else
    Run, Script2.ahk
Reload
Return

RunStopScript3:
If (S3)
    WinClose, Script3.ahk - AutoHotkey v1 ahk_class AutoHotkey
else
    Run, Script3.ahk
Reload
Return

ReloadScript:
If (S1)
{
    If !WinExist("Script1.ahk - AutoHotkey v1 ahk_class AutoHotkey")
        Reload
}
else
{
    If WinExist("Script1.ahk - AutoHotkey v1 ahk_class AutoHotkey")
        Reload
}
If (S2)
{
    If !WinExist("Script2.ahk - AutoHotkey v1 ahk_class AutoHotkey")
        Reload
}
else
{
    If WinExist("Script2.ahk - AutoHotkey v1 ahk_class AutoHotkey")
        Reload
}
If (S3)
{
    If !WinExist("Script3.ahk - AutoHotkey v1 ahk_class AutoHotkey")
        Reload
}
else
{
    If WinExist("Script3.ahk - AutoHotkey v1 ahk_class AutoHotkey")
        Reload
}
Return

1 votes

Ty friend Je vais essayer.

SistemesEz.com

SystemesEZ est une communauté de sysadmins où vous pouvez résoudre vos problèmes et vos doutes. Vous pouvez consulter les questions des autres sysadmins, poser vos propres questions ou résoudre celles des autres.

Powered by:

X