viewpoint-particle

Author Topic: Dynamic Dialog  (Read 2421 times)

bettman

  • Newbie
  • *
  • Posts: 41
Dynamic Dialog
« on: March 05, 2015, 08:16:15 am »
Greetings,

I hope someone can assist with an issue I'm having with a script. I have a script template which I use to install various software packages. This template reads an ini file to determine what needs to be run. Currently it use the astatusbar function to display a progress bar. The one drawback it has is if a step in the script takes a long time to run, the end user may mistakenly thinks that it is hung since there is no activity on the screen. I created the following dialog which displays activity lights (the ok button will be removed at a later time) and will update the statictext_9 control for each step of the install script The intention is to use it for display purposes only; there will be no user interaction while the dialog is displayed. My question is, where can I put the code for the software installation in the following script such that the "lights" will continue to change independent of any other action within the script?

***************************************************** New Dialog Script ******************************************************************************************************
#DefineSubRoutine InitDialogConstants()
   ;DialogprocOptions Constants
   MSG_INIT=0                    ; The one-time initialization
   MSG_TIMER=1                   ; Timer event
   MSG_BUTTONPUSHED=2            ; Pushbutton or Picturebutton
   MSG_RADIOPUSHED=3             ; Radiobutton clicked
   MSG_CHECKBOX=4                ; Checkbox clicked
   MSG_EDITBOX=5                 ; Editbox or Multilinebox
   MSG_FILESELECT=6              ; Filelistbox
   MSG_ITEMSELECT=7              ; Itembox
   MSG_COMBOCHANGE=8             ; Combobox/Droplistbox
   MSG_CALENDAR=9                ; Calendar date change
   MSG_SPINNER=10                ; Spinner number change
   MSG_CLOSEVIA49=11             ; Close clicked (Enabled via DialogProcOptions 1002
   MSG_FILEBOXDOUBLECLICK=12     ; Get double-click message on a FileListBox
   MSG_ITEMBOXDOUBLECLICK=13     ; Get double-click message on an ItemBox
   MSG_COMEVENT=14               ; COMCONTROL Event notification from DialogObject (NOT DialogProcOptions)
   MSG_MENUITEM=15               ; MenuItem selected
   MSG_MENUITEMINIT=16           ; MenuItem initialized
   MSG_RESIZE=17                 ; Dialog resized
   MSG_RVITEMSELROW=18           ; Reportview item select row
   MSG_RVDBLCLICKROW=19          ; Reportview double-click row
   MSG_RVCHECKEDITEM=20          ; Reportview checked/unchecked Item
   MSG_RVITEMTEXT=21             ; Reportview changed text of first column
   MSG_RVHEADER=22               ; Reportview header clicked

   ;Return code constants
   RET_DO_CANCEL=0           ; Cancels dialog
   RET_DO_DEFAULT= -1        ; Continue with default processing for control
   RET_DO_NOT_EXIT= -2       ; Do not exit the dialog
   Count = 1
   Counter = 1
   return
#EndSubroutine

InitDialogConstants()                                       ; Initialize Dialog Constants (need only be done once usually) 


#DefineSubroutine MyDialogCallbackProc(MyDialog_Handle,MyDialog_Message,MyDialog_Name,MyDialog_EventInfo,MyDialog_ChangeInfo)
   ON_EQUAL = @TRUE                                         ; Initialize variable ON_EQUAL
   switch MyDialog_Message                                  ; Switch based on Dialog Message type
      case MSG_INIT                                         ; Standard Initialization message
         DialogProcOptions(MyDialog_Handle,MSG_TIMER,1000)
         DialogProcOptions(MyDialog_Handle,MSG_BUTTONPUSHED,@TRUE)
       return(-1)

      Case 1
         DialogControlSet(MyDialog_Handle,'StaticText_1',11,'0|0|255')
         TimeDelay(.5)
         DialogControlSet(MyDialog_Handle,'StaticText_2',11,'0|0|255')
         TimeDelay(.5)
         DialogControlSet(MyDialog_Handle,'StaticText_3',11,'0|0|255')
         TimeDelay(.5)
         DialogControlSet(MyDialog_Handle,'StaticText_4',11,'0|0|255')
         TimeDelay(.5)
         DialogControlSet(MyDialog_Handle,'StaticText_5',11,'0|0|255')
         TimeDelay(.5)
         DialogControlSet(MyDialog_Handle,'StaticText_6',11,'0|0|255')   
         Timedelay(.5)
         DialogControlSet(MyDialog_Handle,'StaticText_1',11,'255|255|255')
         DialogControlSet(MyDialog_Handle,'StaticText_2',11,'255|255|255')
         DialogControlSet(MyDialog_Handle,'StaticText_3',11,'255|255|255')
         DialogControlSet(MyDialog_Handle,'StaticText_4',11,'255|255|255')
         DialogControlSet(MyDialog_Handle,'StaticText_5',11,'255|255|255')
         DialogControlSet(MyDialog_Handle,'StaticText_6',11,'255|255|255')
       Return(-2) 
      
     case MSG_BUTTONPUSHED                                 ; ID "PushButton_OK"  OK
     return(0)

   endswitch    ; MyDialog_Message     

   return(RET_DO_DEFAULT)
#EndSubroutine                                              ; End of Dialog Callback MyDialogCallbackProc


MyDialogFormat=`WWWDLGED,6.2`

MyDialogCaption=`LANDesk Software Deployment`
MyDialogX=-01
MyDialogY=-01
MyDialogWidth=258
MyDialogHeight=086
MyDialogNumControls=008
MyDialogProcedure=`MyDialogCallbackProc`
MyDialogFont=`DEFAULT`
MyDialogTextColor=`DEFAULT`
MyDialogBackground=`DEFAULT,192|192|192`
MyDialogConfig=0

MyDialog001=`121,067,014,012,PUSHBUTTON,"PushButton_OK",DEFAULT,"OK",1,10,32,DEFAULT,DEFAULT,DEFAULT`
MyDialog002=`067,055,014,006,STATICTEXT,"StaticText_1",DEFAULT,DEFAULT,DEFAULT,20,DEFAULT,"Microsoft Sans Serif|5632|40|34","255|255|255","255|255|255"`
MyDialog003=`089,055,014,006,STATICTEXT,"StaticText_2",DEFAULT,DEFAULT,DEFAULT,20,DEFAULT,"Microsoft Sans Serif|5632|40|34","255|255|255","255|255|255"`
MyDialog004=`111,055,014,006,STATICTEXT,"StaticText_3",DEFAULT,DEFAULT,DEFAULT,20,DEFAULT,"Microsoft Sans Serif|5632|40|34","255|255|255","255|255|255"`
MyDialog005=`155,055,014,006,STATICTEXT,"StaticText_5",DEFAULT,DEFAULT,DEFAULT,20,DEFAULT,"Microsoft Sans Serif|5632|40|34","255|255|255","255|255|255"`
MyDialog006=`133,055,014,006,STATICTEXT,"StaticText_4",DEFAULT,DEFAULT,DEFAULT,20,DEFAULT,"Microsoft Sans Serif|5632|40|34","255|255|255","255|255|255"`
MyDialog007=`177,055,014,006,STATICTEXT,"StaticText_6",DEFAULT,DEFAULT,DEFAULT,20,DEFAULT,"Microsoft Sans Serif|5632|40|34","255|255|255","255|255|255"`
MyDialog008=`029,017,200,028,STATICTEXT,"StaticText_9",DEFAULT,DEFAULT,DEFAULT,80,DEFAULT,DEFAULT,DEFAULT,DEFAULT`

ButtonPushed=Dialog("MyDialog")

exit

******************************************************* Current Install Script ********************************************************************************************
#DefineSubroutine MyDialogCallbackProc()

   Appwait = @Wait
   Apphide = @Normal

   Errormode(@off)

   RebootPending1 = RegQueryMulSz(@REGMachine,'System\CurrentControlSet\Control\Session Manager[PendingFileRenameOperations]',@tab)
   
If RebootPending1 <> 0
   RegDelValue(@REGMachine,'System\CurrentControlSet\Control\Session Manager[PendingFileRenameOperations]')
else   
endif

 If WinMetrics(-2) == 3 Then AddExtender("wwsop64i.dll")
  Else AddExtender("wwsop34i.dll")

  Apptitle=''
     Count = 1
     Sysdrive = Environment('Systemdrive')
     Windir = Environment('Windir')
     Currentdir = DirScript()
     AppCount = IniReadpvt('AppInfo','Count','','%Currentdir%\Appinfo.ini')
     MainAppTitle = IniReadPvt('AppInfo','MainAppTitle','','%Currentdir%\Appinfo.ini')
     Title="Software Deployment"         

     Steps = IniReadPvt('AppInfo','Countdown','0','%Currentdir%\Appinfo.ini')
     Countdown = Steps

     aStatusbar(0,title,"Process Starting",steps,Count)
     WindowOnTop(Title,1)

 If Steps == 0 then Goto Skip

 For Count = 0 to Steps
     aStatusbar(1,title,"A software update will begin in %Countdown% second(s). Please close all running programs at this time.",Steps,Count)
     TimeDelay(1)
     Countdown = Countdown - 1
 Next

 :Skip

     MainAppTitle = ('%Title% - %MainAppTitle%')   
 
     aStatusbar(0,MainAppTitle,"Process Starting",AppCount,0)
     WindowonTop(MainAppTitle,1)
     Count = 1
 For x = 1 to AppCount
     AppTitle = IniReadPvt('AppInfo','AppTitle%count%','','%Currentdir%Appinfo.ini')
     AppCommand = IniReadPvt('AppInfo','AppCMD%count%','','%Currentdir%Appinfo.ini')
     AppCommandLn = IniReadPvt('AppInfo','AppCMDLN%count%','','%Currentdir%Appinfo.ini')
     AppWaitFlag = IniReadPvt('AppInfo','Appwait%count%','','%Currentdir%Appinfo.ini')
     AppHideFlag = IniReadPvt('AppInfo','Apphide%count%','','%Currentdir%Appinfo.ini')
     aStatusbar(1,MainApptitle,'%AppTitle%, Please Wait.',AppCount,x)   
     Timedelay(1)
 If AppwaitFlag == 0 then Appwait = @Nowait
 If ApphideFlag == 0 then Apphide = @Icon
     Runshell(AppCommand,AppCommandLn,'',Apphide,Appwait)
     Count = Count + 1
   Appwait = @Wait
   Apphide = @Normal
 next

If RebootPending1 <> 0    
   RebootPending2 = RegQueryMulSz(@REGMachine,'System\CurrentControlSet\Control\Session Manager[PendingFileRenameOperations]',@tab)
   AnyUpdates = StrCharCount(RebootPending2)

 If AnyUpdates < 4
    WhatToUpdate = (RebootPending1)
  else
   WhattoUpdate = StrInsert(RebootPending1,RebootPending2,1)
  endif
   RegSetMulSz(@REGMachine,'System\CurrentControlSet\Control\Session Manager[PendingFileRenameOperations]',WhatToUpdate,@tab)
else
endif
     Date = TimeDate()
     RegSetValue(@Regmachine,'Software\LANDesk\InstalledApps[%MainAppTitle%]','Was installed on %Date%.')
 exit
#EndSubroutine
   MyDialogCallbackProc()
exit


td

  • Tech Support
  • *****
  • Posts: 3453
    • WinBatch
Re: Dynamic Dialog
« Reply #1 on: March 05, 2015, 01:52:19 pm »
The short answer is you can't put it anyplace if you want to use RunShell with   @WAIT option because you would need to disable the dialog while you were waiting and that also disables the timer.  Your best bet might be to start a separate WinBatch process that runs an install cover script. This could be done  from the timer case.  Your cover script would need to signal to the dialog script that it was complete so the dialog scrip would know to start the next install.

You could also search the Tech Database for examples of ways to display the progress or status of an extended length process. 
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade