Jump to content

Obviator

Active Members
  • Posts

    41
  • Joined

  • Last visited

Profile Information

  • Location
    Montana

Obviator's Achievements

Seeker

Seeker (1/7)

1

Reputation

  1. Thanks MrMitchell! i played with all kinds of permutations of quotation marks, except this one. Never even dawned on me. Thanks for catching the "&" also, i sometimes so wrapped up in the details i forget things. Dave
  2. i've been puzzling over this for a while now and can't seem to find a reasonable solution. i have tw functions that use WMI to get system manufacturer and battery information. As two separate functions they return what i expect. When i try to merge them into one function by increasing the passed variables i get errors that i can't really explain. i'll use the system manufacturer function as an example: $mMfg = _QueryMfg($mMfg) Func _QueryMfg($mMfg) Dim $objWMIService, $colItems, $Output $colItems = "" $objWMIService = ObjGet("winmgmts:\\" & @ComputerName & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_BIOS", "WQL") If IsObj($colItems) Then For $objItem in $colItems $Output = $Output & "Manufacturer: " & $objItem.Manufacturer & @CRLF $mMfg = $objItem.Manufacturer $Output = "" Next Else MsgBox(0, "WMI Output", "No WMI objects found for class Win32_BIOS") Endif Return($mMfg) EndFunc When i add passed variables for properties ($Properties = "Manufacturer") and path ($Path = "Win32_BIOS") i start getting "error in expression". $mMfg = _WMIQuery($Item, "Manufacturer", "Win32_BIOS") Func _WMIQuery($Item, $Properties, $Path) Dim $objWMIService, $colItems, $Output $colItems = "" $objWMIService = ObjGet("winmgmts:\\" & @ComputerName & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM " & $Path, "WQL") If IsObj($colItems) Then For $objItem in $colItems $Output = $Output & $Properties ": " & $objItem.$Properties & @CRLF ;This line gets "Error in Expression" If i remark out this line... $Item = $objItem.$Properties ;...This line gets "Error in Expression" $Output = "" Next Else MsgBox(0, "WMI Output", "No WMI objects found for class " & $Path) Endif Return($Item) EndFunc i can't seem to wrap my head around what i may be doing wrong. Anyone have any ideas? Thanks, Dave
  3. Thanks Melba! While not a beginner, up 'til now i haven't had to deal with them. i'm not really a programmer, i'm just someone trying to make my job easier and quicker, if that means quickly throwing something together that works, i'll give it a try. Elegance in programming constructs is not in me, brute force on the other hand... i'll read through that tutorial too. Thanks! Dave
  4. i'm creating an automated install routine for about 20 different programs. The first 7 or so are "requireds", if not already installed. i can check that and advise the user they're not available for install. So far, so good. My problem is that i end up typing the same thing for each of those first 7 buttons. i've tried to have the system create the buttons, limiting my retyping many lines of code. However, when i do this i do not get to the function i'm trying to direct the click to execute. Here's one of the buttons i have to type: Func _btnName($x1) If _Convert2Number($mNameREG) < _Convert2Number($mNameINI) Then $mbtnName = GUICtrlCreateButton(_CheckInstall($mNameINI), $mCol05, ($mXpos + ($mMultiplier * $x1)) - 4, $mWidth, $mHeight, 1) GUICtrlSetOnEvent(-1, "_NameClick") _SetFont() Else _LabelCreate(_CheckInstall($mNameREG), $mCol05, $mXpos + ($mMultiplier * $x1), $mWidth, $mHeight, 1) EndIf EndFuncThe only variable i have feeding into this function is an offset number and NAME could be anything You want. i further have an .INI file that contains the current available version that i check against the system registry then convert both inputs to numbers (to see which one is greater), finally display the button if necessary. i've tried creating a function that encapsulates this into one function, but on clicking it doesn't go where i point it to. Is it possible to get a $btnName as i intend or do i have to do this long-hand? Thanks, Dave Func _CreateButton($x1, $x2, $x3, $x4, $x5) ;$x1 = Registry variable ;$x2 = INI variable ;$x3 = Button Name ;$x4 = OnClick Event ;$x5 = Offset Number If _Convert2Number($x1) < _Convert2Number($x2) Then $x3 = GUICtrlCreateButton(_CheckInstall($x2), $mCol05, ($mXpos + ($mMultiplier * $x5)) - 4, $mWidth, $mHeight, 1) GUICtrlSetOnEvent(-1, $x4) _SetFont() Else _labelCreate(_CheckInstall($mX1), $mCol05, $mXpos + ($mMultiplier * $x5), $mWidth, $mHeight, 1) EndIf MsgBox(0, "Vars", "$x1 = " & $x1 & @CRLF & _ "$x2 = " & $x2 & @CRLF & _ "$x3 = " & $x3 & @CRLF & _ "$x4 = " & $x4 & @CRLF & _ "$x5 = " & $x5) EndFuncThe MsgBox shows the variables i send and what i intend is that $x3 should be a $btnNAME. Instead i get a number that bears no relation to anything i'm aware of. (on the first button in my form i get a "7".)
  5. i have an older application that creates a splash screen over the whole desktop then puts the install screens on the "splash." Once i activate the real install screen by mousing over and clicking the "Next" button everything operates well, but i cannot seem to WinActivate() the initial install screen. Window title is "Welcome", some text, and 2 buttons, "Next" and "Cancel." i've tried everything i can think of and need a clue. Partial code: WinActivate("Welcome") ControlSend("Welcome", "", "[ID:1; Text: Next]") After i click the "Next" button, everything operates normally; i just can't seem to get over this hurdle. Thanks, Dave
  6. Ok. This is different than most other languages i'm familiar with. Mostly You can just skip by leaving a comma there. The more i learn the more i don't know! Thanks guiness!
  7. Ok, how do you "skip" optional variables? ************************* Function to Create Labels ************************* Func _LabelCreate($mName, $x1, $x2,$x3 = $mWidth, $x4 = $mHeight, $x5 = 0) GUICtrlCreateLabel($mName, $x1, $x2, $x3, $x4, 1) _SetFont() EndFunc Let's say, since $x2 and $x3 are already set and i want something other than the default at $x5. i know that "Center" = 1. i've tried putting blank commas in as placeholders and it doesn't appear to work as i get an "Error in Expresssion" error at the position of the first blank comma. How would i go about skipping defaults and changing the things i want to change?
  8. Damn; is it really THAT easy?? Thanks guinness!!
  9. i have a home-grown function that works great with 3 parameters, when i try to add 2 optional parameters i get 'Badly formatted "Func" statement.' when trying it out in SciTE. Function just creates labels on my main form and is called by passing name to show, x-position, and y-position. When i try to add width and height options it fails ************************* Function to Create Labels ************************* Func _LabelCreate($mName, $x1, $x2 [,$x3 = $mWidth [, $x4 = $mHeight]]) GUICtrlCreateLabel($mName, $x1, $x2, $x3, $x4) _SetFont() EndFunc $mWidth and $mHeight are a standard width and height i set in my variables fuction further up. My real issue is HOW to specify optional parameters and how to set defaults for them. Thanks, Dave
  10. Thanks BrewManNH! Another case of "do what i mean, not what i say" programming! Dave
  11. Here's a quick thing that i just can't make work correctly. Put a screen up to capture a user's input. Force that input to lowercase and put it in a variable to replace at a certain place in a third file. My problem is that i cannot get the user's input to tell me anything other than "3." i HAVE to be doing something wrong but darned if i can spot it. #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) #Region ### START Koda GUI section ### Form=f:\vuwin60\form1.kxf Local $Form1, $txtInput, $btnOK, $btnCancel, $Label1 $Form1 = GUICreate("Enter User ID", 335, 90, -1, -1) ;343, 140);, $WS_SYSMENU) GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close") $txtInput = GUICtrlCreateInput("", 256, 16, 65, 21) ;GUICtrlSetOnEvent(-1, "txtInputChange") $Label1 = GUICtrlCreateLabel("Please input your IWIMS User ID:", 8, 16, 232, 20) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") ;GUICtrlSetOnEvent(-1, "Label1Click") $btnOK = GUICtrlCreateButton("&Ok", 32, 48, 100, 30, $BS_NOTIFY) ;GUICtrlSetResizing(-1, $GUI_DOCKHCENTER+$GUI_DOCKVCENTER+$GUI_DOCKWIDTH+$GUI_DOCKHEIGHT) GUICtrlSetOnEvent(-1, "btnOKClick") $btnCancel = GUICtrlCreateButton("&Cancel", 200, 48, 100, 30, $BS_NOTIFY) ;GUICtrlSetResizing(-1, $GUI_DOCKHCENTER+$GUI_DOCKVCENTER+$GUI_DOCKWIDTH+$GUI_DOCKHEIGHT) GUICtrlSetOnEvent(-1, "btnCancelClick") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 Sleep(100) WEnd Func btnCancelClick() Exit EndFunc Func btnOKClick() GUICtrlRead($txtInput) ConsoleWrite($txtInput & @crlf & StringLen($txtInput) & @CRLF) Exit EndFunc Func Form1Close() Exit EndFunc Can someone please straighten me out here? i expect the lowercase of whatever the user types in, not just "3." Thanks, Dave
  12. Well, here i go exposing myself to ridicule... i've been working in and around computers since the mid-80s; i can't tell You how many different OSs, programs, and languages i've worked with in that time; i couldn't tell You enough about any of them to ruin my amature status . Arrays are just one of those things that i've never "grokked," no matter how much reading i do or which language i try. i think of arrays as a sort of spreadsheet with a fixed number of cells, "fixed" being determined by the programmer. i've always been more of a "brute force" type of programmer, using what knowledge i have to solve a particular problem then moving on to the next issue. i've always admired the way some folks have elegant solutions to problems, like Your solution, but i just don't have that elegant streak. Thank God there's folks who do. Thanks again! Dave
  13. Holy Cats smartee!! That worked like a champ!! Now i need to understand why. FileOpen() seems like the flags are "additive." If i open the file with "16" as a binary file then adding the "1" to make it open writable would make "17." i've never quite gotten the array thing. It looks like You're creating a two-dimensional array and storing the data from position 17 and 2247 for 3 characters in each array element. Sorry if i seem dumb, but i gotta put it in "Dave-speak" so i can assure myself it's not magic. Thanks Loads! Dave
  14. i've been playing with this for awhile and have finally gotten where i can read the file i want, but i still can't WRITE the characters i need to write. i can open file "Contoso.vuw" and process to the end of file, displaying both the character position number and associated character, IF i open the file as read only. If i open the file as FileWrite("contoso.vuw", 1) the file runs to the end, but displays nothing. If i open as FileWrite("contoso.vuw", 16) i get a binary representation of all characters. i'm stuck. i need to replace characters 17, 18 and 19 with whatever the user types in (i can do that part), a 3-character userid. If i can get these three positions done i can do the other positions further down in the file (characters 2247, 2248, and 2249, all represented as "abc"). Can someone point me in the right direction please. Thanks, Dave BinaryWrite.zip
  15. Smartee, Thanks for the link, i've been reading it and think i'm a "little" smarter than when i started. It's been a busy couple of weeks getting systems moved to Win7 but i'm no further along with my script than when i started. What i've got is this (heavily borrowed from JSThePatriot): #include "CompInfo.au3" ;If you are wanting to pull WMI data from different computers then Declare $cI_CompName as the computer name before the include. ;NOTE: Printers contains alot of information, and may require a different output format. Dim $Print Dim $aPrinter Dim $j, $k, $l $j = 0 $k = 0 $l = 0 _ComputerGetPrinters($Print) If @error Then $error = @error $extended = @extended Switch $extended Case 1 _ErrorMsg($ERR_NO_INFO) Case 2 _ErrorMsg($ERR_NOT_OBJ) EndSwitch EndIf For $i = 1 To $Print[0][0]Step 1 For $j = 1 To $aPrint[0][0][0] Step 1 $aPrint[$j][0][0] = $Print[$i][0] $aPrint[0][$k][0] = $Print[$i][28] $aPrint[0][0][$l] = $Print[$i][31] ; MsgBox(0, "Test _ComputerGetPrinters", "Name: " & $Print[$i][0] & " -- " & "DeviceID: " & $aPrint[$i][28] & " -- " & "DriverName: " & $aPrint[$i][31]) Next Next Where i "think" i'm going is getting JSThePatriot's WMI array to feed "my" array in the way i want it. So far no luck, but i'm hopeful that if i keep plugging i might get it yet. Thanks, Dave
×
×
  • Create New...