;Determining which services are currently stopped and the start mode is 'Manual'WQLQuery = SELECT DisplayName FROM Win32_Service Where State='Stopped' AND StartMode='Manual'count :=0For objService in objWMIService.ExecQuery(WQLQuery) StoppedServices .= objService.DisplayName ."`n", count++MsgBox,, Services Currently Stopped and 'Manual':%count%,%StoppedServices%

;Start the First Service in the List of the Stopped Services of the 'Manual' modeFor objService in objWMIService.ExecQuery(WQLQuery){ DemoRunService := objService.DisplayNameif errReturnCode := objService.StartService()MsgBox,48,, Error Code:%errReturnCode%`nCould Not Start the Service,%DemoRunService%else{Msgbox%DemoRunService%is Started. After OK is Pressed, It Will be Stopped.if errReturnCode := objService.StopService()MsgBox,48,, Error Code:%errReturnCode%`nCould Not Stop the Service,%DemoRunService%elseMsgbox Successfully Stopped the Service :%DemoRunService%}Break;just one service to start and stop for demo}

COM Object: WScript.ShellPurpose: Exchange variables between scriptsSystem Requirements: GeneralDocumentation Link:WshEnvironment ObjectOther Links:Environment VariablesBasic Code Example - demonstrates how to set a volatile environment variable and read it from another script:Save this code as Sender.ahk

objShell :=ComObjCreate("WScript.Shell")objEnv := objShell.Environment("Volatile")loop{random, env,0,100;Here the variable is named "Test". Change the name as you need.;But the other script to read the value needs the corresponding variable name.;This variable and its value will be lost after logout/restart/shutdown of your computer. objEnv.Item("Test"):= envsleep100}Return

; Note: when extracting the SafeArray, it will be 1-basedLoop % SafeArray.MaxIndex(1); loop through every row{ CurRowNum :=A_IndexLoop % SafeArray.MaxIndex(2); loop through every columnMsgBox,,, % SafeArray[CurRowNum,A_Index],1; get cell's value}return

F2::; get 2 dimensional object from Selection or any other range object via SafeArray, and convert it to stringoExcel :=ComObjActive("Excel.Application")MsgBox % Table2String(SafeArray(oExcel.Selection))return

COM Object: Shell.Explorer [Embedded Browser]Purpose: Embed a Trident Browser (IE) in a GuiSystem Requirements: GeneralDocumentation Link:Shell.Explorer, iWebBrowser2Basic Code Example: Embed a browser navigate to a web site and wait for it to loadEvery one asks why ctrl+key comboes and enter do not work in theier implementation of this. Please see how this is solved in this example

COM Object: Ahk.ComSurrogate.32/64Purpose: Create COM objects of a specified bitnessSystem Requirements:ComDispatch.ahk (with the included ComRemote.ahk library)Description:This is a simple COM script that proxies the creation of 32-bit only objects on 64-bit scripts and vice versa.

You need to have it running in the background using the AHK_L build of the appropriate bitness (running both AHK_L builds at the same time is supported), then you can use these functions to create objects:

;[========];[ Load ];[========];-- Note: XML data from fincs. The data has been edited to remove all formatting.xmldata=(ltrim join<compactdiscs><compactdisc><artist type="individual">Frank Sinatra</artist><title numberoftracks="4">In The Wee Small Hours</title><tracks><track>In The Wee Small Hours</track><track>Mood Indigo</track><track>Glad To Be Unhappy</track><track>I Get Along Without You Very Well</track></tracks><price>$12.99</price></compactdisc><compactdisc><artist type="band">The Offspring</artist><title numberoftracks="5">Americana</title><tracks><track>Welcome</track><track>Have You Ever</track><track>Staring At The Sun</track><track>Pretty Fly (For A White Guy)</track></tracks><price>$12.99</price></compactdisc></compactdiscs>)

;-- Set properties on the XML writer.; Note: Some of the property assignments have been commented out so that the; default values will be used. Uncomment and set to another value if desired.

xmlWriter.byteOrderMark:=True;-- Determines whether to write the Byte Order Mark (BOM). The; byteOrderMark property has no effect for BSTR or DOM output.

xmlWriter.disableOutputEscaping:=False;-- Matches the disable-output-escaping attribute of the <xsl:text> and; <xsl:value-of> elements. When set to True, special symbols such as; "&" are passed through literally.

;;;;;xmlWriter.encoding:="UTF-8";;;;; ;-- Sets and gets encoding for the output. Observation: For some;;;;; ; reason, encoding is not displayed in the processing instructions;;;;; ; node if this property is set to "UTF-8".

xmlWriter.omitXMLDeclaration:=False;-- Forces the IMXWriter to skip the XML declaration. Useful for; creating document fragments. Observation: For some reason (bug?),; this property is assumed to be TRUE if the "output" property is a; DOM object.

xmlWriter.indent:=True;-- Sets whether to indent output. There is no real need for the; xmlWriter without this feature

;;;;;xmlWriter.standAlone:=True;;;;; ;-- Sets the value of the standalone attribute in the XML declaration to;;;;; ; "yes" or "no".

;;;;;xmlWriter.version:="1.0";;;;; ;-- Specifies the version to include in XML declarations.

;;;;;xmlWriter.output:="";;;;; ;-- Sets the destination and the type of output for IMXWriter.;;;;; ; Observation: If set, this property should (must?) be set last.

;-- Set the XML writer to the SAX content handlerxmlReader.contentHandler :=xmlWriterxmlReader.dtdHandler :=xmlWriterxmlReader.errorHandler :=xmlWriterxmlReader.putProperty("http://xml.org/sax/properties/lexical-handler",xmlWriter)xmlReader.putProperty("http://xml.org/sax/properties/declaration-handler",xmlWriter)