COMate - control COM objects via automation - OBSOLETE!

Developed or developing a new product in PureBasic? Tell the world about it.
CNESM
User
User
Posts: 54
Joined: Sat Jun 21, 2003 11:15 pm
Contact:

Post by CNESM »

@ srod

Maybe a little Off-Topic but in the german board kiffi posted a create further example for using COMate. The example goes around using the excel chart and excel spreadsheet from Microsoft. Its neccessary that you have installed Excel and the OWC.....Dll (Office web Components). Maybe you will put this code to the example collection of the COMate download file:

Code: Select all

XIncludeFile "COMate_Residents.pbi"
XIncludeFile "COMate.pbi"

ExcelObject.COMateObject 
ExcelObject1.COMateObject 

If OpenWindow(0,#PB_Ignore,#PB_Ignore,800,800,"COMate: OWC11.Spreadsheet-Demo",#PB_Window_Invisible|#PB_Window_SystemMenu) 
    
  ExcelObject=COMate_CreateActiveXControl(0,0,800,400,"OWC11.Spreadsheet") 
  
  If ExcelObject 
  
    ExcelObject\SetProperty("Cells(1,1) = 'Özgür'") 
    ExcelObject\SetProperty("Cells(1,2) = 'Levent'") 
    ExcelObject\SetProperty("Cells(2,1) = 10") 
    ExcelObject\SetProperty("Cells(2,2) = 20") 
    
    ExcelObject\SetProperty("Cells(1, 1)\Interior\Color = 18915966") 
    ExcelObject\SetProperty("Cells(1, 2)\Interior\Color = 18915966") 
    ExcelObject\SetProperty("Cells(2, 1)\Interior\Color = 18915966") 
    ExcelObject\SetProperty("Cells(2, 2)\Interior\Color = 18915966") 
    
    ExcelObject\SetProperty("Cells(1, 1)\Font\Color = 255255255") 
    ExcelObject\SetProperty("Cells(1, 2)\Font\Color = 255255255") 
    ExcelObject\SetProperty("Cells(2, 1)\Font\Color = 255255255") 
    ExcelObject\SetProperty("Cells(2, 2)\Font\Color = 255255255") 
    
    ExcelObject\GetObjectProperty("Sheets('3')\Delete") 
    ExcelObject\GetObjectProperty("Sheets('2')\Delete") 
  
    ExcelObject\SetProperty("Cells(1, 1)\HorizontalAlignment = -4152") ;-4152 = xlRight 
    ExcelObject\SetProperty("Cells(1, 2)\HorizontalAlignment = -4152") ;-4152 = xlRight 
    ExcelObject\SetProperty("Cells(2, 1)\HorizontalAlignment = -4152") ;-4152 = xlRight 
    ExcelObject\SetProperty("Cells(2, 2)\HorizontalAlignment = -4152") ;-4152 = xlRight 
    
    
    ExcelObject\SetProperty("Cells(1, 1)\Borders(7)\LineStyle = 1") ;7 = xlEdgeLeft ; 1 = xlContinuous 
    ExcelObject\SetProperty("Cells(1, 1)\Borders(8)\LineStyle = 1") ;8 = xlEdgeTop ; 1 = xlContinuous 
    ExcelObject\SetProperty("Cells(1, 1)\Borders(9)\LineStyle = 1") ;9 = xlEdgeBottom ; 1 = xlContinuous 
    ExcelObject\SetProperty("Cells(1, 1)\Borders(10)\LineStyle = 1") ;10 = xlEdgeRight ; 1 = xlContinuous 
    
    ExcelObject\SetProperty("Cells(1, 2)\Borders(7)\LineStyle = 1") ;7 = xlEdgeLeft ; 1 = xlContinuous 
    ExcelObject\SetProperty("Cells(1, 2)\Borders(8)\LineStyle = 1") ;8 = xlEdgeTop ; 1 = xlContinuous 
    ExcelObject\SetProperty("Cells(1, 2)\Borders(9)\LineStyle = 1") ;9 = xlEdgeBottom ; 1 = xlContinuous 
    ExcelObject\SetProperty("Cells(1, 2)\Borders(10)\LineStyle = 1") ;10 = xlEdgeRight ; 1 = xlContinuous 
    
    ExcelObject\SetProperty("Cells(2, 1)\Borders(7)\LineStyle = 1") ;7 = xlEdgeLeft ; 1 = xlContinuous 
    ExcelObject\SetProperty("Cells(2, 1)\Borders(8)\LineStyle = 1") ;8 = xlEdgeTop ; 1 = xlContinuous 
    ExcelObject\SetProperty("Cells(2, 1)\Borders(9)\LineStyle = 1") ;9 = xlEdgeBottom ; 1 = xlContinuous 
    ExcelObject\SetProperty("Cells(2, 1)\Borders(10)\LineStyle = 1") ;10 = xlEdgeRight ; 1 = xlContinuous 
    
    ExcelObject\SetProperty("Cells(2, 2)\Borders(7)\LineStyle = 1") ;7 = xlEdgeLeft ; 1 = xlContinuous 
    ExcelObject\SetProperty("Cells(2, 2)\Borders(8)\LineStyle = 1") ;8 = xlEdgeTop ; 1 = xlContinuous 
    ExcelObject\SetProperty("Cells(2, 2)\Borders(9)\LineStyle = 1") ;9 = xlEdgeBottom ; 1 = xlContinuous 
    ExcelObject\SetProperty("Cells(2, 2)\Borders(10)\LineStyle = 1") ;10 = xlEdgeRight ; 1 = xlContinuous 
    
    ExcelObject\SetProperty("Cells(1, 1)\Borders(7)\Weight = 2") ;2 = xlThin 
    ExcelObject\SetProperty("Cells(1, 1)\Borders(8)\Weight = 2") ;2 = xlThin 
    ExcelObject\SetProperty("Cells(1, 1)\Borders(9)\Weight = 2") ;2 = xlThin 
    ExcelObject\SetProperty("Cells(1, 1)\Borders(10)\Weight = 2") ;2 = xlThin 
    
    ExcelObject\SetProperty("Cells(1, 2)\Borders(7)\Weight = 2") ;2 = xlThin 
    ExcelObject\SetProperty("Cells(1, 2)\Borders(8)\Weight = 2") ;2 = xlThin 
    ExcelObject\SetProperty("Cells(1, 2)\Borders(9)\Weight = 2") ;2 = xlThin 
    ExcelObject\SetProperty("Cells(1, 2)\Borders(10)\Weight = 2") ;2 = xlThin 
    
    ExcelObject\SetProperty("Cells(2, 1)\Borders(7)\Weight = 2") ;2 = xlThin 
    ExcelObject\SetProperty("Cells(2, 1)\Borders(8)\Weight = 2") ;2 = xlThin 
    ExcelObject\SetProperty("Cells(2, 1)\Borders(9)\Weight = 2") ;2 = xlThin 
    ExcelObject\SetProperty("Cells(2, 1)\Borders(10)\Weight = 2") ;2 = xlThin 
    
    ExcelObject\SetProperty("Cells(2, 2)\Borders(7)\Weight = 2") ;2 = xlThin 
    ExcelObject\SetProperty("Cells(2, 2)\Borders(8)\Weight = 2") ;2 = xlThin 
    ExcelObject\SetProperty("Cells(2, 2)\Borders(9)\Weight = 2") ;2 = xlThin 
    ExcelObject\SetProperty("Cells(2, 2)\Borders(10)\Weight = 2") ;2 = xlThin 
    
    ExcelObject\SetProperty("DisplayToolbar = #False") 
    ExcelObject\SetProperty("ScreenUpdating = #True") 
    ExcelObject\SetProperty("ViewOnlyMode = #True") ;Schreibschutz 
    ExcelObject\SetProperty("DisplayOfficeLogo = #False") 
    ExcelObject\SetProperty("DisplayTitleBar = #False") 
    ExcelObject\SetProperty("ActiveWindow\ViewableRange = 'A1:B2'") 
    ExcelObject\SetProperty("ActiveWindow\DisplayWorkbookTabs = #False") 
  Else 
    
    Debug "!mySpreadsheet" 
      
  EndIf 
  
  ;############################################################## 
  
  Define myChart.COMateObject 
  Define ChartSpace.COMateObject 
  Define mySeriesCollection.COMateObject 
  
  ChartSpace=COMate_CreateActiveXControl(0,400,800,400,"OWC11.ChartSpace") 
  
  If ChartSpace 
    
    ChartSpace\SetProperty("DisplayOfficeLogo = #False") 
    ChartSpace\SetProperty("DisplayToolbar = #False") 
    ChartSpace\SetProperty("AllowPropertyToolbox = #False") 
    ChartSpace\SetProperty("ScreenUpdating = #True") 
    
    ChartSpace\SetProperty("HasChartSpaceTitle = #True") 
    ChartSpace\SetProperty("ChartSpaceTitle\Caption = 'Overview'") 
    ChartSpace\SetProperty("ChartSpaceTitle\Font\Bold = #True") 
    ChartSpace\SetProperty("ChartSpaceTitle\Font\Underline = #True") 
    
    ChartSpace\SetProperty("SeriesCollection\Type = 6") ;6=chChartTypeLine 
    ChartSpace\SetProperty("DataSource = " + Str(ExcelObject) + " As COMateObject") 
    
    myChart = ChartSpace\GetObjectProperty("Charts\Add") 
    
    If myChart 
      
      myChart\SetProperty("Type = 6") ; 6 = chChartTypeLine 
      
      mySeriesCollection = myChart\GetObjectProperty("SeriesCollection\Add") 
      
      If mySeriesCollection 
        
        mySeriesCollection\Invoke("SetData( 0, 0, 'B1')")  ;0 = chDimSeriesNames 
        mySeriesCollection\Invoke("SetData( 1, 0, 'A1:B1')") ;1 = chDimCategories 
        mySeriesCollection\Invoke("SetData( 2, 0, 'A2:B2')") ;2=chDimValues 
      
        mySeriesCollection\Release() 
        
      Else 
        
        Debug "!mySeriesCollection" 
        
      EndIf 
      
      myChart\Release() 
      
    Else 
      
      Debug "!myChart" 
      
    EndIf 
    
  EndIf 

  HideWindow(0,0) 
  
  If ExcelObject 
    Repeat 
    Until WaitWindowEvent()=#PB_Event_CloseWindow 
    ExcelObject\Release() 
    ChartSpace\Release() 
  EndIf 
  CloseWindow(0) 
EndIf
The original thread in the german board: http://www.purebasic.fr/german/viewtopi ... sc&start=0
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Wow! :shock:

Yep, that one has been added (for the next update). Very nice.

Thanks.
I may look like a mule, but I'm not a complete ass.
Marco2007
Enthusiast
Enthusiast
Posts: 648
Joined: Tue Jun 12, 2007 10:30 am
Location: not there...

AutoCad and Comate

Post by Marco2007 »

Hi,

here`s just a short example with AutoCad (= has to be installed).
I don`t know, if someone could need this.
Mass-Converter from dwg/dxf to dxf/dwg. Tested with AutoCad 2008 at work.

Code: Select all

XIncludeFile "COMate.pbi"

Enumeration
  #Window
EndEnumeration

Enumeration
  #ExplorerList
  #Combo_Save
  #Button_0
  #Frame3D_0
  #Frame3D_1
EndEnumeration

Global value

Procedure.s GetFilePartWithoutExtension(File.s) ; Procedure by NictheQuick
  Protected *c.Character = @File, tmp.s = "", Result.s 
  
  While *c\c 
    If *c\c = '\' 
      tmp = "" 
      Result = "" 
    ElseIf *c\c = '.' 
      Result = tmp 
      tmp + Chr(*c\c) 
    Else 
      tmp + Chr(*c\c) 
    EndIf 
    *c + SizeOf(Character) 
  Wend 
  
  If Result 
    ProcedureReturn Result 
  Else 
    ProcedureReturn tmp 
  EndIf 
EndProcedure 

Procedure save()
Protected autocad.COMateObject
Protected document.COMateObject
Protected open.COMateObject
Protected activeDoc.COMateObject
autocad = COMate_CreateObject("autocad.application") 
If autocad 

OpenConsole()
  document = autocad\GetObjectProperty("Documents")
  ;************
      For i=0 To CountGadgetItems(#ExplorerList)-1
        If GetGadgetItemState(#ExplorerList, i)&#PB_Explorer_Selected 
          file.s=GetGadgetItemText(#ExplorerList, i)
          path.s=GetGadgetText(#ExplorerList) 
          open = document\GetObjectProperty("open('"+path+file+"', 1)") 
          savefile.s=path+"_"+GetFilePartWithoutExtension(file)
          Print(file+".....")
          If open
          activeDoc = open\GetObjectProperty("Application\ActiveDocument")
            If activeDoc
              activeDoc\Invoke("SaveAs('"+savefile+"',"+Str(value)+")")
              activeDoc\Release()
              Delay(16)
              PrintN("saved")
            Else
              MessageRequester("Sorry!", "File not saved!")
            EndIf    
          open\release()
          Else
          MessageRequester("Sorry!", "File couldn`t be openend!")
          EndIf
        EndIf
      Next
document\release()  
autocad\Invoke("Quit")    
autocad\release()
CloseConsole()
Else
MessageRequester("Fehler!", "AutoCad muss installiert sein!")
EndIf
EndProcedure

Procedure Open_Window()
  If OpenWindow(#Window, 335, 45, 400, 465, "AutoCad converter",  #PB_Window_SystemMenu|#PB_Window_TitleBar )
      ExplorerListGadget(#ExplorerList, 40, 35, 320, 300, "C:\*.dwg;*.dxf", #PB_Explorer_AlwaysShowSelection|#PB_Explorer_MultiSelect|#PB_Explorer_FullRowSelect|#PB_Explorer_AutoSort)
      RemoveGadgetColumn(#ExplorerList, 2)
      SetGadgetItemAttribute(#ExplorerList, 0, #PB_Explorer_ColumnWidth, 190, 0)
      SetGadgetItemAttribute(#ExplorerList, 0, #PB_Explorer_ColumnWidth, 60, 1)
      SetGadgetItemAttribute(#ExplorerList, 0, #PB_Explorer_ColumnWidth, 99, 2)
      ComboBoxGadget(#Combo_Save, 40, 390, 225, 20)
      AddGadgetItem(#Combo_Save, -1 , "AutoCAD Release12/LT2 DXF (*.dxf)")
      AddGadgetItem(#Combo_Save, -1 , "AutoCAD Release13/LT95 DWG (*.dwg)")
      AddGadgetItem(#Combo_Save, -1 , "AutoCAD Release13/LT95 DXF (*.dxf)")
      AddGadgetItem(#Combo_Save, -1 , "AutoCAD Release14/LT97 DWG (*.dwg)")
      AddGadgetItem(#Combo_Save, -1 , "AutoCAD Release14/LT97 DXF (*.dxf)")
      AddGadgetItem(#Combo_Save, -1 , "AutoCAD 2000 DWG (*.dwg)")
      AddGadgetItem(#Combo_Save, -1 , "AutoCAD 2000 DXF (*.dxf)")
      AddGadgetItem(#Combo_Save, -1 , "AutoCAD 2000 DWT (*.dwt)")
      AddGadgetItem(#Combo_Save, -1 , "AutoCAD 2004 DXF (*.dxf)")
      AddGadgetItem(#Combo_Save, -1 , "AutoCAD 2004 DWG (*.dwg)")
      AddGadgetItem(#Combo_Save, -1 , "AutoCAD 2004 DWT (*.dwt)")
      SetGadgetState(#Combo_Save, 6)
      Frame3DGadget(#Frame3D_0, 20, 365, 360, 65, "Save as version")
      ButtonGadget(#Button_0, 285, 390, 75, 25, "save")
      Frame3DGadget(#Frame3D_1, 20, 15, 360, 340, "")
  EndIf
EndProcedure

Open_Window() 

Repeat
event=WaitWindowEvent()
  Select event 
    Case #PB_Event_Gadget
      Select EventGadget()
        Case #Button_0
          Select GetGadgetState(#Combo_Save)
            Case 0: value=1
            Case 1: value=4
            Case 2: value=5
            Case 3: value=8    
            Case 4: value=9  
            Case 5: value=12
            Case 6: value=13
            Case 7: value=14
            Case 8: value=24    
            Case 9: value=25
            Case 10: value=26
          EndSelect
          save()
      EndSelect
  EndSelect          
Until event=#PB_Event_CloseWindow


I also made a little mass-printer, but now I´m at home...if someone needs it, just tell me.
PureBasic for Windows
SFSxOI
Addict
Addict
Posts: 2970
Joined: Sat Dec 31, 2005 5:24 pm
Location: Where ya would never look.....

Post by SFSxOI »

seems COMate is getting spread around a little:

http://translate.google.com/translate?h ... 3DCOMate_C
CNESM
User
User
Posts: 54
Joined: Sat Jun 21, 2003 11:15 pm
Contact:

Post by CNESM »

COMate is create!!! Go on with the development! :D
User avatar
dobro
Enthusiast
Enthusiast
Posts: 766
Joined: Sun Oct 31, 2004 10:54 am
Location: France
Contact:

Post by dobro »

little complétion of the "Demo Agent.pb"

possibilité de changer de voix
d'agents

et passe en revu la majeur partie des animations !
:) thanks for Comate ! :D

Code: Select all

;EnableExplicit

; recuperer les agents et la reconaissance vocale ici
;http://www.microsoft.com/MSAgent/

IncludePath "..\"
XIncludeFile "COMate.pbi"

Define.l cHeight, cWidth


If ExamineDesktops()
    cWidth  = DesktopWidth(0)   / 2 - 50
    cHeight = DesktopHeight(0)  / 4
EndIf 

Define.COMateObject oAgent, oGenie

oAgent = COMate_CreateObject("Agent.Control.1")

If oAgent
    oAgent\SetProperty("Connected = #True") 
  ; **************************** le peroquet ***********************
    ;oAgent\Invoke("Characters\Load('peedy','Peedy.acs')") ; 
    ;oGenie = oAgent\GetObjectProperty("Characters('peedy')")
    ; *************************************************************
    ; **************************** le Genie  ***********************
   ; oAgent\Invoke("Characters\Load('Genie','Genie.acs')") 
    ; oGenie = oAgent\GetObjectProperty("Characters('Genie')")
    ; *************************************************************
    
    ; **************************** le Robot  ***********************
    ;oAgent\Invoke("Characters\Load('Robby','Robby.acs')") 
    ;oGenie = oAgent\GetObjectProperty("Characters('Robby')")
    ; *************************************************************
    
    ; **************************** Merlin  ***********************
    oAgent\Invoke("Characters\Load('Merlin','Merlin.acs')") ;
    oGenie = oAgent\GetObjectProperty("Characters('Merlin')")
    ; *************************************************************
    
    If oGenie
      oGenie\Invoke("show")
        Delay(3000)
      oGenie\Invoke("MoveTo("+StrU(cWidth)+", "+StrU(cHeight)+", 3000)") ; x,y,vitesse de deplacement
        ; les animations :
       ; oGenie\Invoke("listen(1)")
        ; 
        oGenie\Invoke("LanguageID=$40C") ; force a parler français
      ;************** comment changer la voix !! *****************************
        ; aller dans la base de registre cherchez la chaine qui caracterise la voix !!
        ;hklm\Software\Microsoft\
        ;  Debug  oGenie\GetStringProperty("TTSModeID")
        veronique.s="{0879A4E0-A92C-11d1-B17B-0020AFED142E}" ;voix française
        pierre.s="{0879A4E1-A92C-11d1-B17B-0020AFED142E}" ;voix fançaise
        carmen.s="{2CE326E0-A935-11d1-B17B-0020AFED142E}" ; voix espagnole a telecharger
        julio.s="{2CE326E1-A935-11d1-B17B-0020AFED142E}" ; voix espagnole a telecharger
        ;;;virginie.s="{CAC6785B-655E-4ae1-A656-BDEFD18DC46C}" ; Sapi 5 ne marche pas avec les agents
        ;;;Sam.s="{65DBDDEF-0725-11D3-B50C-00C04F797396}";Sapi 5 ne marche pas avec les agents
        oGenie\SetProperty("TTSModeID='"+pierre.s+"'") ; choisi pierre si présent
        
        ch$="'\Chr='Whisper'\'"  ;Monotone;Whisper,Normal
         ch$="'bonjour, je vais vous parler de Purebasic'"
        oGenie\Invoke("Speak("+ch$+")")
        
        ch$="'tiens a quoi je pense la ?'"
        oGenie\Invoke("Think("+ch$+")") ; fait penser l'agent !!
         
        oGenie\Invoke("play('Greet')") 
        Delay(1000)
        oGenie\Invoke("play('confused')") 
        Delay(1000)
        
        oGenie\Invoke("play('alert')")
        Delay(1000)
        
        oGenie\Invoke("play('Announce')")
        Delay(1000)
        
        oGenie\Invoke("play('Congratulate')")
        Delay(1000)
        
        oGenie\Invoke("play('DoMagic2')")
        Delay(1000)
        
        oGenie\Invoke("play('Decline')")
        Delay(1000)
        
        oGenie\Invoke("play('DontRecognize')")
        Delay(1000)
        
        oGenie\Invoke("play('Explain')")
        Delay(1000)
        
        oGenie\Invoke("play('GestureDown')")
        Delay(1000)
        
        oGenie\Invoke("play('GestureLeft')")
        Delay(1000)
        
        oGenie\Invoke("play('GestureRight')")
        Delay(1000)
        
        oGenie\Invoke("play('GestureUp')")
        Delay(1000)
        
        oGenie\Invoke("play('GetAttention')") 
        Delay(1000)
        
        oGenie\Invoke("play('GetAttentionContinued')")
        Delay(1000)
        
        oGenie\Invoke("play('GetAttentionReturn')")
        Delay(1000)
        
        oGenie\Invoke("play('LookDown')")
        Delay(1000)
        
        oGenie\Invoke("play('LookDownreturn')")
        Delay(1000)
        
        oGenie\Invoke("play('LookDownBlink')")
        Delay(1000)
        
        oGenie\Invoke("play('LookDownreturn')")
        Delay(1000)
        
        oGenie\Invoke("play('LookLeft')")
        Delay(1000)
        
        oGenie\Invoke("play('LookLeftreturn')")
        Delay(1000)
        
        oGenie\Invoke("play('LookLeftBlink')")
        Delay(1000)
        
        oGenie\Invoke("play('LookLeftreturn')")
        Delay(1000)
        
        oGenie\Invoke("play('LookRight')")
        Delay(1000)
        
        oGenie\Invoke("play('LookRightreturn')")
        Delay(1000)
        
        oGenie\Invoke("play('LookRightBlink')")
        Delay(1000)
        
        oGenie\Invoke("play('LookRightreturn')")
        Delay(1000)
        
        oGenie\Invoke("play('LookUp')")
        Delay(1000)
        
        oGenie\Invoke("play('LookUpReturn')")
        Delay(1000)
        
        oGenie\Invoke("play('LookUpBlink')")
        Delay(1000)
        
        oGenie\Invoke("play('LookUpReturn')")
        Delay(1000)
        
        oGenie\Invoke("play('LookUpReturn')")
        Delay(1000)
        
        oGenie\Invoke("play('MoveDown')")
        Delay(1000)
        
        oGenie\Invoke("play('MoveLeft')")
        Delay(1000)
        
        oGenie\Invoke("play('MoveRight')")
        Delay(1000)
        
        oGenie\Invoke("play('MoveUp')")
        Delay(1000)
        
        oGenie\Invoke("play('Pleased')")
        Delay(1000)
        
        oGenie\Invoke("play('Processing')") ; bloc
        Delay(5000)
        oGenie\Invoke("StopAll") ; obligé apres les animations qui boucles
        
        Delay(2000)
        ;oGenie\Invoke("play('Stop')")
        
        oGenie\Invoke("play('Read')")
        Delay(1000)
        
        oGenie\Invoke("play('ReadContinued')")
        Delay(1000) 
        
        oGenie\Invoke("play('Reading')"); bloc
        Delay(5000)
        oGenie\Invoke("StopAll") ; obligé apres les animations qui boucles
        Delay(1000) 
        
        oGenie\Invoke("play('Sad')")
        Delay(1000) 
        
        oGenie\Invoke("play('Searching')") ; bloc 
        Delay(5000)
        oGenie\Invoke("StopAll") ; obligé apres les animations qui boucles
        Delay(1000) 
        
        oGenie\Invoke("play('StartListening')")
        Delay(1000) 
        
        oGenie\Invoke("play('StopListening')")
        Delay(1000) 
        
        oGenie\Invoke("play('Suggest')") ; bloc
        Delay(5000)
        oGenie\Invoke("StopAll") ; obligé apres les animations qui boucles
        Delay(1000) 
        ;
        oGenie\Invoke("play('Surprised')")
        Delay(1000) 
        ;  
        oGenie\Invoke("play('Think')")
        Delay(1000) 
        
        oGenie\Invoke("play('Uncertain')")
        Delay(1000) 
        
        oGenie\Invoke("play('Wave')")
        Delay(1000)  
        ;
        oGenie\Invoke("play('Write')")
        Delay(1000) 
        
        oGenie\Invoke("play('WriteContinued')") ;bloc
        Delay(5000)
        oGenie\Invoke("StopAll") ; obligé apres les animations qui boucles
        
        Delay(1000) 
        
        oGenie\Invoke("play('Writing')") ; bloc
        Delay(5000)
        oGenie\Invoke("StopAll") ; obligé apres les animations qui boucles
        Delay(1000) 
        
        oGenie\Invoke("play('Writereturn')")
        
        
        oGenie\Invoke("play('StopAll')")
        
        
        ch$="'bonjour, je vais vous parler de Purebasic'"
        oGenie\Invoke("Speak("+ch$+")")
        
        oGenie\Invoke("play('Reading')") ; bloc 
        Delay(5000)
        oGenie\Invoke("StopAll") ; obligé apres les animations qui boucles
        Delay(2000)
        
        
        ch$="'\Pit=144 \ PureBasic est vraiment un super langage'" ; en principe le pitch en hertz
        
        oGenie\Invoke("Speak("+ch$+")")
        Delay(5000)
        ch$=" '\Spd=200\ je sais parler plus vite aussi'" ; en mot par minutes
        
        oGenie\Invoke("Speak("+ch$+")")
        Delay(6000)
        ch$=" '\Spd=80\ je sais parler plus lentement aussi'" ; en mot par minutes
        
        oGenie\Invoke("Speak("+ch$+")")
        Delay(6000)
        ch$="'\Vol=100\ et moins fort '" ;de 0 a 65535 ; le volume en principe
        
        oGenie\Invoke("Speak("+ch$+")")
        
        ch$="'\Vol=65535\ et beaucoup plus fort !! '" ;de 0 a 65535 ; le volume en principe
        
        oGenie\Invoke("Speak("+ch$+")")
        
        ch$="'\Rst\'" ; reset les tag
        oGenie\Invoke("Speak("+ch$+")")
        Delay(6000) 
        oGenie\Invoke("Speak('Au revoir ! .')") 
        
        oGenie\Invoke("play('Hide')")
        Delay(3000) 
        oGenie\Release()
    EndIf
    oAgent\Release()
EndIf
Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/
SFSxOI
Addict
Addict
Posts: 2970
Joined: Sat Dec 31, 2005 5:24 pm
Location: Where ya would never look.....

Post by SFSxOI »

I'm trying to implement the SWbemDateTime methods outlined at http://msdn.microsoft.com/en-us/library ... S.85).aspx

but when I create the object and do this:

Code: Select all

Define dateTime.COMateObject 
dateTime = COMate_CreateObject("SWbemScripting.SWbemDateTime")

dateTime\Value ; <<<<<< this produces a syntax error

QFE_InstalledOn$ = "00000101000000.000000+000"

dateTime\SetProperty("Value = QFE_InstalledOn$") <<<< this doesn't give any error or return sucess or failure, in fact it doesn't give any indication its alive at all.
Does COMate not work for creating this object? It seems to create the object but none of the objects properties or methods work in COMate, or i'm simply not doing something correctly here. How do you use the SWbemDateTime object in COMate ?
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Well of course you get a syntax error!

dateTime, as defined in your code above, is a COMate object. Now, COMate objects do not expose a \Value() method!!!

Presumably you want something like :

Code: Select all

Value = dateTime\GetIntegerProperty("Value")
or GetRealProperty() etc.

**EDIT : or GetStringProperty() :wink:
Last edited by srod on Fri Feb 27, 2009 11:45 am, edited 1 time in total.
I may look like a mule, but I'm not a complete ass.
User avatar
Kiffi
Addict
Addict
Posts: 1485
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Post by Kiffi »

Code: Select all

Define dateTime.COMateObject

dateTime = COMate_CreateObject("WbemScripting.SWbemDateTime")

If dateTime
  
  dateTimeValue$ = dateTime\GetStringProperty("Value")
  
  Debug dateTimeValue$
  
  QFE_InstalledOn$ = "00000101000000.000000+000"
  
  dateTime\SetProperty("Value = '" + QFE_InstalledOn$ + "'")
  
  dateTime\Release()
  
Else
  
  Debug COMate_GetLastErrorDescription()
  
EndIf
Greetings ... Kiffi
Hygge
SFSxOI
Addict
Addict
Posts: 2970
Joined: Sat Dec 31, 2005 5:24 pm
Location: Where ya would never look.....

Post by SFSxOI »

DoH!

I just get lost sometimes, but I always know exactly where I am...i'm in a state of confusion. Gheesh! I'm stupid stupid stupid....

I should have seen all that.

Thanks folks. :)
SFSxOI
Addict
Addict
Posts: 2970
Joined: Sat Dec 31, 2005 5:24 pm
Location: Where ya would never look.....

Post by SFSxOI »

OK, a couple of little things, an example for using the SWbemDateTime with COMate:

Code: Select all

Procedure.s CIM_UTCtoDate(CIM_UTC_Date.s, UTC_True_False.i) ; converts a DateTime formatted CIM string to human readable local date time with/without UTC offset
Define.COMateObject dateTime
dateTime = COMate_CreateObject("WbemScripting.SWbemDateTime")
  
  If dateTime
    
    dateTime\SetProperty("Value = '" + CIM_UTC_Date + "'") ; we put the date which is in CIM format into the datetime Value property, i.e...20071121060857.000000-360
    
    If UTC_True_False = 0
    date_time$ = dateTime\GetStringProperty("GetVarDate('FALSE')") ; we get the local time in the Value property in a human readable format i.e... 11/21/2007 12:08:57 PM without UTC offset
    EndIf
    
    If UTC_True_False = 1
    date_time$ = dateTime\GetStringProperty("GetVarDate('TRUE')") ; we get the local time in the Value property in a human readable format i.e... 11/21/2007 6:08:57 AM with UTC offset
    EndIf
    
        
  EndIf
  
  dateTime\Release()

ProcedureReturn date_time$

EndProcedure

; example use - get the operating system install date
Procedure.s OS_InstallDate()

Define.COMateObject objWMIService, Version, dateTime
colOS.COMateEnumObject
dateTime.COMateObject
dateTime = COMate_CreateObject("WbemScripting.SWbemDateTime")
strComputer.s = "." 

objWMIService = COMate_GetObject("winmgmts:\\" + strComputer + "\root\cimv2", "") 
If objWMIService 
  colOS = objWMIService\CreateEnumeration("ExecQuery('Select InstallDate from Win32_OperatingSystem')")
  If colOS 
    Version = colOS\GetNextObject() 
    While Version
      
      OS_InstallDate$ = Version\GetStringProperty("InstallDate")
      Debug CIM_UTCtoDate(OS_InstallDate$, 1)
      
      Version\Release() 
      Version = colOS\GetNextObject()
    Wend
    colOS\Release() 
  EndIf
  objWMIService\Release()
  Else
      MessageRequester("Error", "OSInfo")  
EndIf

EndProcedure

I've not been able to get the SetFileTime or SetVarDate in SWbemDateTime to work in COMate. Not sure why not yet. I'm beginning to think for some reason they will not work with COMate. I can get the rest of the SWbemDateTime properties and methods to work, just not the SetFileTime or SetVarDate.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Doesn't work with COMate!!!

Tish and piffle my dippy friend! :wink:

Code: Select all

;Set a variant date to match this moment in time.
  variantDate.d = Date()/86400 + 25569

dateTime.COMateObject  = COMate_CreateObject("WbemScripting.SWbemDateTime") 
  
If dateTime 
    dateTime\Invoke("SetVarDate(" + StrD(variantDate) + " as date, #FALSE)")
    Debug dateTime\GetStringProperty("GetVarDate(#False)") ; we get the local time in the Value property in a human readable format i.e... 11/21/2007 12:08:57 PM without UTC offset 
    dateTime\Release()
EndIf
Or, using variants :

Code: Select all

;Set a variant date to match this moment in time.
  var.VARIANT
    var\vt = #VT_DATE
    var\date = Date()/86400 + 25569

dateTime.COMateObject  = COMate_CreateObject("WbemScripting.SWbemDateTime") 
  
If dateTime 
    dateTime\Invoke("SetVarDate(" + Str(var) + " as variant, #FALSE)")
    Debug dateTime\GetStringProperty("GetVarDate(#False)") ; we get the local time in the Value property in a human readable format i.e... 11/21/2007 12:08:57 PM without UTC offset 
    dateTime\Release()
EndIf
I'll leave you to sort out SetFileTime().
I may look like a mule, but I'm not a complete ass.
SFSxOI
Addict
Addict
Posts: 2970
Joined: Sat Dec 31, 2005 5:24 pm
Location: Where ya would never look.....

Post by SFSxOI »

OK I just figured out something for the SetFileTime method in the SWbemDateTime, i've been using strings (because they worked for everything else) and it was driving me nuts trying to figure out why it wasn't working. Using this as a test:

Code: Select all

Procedure.s DateTimeTest()
Define.COMateObject dateTime
dateTime = COMate_CreateObject("WbemScripting.SWbemDateTime")

file_x$ = "126036951652030000"
;should Return 5/25/2000 2:26:05 AM
  
  If dateTime
    
    
      
      datetime\Invoke("SetFileTime('file_x$')")
      Debug dateTime\GetStringProperty("GetVarDate()")
            
  EndIf
  
  dateTime\Release()

EndProcedure
If I do - datetime\Invoke("SetFileTime('file_x$')") (as shown above) - then it doesn't work. But if I do this: datetime\Invoke("SetFileTime('126036951652030000')") - it works fine then.

The MSDN says this for SetFileTime:

"The SetFileTime method of the SWbemDateTime object converts a date in the string FILETIME format to the CIM datetime format.
The FILETIME format is a 64-bit datetime structure that represents the number of 100-nanosecond units since the beginning of January 1, 1601. Windows Management Instrumentation (WMI) treats FILETIME values as string representations of unsigned 64-bit numbers."

So the test value above of 126036951652030000 - can't be a long, and a quad itsn't working either (although it doesn't complain if its a quad - but doesn't work either). But it also can't be a string for the SetFileTime method. So how do you pass it then?

This is not a filetime for a physical file, its filetime representation for times used in WMI, (did I say this correctly?)

If I assign the test value as a quad like this: filetime.q = 126036951652030000 and then do this : datetime\Invoke("SetFileTime('file_x')") - it doesn't crash but doesn't work. It only works if its like this:

Code: Select all

datetime\Invoke("SetFileTime('126036951652030000')")
If I set it as an integer it crashes with this:

[img]
http://i268.photobucket.com/albums/jj24 ... erflow.png
[/img]

and of course it would crash with that. The PB help says : "Integer .i 4 bytes (32 bits) -2147483648 to +2147483647" so as an integer it is out of range just like it says.

So how do I do this?
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Code: Select all

datetime\Invoke("SetFileTime('" + file_x$ + "')")
I may look like a mule, but I'm not a complete ass.
SFSxOI
Addict
Addict
Posts: 2970
Joined: Sat Dec 31, 2005 5:24 pm
Location: Where ya would never look.....

Post by SFSxOI »

srod wrote:Doesn't work with COMate!!!

Tish and piffle my dippy friend! :wink:

Code: Select all

;Set a variant date to match this moment in time.
  variantDate.d = Date()/86400 + 25569

dateTime.COMateObject  = COMate_CreateObject("WbemScripting.SWbemDateTime") 
  
If dateTime 
    dateTime\Invoke("SetVarDate(" + StrD(variantDate) + " as date, #FALSE)")
    Debug dateTime\GetStringProperty("GetVarDate(#False)") ; we get the local time in the Value property in a human readable format i.e... 11/21/2007 12:08:57 PM without UTC offset 
    dateTime\Release()
EndIf
Or, using variants :

Code: Select all

;Set a variant date to match this moment in time.
  var.VARIANT
    var\vt = #VT_DATE
    var\date = Date()/86400 + 25569

dateTime.COMateObject  = COMate_CreateObject("WbemScripting.SWbemDateTime") 
  
If dateTime 
    dateTime\Invoke("SetVarDate(" + Str(var) + " as variant, #FALSE)")
    Debug dateTime\GetStringProperty("GetVarDate(#False)") ; we get the local time in the Value property in a human readable format i.e... 11/21/2007 12:08:57 PM without UTC offset 
    dateTime\Release()
EndIf
I'll leave you to sort out SetFileTime().

worksd fine here just as I posted it. You can't do it the way you did it...you have to use actual words like dont use #False - you have to actually use the word 'FALSE'. And it only works if its like this:

Code: Select all

Procedure.s CIM_UTCtoDate(CIM_UTC_Date.s) ; converts a DateTime formatted CIM string to human readable local date time with/without UTC offset
Define.COMateObject dateTime
dateTime = COMate_CreateObject("WbemScripting.SWbemDateTime")
  
  If dateTime
    
    dateTime\SetProperty("Value = '" + CIM_UTC_Date + "'") ; we put the date which is in CIM format into the datetime Value property, i.e...20071121060857.000000-360
    date_time$ = dateTime\GetStringProperty("GetVarDate('FALSE')") ; we get the local time in the Value property in a human readable format i.e... 11/21/2007 12:08:57 PM without UTC offset
       
        
  EndIf
  
  dateTime\Release()

ProcedureReturn date_time$

EndProcedure
but your way works too but adds a little more complexity. Are you saying that the way I posted it doesn't work for you at all? Are you on XP?
Last edited by SFSxOI on Sat Feb 28, 2009 11:34 pm, edited 2 times in total.
Post Reply