Jump to content

SIMPLE_XP

Members
  • Posts

    16
  • Joined

  • Last visited

Everything posted by SIMPLE_XP

  1. Sorry it took so long... I have been busy at work. I created a basic wmifunctions.au3 UDF. Here is the lowdown: Create a new namespace in the rootDelete a namespace in the rootAdd a Class, set the key property and add additional propertiesIt is Beta, so please do not make fun! I will add some additional functionality in the future. Example of how to use the functions: CODE#include <wmifunctions.au3> $LOCAL_COMPUTER = "." $NAME_SPACE = "AutoIT" $CLASS = "WMIisFun" $KEYPROPERTY = "KeyProperty,False" $PROPERTYLIST = "FirstProperty,False|SecondProperty,False|ThirdProperty,False" _ADD_ROOT_NAMESPACE($LOCAL_COMPUTER, $NAME_SPACE) _CREATE_NAMESPACE_CLASS($LOCAL_COMPUTER, $NAME_SPACE, $CLASS, $KEYPROPERTY, $PROPERTYLIST) _DELETE_NAMESPACE($LOCAL_COMPUTER, $NAME_SPACE) wmifunctions.au3
  2. Ok, I think I figured it out... (found some cool stuff in vbscript) I will post the code as soon as I have it validated. I am sure someone else will want to know how to do this in AutoIT as well. Maybe I will make WMI UDF if I have time.
  3. Thanks for replying, but I know how to read from WMI, I am trying to figure out how to write to WMI (In the namespace I created with the posted code) without an intermediary providor. Is this possible in AutoIT?
  4. Ok, so I figured out how to create a new namespace in WMI... Func ADD_ROOT_NAMESPACE($PASSED_LOCAL_COMPUTER, $PASSED_NAMESPACE) Dim $OBJ_WMI_SERVICE, $OBJ_ITEM, $OBJ_NAME_SPACE $OBJ_WMI_SERVICE = ObjGet("winmgmts:\\" & $PASSED_LOCAL_COMPUTER & "\root") $OBJ_ITEM = $OBJ_WMI_SERVICE.Get("__Namespace") $OBJ_NAME_SPACE = $OBJ_ITEM.SpawnInstance_ $OBJ_NAME_SPACE.Name = $PASSED_NAMESPACE $OBJ_NAME_SPACE.Put_ EndFunc How do I now create Classes etc... and then write to them? Thanks in advance...
  5. You need to add the following to your script... (You can comment out the Msgbox line in the function so that it is silent...) Basically you are adding a custom error function to handle the errors. I added the static Hex error in the function that will trap the specific error of the dll not being registered. Good luck! Opt("RunErrorsFatal", 0) ;SET ERRORS AS SILENT NOT FATAL $OBJECT_ERROR_HANDLER = ObjEvent("AutoIt.Error","PRINTER_ERROR_FUNC") ;CUSTOM ERROR HANDLER FUNCTION Func PRINTER_ERROR_FUNC() $HexNumber=hex($OBJECT_ERROR_HANDLER.number,8) If $HexNumber ="800401F3" Then $DO_NOT_RUN = True MsgBox(0, "Error", "Please register prnadmin.dll before using") Else Msgbox(0,"","Please let me (Jim Parsons) the Author know we intercepted a COM Error !" & @CRLF & _ "Number is: " & $HexNumber & @CRLF & _ "Windescription is: " & $OBJECT_ERROR_HANDLER.windescription ) EndIf SetError(1) Endfunc
  6. Sorry guys, I just assumed the Variable names were self explanitory. I am passing the Name of the server and Name of the printer (remotely) so the server variable would be "\\MYSERVER1" and Printer variable would be "PRINTER2". I looked at how the add method worked and figured out that the VBScript code from Microxoft was incorrect (Whitepaper from MS "prnadmin.doc" comes with Toolkit) and here is what finally worked. CODEFunc REMOVE_PRINT_QUEUE($PRINTSERVER_NAME, $PRINTER_NAME) $P_OBJ_PRINTER.ServerName = "\\" & $PRINTSERVER_NAME $P_OBJ_PRINTER.PrinterName = $PRINTER_NAME $P_OBJ_MASTER.PrinterDel($P_OBJ_PRINTER) $PRINTSERVER_NAME = "" $PRINTER_NAME = "" EndFunc
  7. Well I am having some minor trouble converting the follow VBScript code to AutoIT. No matter how I format the SERVER, PRINTER variables after "oMaster.PrinterDel" I get an error. I can get the Add printer code to work, just not the delete! VBscript CODEset oMaster = CreateObject("PrintMaster.PrintMaster.1") oMaster.PrinterDel ServerName, PrinterName AutoIT Code... so far I have tried... oMaster.PrinterDel $PRINTSERVER_NAME, $PRINTER_NAME oMaster.PrinterDel($PRINTSERVER_NAME, $PRINTER_NAME) oMaster.PrinterDel('"' & $PRINTSERVER_NAME & "," & '"' & $PRINTER_NAME & '"') oMaster.PrinterDel '"' & $PRINTSERVER_NAME & "," & '"' & $PRINTER_NAME & '"' oMaster.PrinterDel $PRINTSERVER_NAME & "," & $PRINTER_NAME CODEFunc REMOVE_PRINT_QUEUE($PRINTSERVER_NAME, $PRINTER_NAME) $P_OBJ_MASTER = ObjCreate("PrintMaster.PrintMaster.1") $P_OBJ_MASTER.PrinterDel($PRINTSERVER_NAME, $PRINTER_NAME) EndFunc Any help would be appreciated. Thanks!
  8. Came across an issue where I needed to see how many times a value appeared in a string. I could not find anything pre-written for this, so I wrote a simple function to count how many times a sub string appears in a string. Hope someone finds this useful. CODE#include <Array.au3> $STRING_TO_CHECK = "You are the sunshine of my life. Sunshine is needed for plants to grow." $STRING_TO_LOOK_FOR = "sunshine" $RETURNED_VALUE = COUNT_HOW_MANY($STRING_TO_CHECK , $STRING_TO_LOOK_FOR , False) MsgBox(0, "COUNT", $RETURNED_VALUE) Func COUNT_HOW_MANY($STR_TO_SEARCH, $STR_WANT_TO_FIND, $CASE_SENSITIVE) If $CASE_SENSITIVE Then $HOW_MANY = UBound(StringSplit($STR_TO_SEARCH, $STR_WANT_TO_FIND, 1)) Else $HOW_MANY = UBound(StringSplit(StringUpper($STR_TO_SEARCH), StringUpper($STR_WANT_TO_FIND), 1)) EndIf Return $HOW_MANY -2 EndFunc
  9. Um... sorry about that... I thought I had found that example before, but it is different. It goes in to much more detail. I will take a look and if I find an easy way to use it I will post. Thanks!
  10. Thanks, but I had already found that. I am not sure how to expose what I need. I am a little new to scripting... Hopefully somone can come up with something... I will keep looking.
  11. I am trying to get a low CPU intensive way to read the status of Network cards. I am running a delayed internal function loop to keep the CPU from pegging, but making the check using a WMI call seems to eat up about 35% of the CPU when it makes the call. I am using a DLL struct to check the AC vs. Battery, and was hoping there was a similar DLL call that could do the same thing for network cards... Here is the code I have right now... CODE$wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM BRCM_3RdPartyNetworkAdapter", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) then For $objItem In $colItems If $objItem.Name = "Intel® PRO/Wireless 2200BG Network Connection" Then $NIC_NAME = "Intel® PRO/Wireless 2200BG" $NIC_CONNECTION_ID = $objItem.NetConnectionID $NIC_TYPE = $objItem.NICType If $objItem.Status = "OK" Then $NIC_STATUS = "CONNECTED" Else $NIC_STATUS = "DISCONNECTED" EndIf ExitLoop EndIf Next EndIf
  12. Thanks! I am not sure why I did not see that when I searched... thanks again.
  13. Can anyone point me in the right direction in determining if a laptop is running on a battey or not? Thanks in advance.
  14. I am a really new AutoIT coder, and need some help! I have a problem with a game I just started working on. I would really appreciate any thoughts on fixing this! Here is my issue. The navigation works by using $KEY_MONITOR = DllOpen("user32.dll") to monitor for the Up, Down, Left and right keys being pressed. This part works great. Actually, everything works great unless I move the main gui window. If I move it, the in game window "Boundries" do not move with the window. In other words, the Character ends up being able to walk off of the display GUI on one side and does not go far enough on the other. My navigation was working great until I added a transparent layer so the on screen Player image(Sprite) does not show a white background. Here is the code that is called when an arrow key is pressed: If _IsPressed("25", $KEY_MONITOR) Then Sleep(100) GUICtrlSetImage($PLAYER_1,$PLAYER[2][1][0]); If $CURRENT_MAP_HORIZONTAL = 1 And $PLAYER_HORIZONTAL < 150 Then ControlMove("","", $TRANSPARENT_MAT, $PLAYER_HORIZONTAL,$PLAYER_VERTICLE) Else $PLAYER_HORIZONTAL = $PLAYER_HORIZONTAL-10 ControlMove("","", $TRANSPARENT_MAT, $PLAYER_HORIZONTAL,$PLAYER_VERTICLE) GUICtrlSetData($LOCATION, $CURRENT_LARGE_MAP & " " & $CURRENT_MAP_HORIZONTAL & "-" & $CURRENT_MAP_VERTICLE & " " & $PLAYER_HORIZONTAL & " - " & $PLAYER_VERTICLE) If $PLAYER_HORIZONTAL < 150 Then CHANGE_LOCAL_MAP_LEFT() EndIf Here is what I mean: This one is ok (original location of GUI window) This one is after moving the window
×
×
  • Create New...