Wakesk8 Posted October 21, 2008 Share Posted October 21, 2008 Just started working with Autoit and am impressed with what it can do. Need some help on adding additional functionality to my first GUI. GUI currently will take input values and write to specified registry keys. Everything works great. I have an application which requires it's windows service to be bounced when a registry setting is updated. I need help in how to create (2) buttons in the GUI, one for stopping the specified service, the second to start the service. Any help would be greatly appreciated. Link to comment Share on other sites More sharing options...
rasim Posted October 21, 2008 Share Posted October 21, 2008 Wakesk8Welcome!Example:#include <GuiConstantsEx.au3> $hGUI = GUICreate("Test", 200, 100) GUICtrlCreateLabel("Spooler service", 60, 25, 90, 20) GUICtrlSetFont(-1, 9, 800) $StartService_Button = GUICtrlCreateButton("Start", 11, 69, 75, 25) $StopService_Button = GUICtrlCreateButton("Stop", 115, 69, 75, 25) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $StartService_Button _ServiceStartStop(1) Case $StopService_Button _ServiceStartStop() EndSwitch WEnd Func _ServiceStartStop($sFlag = 0) If $sFlag = 1 Then RunWait(@ComSpec & " /c sc.exe start spooler", @SystemDir, @SW_HIDE) Else RunWait(@ComSpec & " /c sc.exe stop spooler", @SystemDir, @SW_HIDE) EndIf EndFunc Link to comment Share on other sites More sharing options...
Wakesk8 Posted October 21, 2008 Author Share Posted October 21, 2008 So if I'm trying to start/stop the Alerter service: C:\WINDOWS\system32\svchost.exe, where would I add the service path? Link to comment Share on other sites More sharing options...
rasim Posted October 22, 2008 Share Posted October 22, 2008 Wakesk8sc.exe stop alerterGoogleLocal help: c:\WINDOWS\Help\ntcmds.chm Link to comment Share on other sites More sharing options...
Wakesk8 Posted November 3, 2008 Author Share Posted November 3, 2008 Script works perfect now. I've been trying to launch this from a parent GUI, get the child window, but I can't get the Service buttons to Start/Stop. How do I run the child window functions? Link to comment Share on other sites More sharing options...
rasim Posted November 4, 2008 Share Posted November 4, 2008 Wakesk8Show your code. Link to comment Share on other sites More sharing options...
Wakesk8 Posted November 5, 2008 Author Share Posted November 5, 2008 (edited) CODE#include <GUIConstants.au3> Opt("GUIOnEventMode", 1) $Form1_1 = GUICreate("AIM Editor Beta v1.1", 631, 737) GUISetBkColor(0xA6CAF0) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSE_Clicked") $Pic1_gif = @TempDir & "\aimsa.gif" FileInstall("C:\Documents and Settings\Administrator\Desktop\aimsa.gif", $Pic1_gif) $Pic1 = GUICtrlCreatePic($Pic1_gif, 0, 0, 172, 100) GUICtrlSetResizing(-1, $GUI_DOCKAUTO) $AQI = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AMI\CA\3.0\AIM", "IntervalArchiveQueueMonitoringinMinutes") $AQH = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AMI\CA\3.0\AIM", "IntervalArchiveQueueMonitoringInMinutes.Help") $ATI = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AMI\CA\3.0\AIM", "MaxArchiveTasks") $ATH = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AMI\CA\3.0\AIM", "MaxArchiveTasks.Help") $MFARI = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AMI\CA\3.0\AIM", "MaxFailedArchiveRequests") $MFARH = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AMI\CA\3.0\AIM", "MaxFailedArchiveRequests.Help") $FPR = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AMI\CA\3.0\AIM", "MaxFailedPrefetchRequests") $FPRH = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AMI\CA\3.0\AIM", "MaxFailedPrefetchRequests.Help") $PT = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AMI\CA\3.0\AIM", "MaxPrefetchTasks") $PTH = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AMI\CA\3.0\AIM", "MaxPrefetchTasks.Help") $FRR = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AMI\CA\3.0\AIM", "MaxFailedRetrieveRequests") $FRRH = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AMI\CA\3.0\AIM", "MaxFailedRetrieveRequests.Help") $RT = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AMI\CA\3.0\AIM", "MaxRetrieveTasks") $RTH = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AMI\CA\3.0\AIM", "MaxRetrieveTasks.Help") $RTA = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AMI\CA\3.0\AIM", "MaxRetrieveTasksForArchiving") $RTAH = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AMI\CA\3.0\AIM", "MaxRetrieveTasksForArchiving.Help") $RBS = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AMI\CA\3.0\AIM", "RetrieveBatchSize") $RBSH = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AMI\CA\3.0\AIM", "RetrieveBatchSize.Help") $RWT = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AMI\CA\3.0\AIM", "RetrieveWaitTimeInSeconds") $RWTH = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AMI\CA\3.0\AIM", "RetrieveWaitTimeInSeconds.Help") $ArchiveQueueLabel = GUICtrlCreateLabel("Archive Queue Monitor Interval (min)", 32, 129, 217, 20) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $ArchiveQueueInput = GUICtrlCreateInput($AQI, 441, 129, 78, 24) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $ArchiveQueueDefault = GUICtrlCreateLabel("60", 375, 131, 18, 20) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $ArchiveQueueUpdate = GUICtrlCreateButton("Update", 533, 131, 50, 20, 0) GUICtrlSetTip($ArchiveQueueUpdate, "Apply New Value to Archive Queue monitor") $Archive = GUICtrlCreateLabel("Archive", 32, 106, 56, 20) GUICtrlSetFont(-1, 10, 800, 4, "MS Sans Serif") GUICtrlSetColor(-1, 0x0000FF) $Default = GUICtrlCreateLabel("Default", 358, 108, 53, 20) GUICtrlSetFont(-1, 10, 800, 4, "MS Sans Serif") GUICtrlSetColor(-1, 0x0000FF) $New = GUICtrlCreateLabel("New Value", 441, 108, 78, 20) GUICtrlSetFont(-1, 10, 800, 4, "MS Sans Serif") GUICtrlSetColor(-1, 0x0000FF) $ArchiveQueueHelp = GUICtrlCreateLabel($AQH, 32, 153, 487, 17) GUICtrlSetColor(-1, 0xFF0000) $ArchiveTasksLabel = GUICtrlCreateLabel("Archive Tasks (max)", 32, 174, 126, 20) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $ArchiveTasksInput = GUICtrlCreateInput($ATI, 441, 174, 78, 24) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $ArchiveTasksDefault = GUICtrlCreateLabel("5", 379, 176, 11, 20) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $ArchiveTasksUpdate = GUICtrlCreateButton("Update", 533, 176, 50, 20, 0) GUICtrlSetTip($ArchiveTasksUpdate, "Apply New Maximum Value for Archive Tasks") $ArchiveTasksHelp = GUICtrlCreateLabel($ATH, 32, 198, 487, 17) GUICtrlSetColor(-1, 0xFF0000) $MaxFailedArchiveRequestsLabel = GUICtrlCreateLabel("Failed Archive Requests (max)", 32, 220, 167, 20) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $MaxFailedArchiveRequestsInput = GUICtrlCreateInput($MFARI, 441, 220, 78, 24) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $MaxFailedArchiveRequestsDefault = GUICtrlCreateLabel("100", 372, 222, 25, 20) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $maxFailedArchiveRequestsUpdate = GUICtrlCreateButton("Update", 533, 222, 50, 20, 0) GUICtrlSetTip($maxFailedArchiveRequestsUpdate, "Apply New Value For Failed Archive Requests") $MaxFailedArchiveRequestsHelp = GUICtrlCreateLabel($MFARH, 32, 244, 487, 34) GUICtrlSetColor(-1, 0xFF0000) $FailedPrefetchRequests = GUICtrlCreateLabel("Failed Prefetch Requests (max)", 32, 312, 191, 20) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $FailedPrefetchRequestsInput = GUICtrlCreateInput($FPR, 441, 312, 78, 24) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $FailedprefetchRequestsDefault = GUICtrlCreateLabel("100", 372, 314, 25, 20) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $FailedPrefetchRequestsUpdate = GUICtrlCreateButton("Update", 533, 314, 50, 20, 0) GUICtrlSetTip($FailedPrefetchRequestsUpdate, "Apply New Maximum Value for Failed Prefetch Requests") $Prefetch = GUICtrlCreateLabel("Prefetch", 32, 289, 61, 20) GUICtrlSetFont(-1, 10, 800, 4, "MS Sans Serif") GUICtrlSetColor(-1, 0x0000FF) $Default = GUICtrlCreateLabel("Default", 358, 291, 53, 20) GUICtrlSetFont(-1, 10, 800, 4, "MS Sans Serif") GUICtrlSetColor(-1, 0x0000FF) $New = GUICtrlCreateLabel("New Value", 441, 291, 78, 20) GUICtrlSetFont(-1, 10, 800, 4, "MS Sans Serif") GUICtrlSetColor(-1, 0x0000FF) $FailedPrefetchRequestsHelp = GUICtrlCreateLabel($FPRH, 32, 336, 487, 34) GUICtrlSetColor(-1, 0xFF0000) $PrefetchTasksLabel = GUICtrlCreateLabel("Prefetch Tasks (max)", 32, 374, 130, 20) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $PrefetchTasksInput = GUICtrlCreateInput($PT, 441, 374, 78, 24) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $PrefetchTasksDefault = GUICtrlCreateLabel("2", 379, 376, 11, 20) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $PrefetchTasksUpdate = GUICtrlCreateButton("Update", 533, 376, 50, 20, 0) GUICtrlSetTip($PrefetchTasksUpdate, "Apply New Maximum Value for Prefetch Tasks") $PrefetchTasksHelp = GUICtrlCreateLabel($PTH, 32, 398, 487, 17) GUICtrlSetColor(-1, 0xFF0000) $FailedRetrieveRequestsLabel = GUICtrlCreateLabel("Failed Retrieve Requests (max)", 32, 466, 193, 20) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $FailedRetrieveRequestsInput = GUICtrlCreateInput($FRR, 441, 466, 78, 24) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $FailedRetrieveRequestsDefault = GUICtrlCreateLabel("50", 375, 468, 18, 20) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $FailedRetrieveRequestsUpdate = GUICtrlCreateButton("Update", 533, 468, 50, 20, 0) GUICtrlSetTip($FailedRetrieveRequestsUpdate, "Apply New Maximum Value for Failed Retrieve Requests") $Retrieve = GUICtrlCreateLabel("Retrieve", 32, 443, 63, 20) GUICtrlSetFont(-1, 10, 800, 4, "MS Sans Serif") GUICtrlSetColor(-1, 0x0000FF) $Default = GUICtrlCreateLabel("Default", 358, 445, 53, 20) GUICtrlSetFont(-1, 10, 800, 4, "MS Sans Serif") GUICtrlSetColor(-1, 0x0000FF) $New = GUICtrlCreateLabel("New Value", 441, 445, 78, 20) GUICtrlSetFont(-1, 10, 800, 4, "MS Sans Serif") GUICtrlSetColor(-1, 0x0000FF) $FailedRetrieveRequestsHelp = GUICtrlCreateLabel($FRRH, 32, 490, 487, 34) GUICtrlSetColor(-1, 0xFF0000) $RetrieveTasksLabel = GUICtrlCreateLabel("Retrieve Tasks (max)", 32, 528, 132, 20) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $RetrieveTasksInput = GUICtrlCreateInput($RT, 441, 528, 78, 24) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $RetrieveTasksDefault = GUICtrlCreateLabel("5", 379, 530, 11, 20) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $RetrieveTasksUpdate = GUICtrlCreateButton("Update", 533, 530, 50, 20, 0) GUICtrlSetTip($RetrieveTasksUpdate, "Apply New Maximum Value for Retrieve Tasks") $RetrieveTasksHelp = GUICtrlCreateLabel($RTH, 32, 552, 487, 17) GUICtrlSetColor(-1, 0xFF0000) $RetrieveTasksArchivingLabel = GUICtrlCreateLabel("Retrieve Tasks for Archiving (max)", 32, 574, 208, 20) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $RetrieveTasksArchivingInput = GUICtrlCreateInput($RTA, 441, 574, 78, 24) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $RetrieveTasksArchivingDefault = GUICtrlCreateLabel("20", 375, 576, 18, 20) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $RetrieveTasksArchivingUpdate = GUICtrlCreateButton("Update", 533, 576, 50, 20, 0) GUICtrlSetTip($RetrieveTasksArchivingUpdate, "Apply New Maximum Value to Retrieve Tasks for Archiving") $RetrieveTasksArchivingHelp = GUICtrlCreateLabel($RTAH, 32, 598, 487, 17) GUICtrlSetColor(-1, 0xFF0000) $RetrieveBatchSizeLabel = GUICtrlCreateLabel("Retrieve Batch Size", 32, 620, 121, 20) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $RetrieveBatchSizeInput = GUICtrlCreateInput($RBS, 441, 620, 78, 24) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $RetrieveBatchSizeDefault = GUICtrlCreateLabel("100", 372, 622, 25, 20) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $RetrieveBatchSizeUpdate = GUICtrlCreateButton("Update", 533, 622, 50, 20, 0) GUICtrlSetTip($RetrieveBatchSizeUpdate, "Apply New Value for Retrieve Batch Size") $RetrieveBatchSizeHelp = GUICtrlCreateLabel($RBSH, 32, 644, 487, 17) GUICtrlSetColor(-1, 0xFF0000) $RetrieveWaitTimeLabel = GUICtrlCreateLabel("Retrieve Wait Time (sec)", 32, 666, 152, 20) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $RetrieveWaitTimeInput = GUICtrlCreateInput($RWT, 441, 666, 78, 24) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $RetrieveWaitTimeDefault = GUICtrlCreateLabel("10", 375, 668, 18, 20) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $RetrieveWaitTimeUpdate = GUICtrlCreateButton("Update", 533, 668, 50, 20, 0) GUICtrlSetTip($RetrieveWaitTimeUpdate, "Apply New Value for Retrieve Wait Time") $RetrieveWaitTimeHelp = GUICtrlCreateLabel($RWTH, 32, 690, 487, 17) GUICtrlSetColor(-1, 0xFF0000) $Presets = GUICtrlCreateCombo("AIM Presets", 176, 26, 130, 25) GUICtrlSetData(-1, "Test|ASP|Chuck"&Chr(39)&"s Settings") GUICtrlSetTip($Presets, "AIM presets defined by installation type") $Update_Preset = GUICtrlCreateButton("Set" , 306, 24, 40, 0) GUICtrlSetTip($Update_Preset, "Update AIM Preset Settings") $Communication = GUICtrlCreateButton("Communication", 378, 24, 100, 25, 0) GUICtrlSetTip($Communication, "Set AIM Communication Settings") GUICtrlSetOnEvent($Communication, "COMM_Edit") $DICOM = GUICtrlCreateButton("DICOM", 483, 24, 100, 25, 0) GUICtrlSetTip($DICOM, "Set AIM DICOM AET & Port") GUICtrlSetOnEvent($DICOM, "DICOM_Edit") $Services = GUICtrlCreateButton("Services", 378, 56, 100, 25, 0) GUICtrlSetTip($Services, "Start/Stop EA AIM Service") GUICtrlSetOnEvent($Services, "Services_StartStop") $CommGUI = GUICreate("Communication Settings", 400, 400) GUISetBkColor(0xA6CAF0) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSE_Clicked") GUISwitch($Form1_1) $DICOM_GUI = GUICreate("AIM DICOM Settings", 400, 400) GUISetBkColor(0xA6CAF0) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSE_Clicked") GUISwitch($Form1_1) $Services_GUI = GUICreate("Start/Stop EA AIM Service", 275, 100) GUISetBkColor(0xA6CAF0) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSE_Clicked") GUICtrlCreateLabel("EA AIM Service", 90, 30, 150, 20) GUICtrlSetFont(-1, 9, 800, 0,"MS Sans Serif") $StartService_Button = GUICtrlCreateButton("Start", 51, 69, 75, 25) $StopService_Button = GUICtrlCreateButton("Stop", 155, 69, 75, 25) GUISwitch($Form1_1) GUISetState(@SW_SHOW, $Form1_1) While 1 $msg = GUIGetMsg() #$nMsg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Func _ServiceStartStop($sFlag = 0) If $sFlag = 1 Then RunWait(@ComSpec & " /c sc.exe start alerter", @SystemDir, @SW_HIDE) Else RunWait(@ComSpec & " /c sc.exe stop alerter", @SystemDir, @SW_HIDE) EndIf EndFunc Func COMM_Edit() GUICtrlSetState($Communication, $GUI_DISABLE) GUISetState(@SW_SHOW, $CommGUI) EndFunc Func DICOM_Edit() GUICtrlSetState($DICOM, $GUI_DISABLE) GUISetState(@SW_SHOW, $DICOM_GUI) EndFunc Func Services_StartStop() GUICtrlSetState($Services, $GUI_DISABLE) GUISetState(@SW_SHOW, $Services_GUI) EndFunc Func CLOSE_Clicked() If @GUI_WinHandle = $Form1_1 Then Exit Else GUISetState(@SW_HIDE, $CommGUI) GUISetState(@SW_HIDE, $DICOM_GUI) GUISetState(@SW_HIDE, $Services_GUI) GUICtrlSetState($Communication, $GUI_ENABLE) GUICtrlSetState($DICOM, $GUI_ENABLE) GUICtrlSetState($Services, $GUI_ENABLE) EndIf EndFunc Case $msg = $ArchiveQueueInput $DATA_Value = GUICtrlRead($ArchiveQueueInput) RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\AMI\CA\3.0\AIM", "IntervalArchiveQueueMonitoringInMinutes", "REG_DWORD", $DATA_Value) Case $msg = $ArchiveTasksInput $DATA_Value = GUICtrlRead($ArchiveTasksInput) RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\AMI\CA\3.0\AIM", "MaxArchiveTasks", "REG_DWORD", $DATA_Value) Case $msg = $MaxFailedArchiveRequestsInput $DATA_Value = GUICtrlRead($MaxFailedArchiveRequestsInput) RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\AMI\CA\3.0\AIM", "MaxFailedArchiveRequests", "REG_DWORD", $DATA_Value) Case $msg = $FailedPrefetchRequestsInput $DATA_Value = GUICtrlRead($FailedPrefetchRequestsInput) RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\AMI\CA\3.0\AIM", "MaxFailedPrefetchRequests", "REG_DWORD", $DATA_Value) Case $msg = $PrefetchTasksInput $DATA_Value = GUICtrlRead($PrefetchTasksInput) RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\AMI\CA\3.0\AIM", "MaxPrefetchTasks", "REG_DWORD", $DATA_Value) Case $msg = $FailedRetrieveRequestsInput $DATA_Value = GUICtrlRead($FailedRetrieveRequestsInput) RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\AMI\CA\3.0\AIM", "MaxFailedRetrieveRequests", "REG_DWORD", $DATA_Value) Case $msg = $RetrieveTasksInput $DATA_Value = GUICtrlRead($RetrieveTasksInput) RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\AMI\CA\3.0\AIM", "MaxRetrieveTasks", "REG_DWORD", $DATA_Value) Case $msg = $RetrieveTasksArchivingInput $DATA_Value = GUICtrlRead($RetrieveTasksArchivingInput) RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\AMI\CA\3.0\AIM", "MaxRetrieveTasksForArchiving", "REG_DWORD", $DATA_Value) Case $msg = $RetrieveBatchSizeInput $DATA_Value = GUICtrlRead($RetrieveBatchSizeInput) RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\AMI\CA\3.0\AIM", "RetrieveBatchSize", "REG_DWORD", $DATA_Value) Case $msg = $RetrieveWaitTimeInput $DATA_Value = GUICtrlRead($RetrieveWaitTimeInput) RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\AMI\CA\3.0\AIM", "RetrieveWaitTimeInSeconds", "REG_DWORD", $DATA_Value) EndSwitch WEnd Edited November 5, 2008 by Wakesk8 Link to comment Share on other sites More sharing options...
rasim Posted November 5, 2008 Share Posted November 5, 2008 Wakesk8Please post a little as possible example, which represent your problem and use the code tags. Link to comment Share on other sites More sharing options...
Wakesk8 Posted November 5, 2008 Author Share Posted November 5, 2008 Included below are the specific pieces that don't seem to work. The GUI gets created but the buttons do not Start/Stop the requestsed Windows Service. Do I have to assign the function to only work with the GUI? CODE$Services_GUI = GUICreate("Start/Stop EA AIM Service", 275, 100) GUISetBkColor(0xA6CAF0) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSE_Clicked") GUICtrlCreateLabel("EA AIM Service", 90, 30, 150, 20) GUICtrlSetFont(-1, 9, 800, 0,"MS Sans Serif") $StartService_Button = GUICtrlCreateButton("Start", 51, 69, 75, 25) $StopService_Button = GUICtrlCreateButton("Stop", 155, 69, 75, 25) GUISwitch($Form1_1) GUISetState(@SW_SHOW, $Form1_1) ##################### $msg = GUIGetMsg() #$nMsg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Func _ServiceStartStop($sFlag = 0) If $sFlag = 1 Then RunWait(@ComSpec & " /c sc.exe start alerter", @SystemDir, @SW_HIDE) Else RunWait(@ComSpec & " /c sc.exe stop alerter", @SystemDir, @SW_HIDE) EndIf EndFunc Link to comment Share on other sites More sharing options...
Wakesk8 Posted November 18, 2008 Author Share Posted November 18, 2008 Any help on getting the services start/stop from within child GUI? Link to comment Share on other sites More sharing options...
MisterF Posted November 20, 2008 Share Posted November 20, 2008 (edited) Any help on getting the services start/stop from within child GUI?GUIGetMsg() can work in advanced mode(see autoit help). I use something like that While 1 $msg = GUIGetMsg(1) Select Case $msg[0] == $GUI_EVENT_CLOSE Exit Case $msg[0] == $StartService_Button And $msg[1] == $Services_GUI _ServiceStartStop(1) Case $msg[0] == $StopService_Button And $msg[1] == $Services_GUI _ServiceStartStop() EndSelect WEnd Edited November 20, 2008 by MisterF Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now