Jump to content

triodz

Active Members
  • Posts

    34
  • Joined

  • Last visited

About triodz

  • Birthday 11/19/1977

Profile Information

  • Location
    Bendigo

triodz's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. Thanks for the help with this one, but it unfortunately it just created a blank file. This worked perfectly! Thanks so much for your help. You actually went above and beyond and got me on my way with my next challenge of having the number on the button update (well it will be on a label, but same-same!)
  2. I want the number in a file to be overwritten with the next number up each time a button is pressed. So it is pressed once, the number '1' is written to the file. It is pressed again and the number '2' overwrites the first number. At the moment I get the number 1 written, but can't get it to overwrite. What I have so far: #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> #Region ### START Koda GUI section ### Form=C:\Users\soulf\Desktop\CalcGui\RLCalc.kxf $Form1 = GUICreate("Form1", 615, 437, 426, 141) $One = GUICtrlCreateButton("1", 32, 72, 25, 25) GUICtrlSetBkColor(-1, 0xFF0000) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Func First ()     $fPath = "C:\temp\First.txt"     $fOpen = FileOpen ($fPath, 2)     $Counter = FileReadLine ($fpath)     $counter = $counter + 1     $fWrite = filewriteline ($fPath, $counter)     FileClose ($fpath) EndFunc While 1     $nMsg = GUIGetMsg()     Switch $nMsg         Case $GUI_EVENT_CLOSE             Exit         Case $One             Call ("First")     EndSwitch WEnd I tried a Do Until statement, but that just puts the numbers 1 to 5 in the file. Any help would be greatly appreciated!
  3. Sorry mate, just overwrites the file It's OK, I did a for...next loop, then used a different program to rename them in chronological order. It can start renaming from the last number too, which is handy. It's heaps easier and doesn't take long. Thanks anyways guys. Have a great night!
  4. Thanks Andreu, but I can't get it to work. I do appreciate your assistance though I might just do a for...next and use a batch file rename programs separately to name the files in an orderly way, being that the "for" statement will create the same names again,
  5. Hi Everyone! Been away from scripting for a bit and am a bit rusty. I was trying to get downloaded image filenames to increment by one. I was hoping to be able to check the last filename and continue from there if the program was closed and reopened again. #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $biolister = GUICreate("Form1", 125, 97, 192, 124) GUISetBkColor(0x99B4D1) $start = GUICtrlCreateButton("Start", 8, 40, 41, 33) GUICtrlSetBkColor(-1, 0x00FFFF) $stop = GUICtrlCreateButton("Stop", 72, 40, 41, 33) GUICtrlSetBkColor(-1, 0xFF0000) $Bio = GUICtrlCreateLabel("Bio Lister", 24, 8, 80, 28) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $filename = 0 $sImgDir = "C:\filepathname\"&$filename&".jpg" $sImgUrl = "http://lorempixel.com/400/200" $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $stop Exit case $start InetGet($sImgUrl, $simgdir, 1, 0) if fileexists( $simgdir & $filename) then $filename + 1 EndSwitch WEnd
  6. Holy crap, that's awesome! This does exactly what I want. Thank you so much! This is great!
  7. Well, I figured out a way around it... sorta. I will be using this to keep track of numbers. So the last number entered needs to be added to the new number entered. I ended up with a msgbox that pops up with the current total. I would prefer this to show in an inputbox if this possible though. For anyone interested: #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 211, 85, 192, 124) $FIRST = GUICtrlCreateLabel("First", 8, 16, 23, 17) $1ST=GUICtrlCreateInput("", 36, 12, 57, 21) $Button1 = GUICtrlCreateButton("Add", 20, 40, 75, 25) $Button2 = GUICtrlCreateButton("Clear", 104, 40, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $FIRST1=GUICtrlRead($1st) ;reads number entered $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE FileDelete("total.txt") ;deletes any created files so there is no interference next time Exit Case $Button1 $LASTTOTAL=FileReadLine("total.txt",-1) ;reads last number in tally file. If not there, it is created $NEXTTOTAL=$FIRST1+$LASTTOTAL ;adds the last number in the tally file with the number entered in inputbox $TOTALFILE=FileWriteLine("total.txt",$NEXTTOTAL) ;writes new total in tally file MsgBox(1,"",$NEXTTOTAL) ;displays the current total Case $Button2 FileDelete("total.txt") ;deletes the tally file if you want to start again EndSwitch WEnd
  8. This probably has a simple solution, but I cannot figure it out. First here is the code: #include #include #include #include #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("", 234, 58, 192, 124) $FIRST = GUICtrlCreateLabel("First", 8, 16, 23, 17) $SECOND = GUICtrlCreateLabel("Second", 104, 15, 41, 17) $1st=GUICtrlCreateInput("", 36, 12, 57, 21) $2nd=GUICtrlCreateInput("", 150, 12, 57, 21) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $FIRST1=GUICtrlRead($1st) $SECOND2=GUICtrlRead($2nd) if $FIRST1<>"" Then $SECOND2=$FIRST1+$SECOND2 EndIf While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd What I want to do is, when I put a number in the First inputbox, the Second inputbox automatically adds it to its total. Example: First: I put in the number 6 Second: It already has the number 8 in it I want the Second to automatically update to 14. Any help is greatly appreciated.
  9. First example script. Yay for me! So apologies if there is a certain way i need to do this. It is probably more accurate to state that this is code from different people put into a instantly usable script. First, credits go to: For the encrypt\decrypt code: For the Verification against AD code: I have added commentary in the scripts that will hopefully help the newbie factor out a bit. I've been there and its nice to have helpful comments. In case you need to compare your situation with mine: I work on a helpdesk. I log on with a standard signon and use a different signon for administrative tasks. I am using this to run other scripts as an administrator.In "CredCheck.au3", it will check the username and password given against Active Directory. If it fails, it will let you know. If it succeeds, it will run the given program or script as administrator. It also writes the password to an ini file and encrypts it, and also writes the username - unencrypted. In "Unencrypt Test.au3" it will unencrypt the password which will allow it to be injected into password fields of remote pc's if needed. In my case, I did need this. CredCheck.au3 unencrypt test.au3 Good luck and any criticism welcome!
  10. I FIGURED IT OUT!! OMG I THOUGHT MY HEAD WOULD ASPLODE AND EVERYONE AROUND ME WOULD BE COVERED IN CONFUSED BRAIN GOO! Right, now that excitement is out of the way: BrewManNH, you are very right, but not in the way I (or perhaps you) are thinking. I was wondering if the files were getting the same rights as the initial script calling on them. Our standard logon and our Admin logon (the reason I am creating this) are different - "username" for standard and "username_a" for admin. So if the script is being opened with the "username_a", then calling on files that have not inherited the same rights, it will fail. Because these files are a part of the array, said annoying-as-hell error appears. So what to do? Look at the Logon script (CredCheckPrint) that calls the script I want to run! In this script, I had this: case $ok If _ValidUserPass($usera, $computer, $passa) = True Then Ini_Write("Password","c:cred3.ini","Section","Key",$passa) ; RunAs($usera, $computer, $passa,0,@ScriptDir&"test3.exe") ExitLoop Else for when the OK button was pressed. I changed the RunAs line to this: RunAs($usera, $computer, $passa,0,@ScriptDir&"test3.exe",@ScriptDir,"",0x1) Help file states: 0x1 ($STDIN_CHILD) = Provide a handle to the child's STDIN stream My interpretation of this is that the credentials used will also also be used for any files the script calls on. Which is what i need. Works beautifully! When I have this completed and working, I am going to post for use by others as it really is going to be a useful script in an environment that only uses admin logons when troubleshooting users PC's. It will allow automation of any script yiou create that needs to be run as admin. And the printing script may come in handy too! Thanks SO MUCH for the help you have both provided! Once again this community shows its awesomeness.
  11. Hi BrewManNH, I added what you suggested, as such: $print = IniReadSection(".printerlist.ini","PRINTERS") _ArrayDisplay ($print) and: $PrintCombo = GUICtrlCreateCombo("", 160, 77, 225, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) For $iX = 1 To $print[0][0] ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $iX = ' & $iX & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console GUICtrlSetData(-1, $print[$iX][0],"") Next When run uncompiled, the array displays perfectly, with no debug errors at all. Unfortunately, the same error came up when trying to runas the Printer Install script when it is compiled. So it does not even open it to debug it. As stated before, when run from the au3 file or if I run the exe just by double clicking on it, there are no errors. So nothing to debug. Thanks for the hints though. I ended up trying this in place of the arrays: $PrintCombo = GUICtrlCreateCombo("", 160, 77, 225, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) $file = FileOpen("printerlist.txt", 0) $lineComplete = "" while 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop $lineComplete = $lineComplete & $line GUICtrlSetData(-1,$lineComplete) WEnd FileClose($file) Now it does not show the error when using runas. Instead, I see the autoit icon in the system tray, but it does not open the GUI! Gah!!
  12. Thanks, but I have picked up on this and tried with the ini file in the same folder as the script and withwithout the "." in front. Still fails with the same error. I am now resorting to finding a way without using arrays. Maybe using filereadline, but it only reads one line. Ah well. Another journey to undertake!
  13. Still happening Here is the error that happens EVERY time. It is always the same (with yours and mine). I can see what you were doing with the ini files, too. I didn't have anything in the "value" field for a couple of them. Made no difference though unfortunately. As mentioned above, ONLY happens when I try and run as from a different autoit script (compiled or uncompiled) or runas with a command prompt. If I right click and Run As a different user, it works perfectly fine. Thanks a million for you input though Aipion. My head will now explode...
  14. Thanks Aipion. I wish i could try this, but my work proxy has blocked your site. Nothing personal, our filters are just really paranoid! I think it picked up the .co.cc domain and slammed down the iron door of fear! Is it possible to post the au3 file? Thanks again
  15. FINAL EDIT: The answer you seek is at the EDIT: It definitley has to do with any part of the code with this in it: For $iX = 1 To $print[0][0] GUICtrlSetData(-1, $print[$iX][0],"") Next which calls on this: $print = IniReadSection(".ifileprinterlist.ini","PRINTERS") I commented all of the arrays and it worked fine. So I guess i need to figure out what I'm doing wrong here. END EDIT MORE EDITS I used a totally different array and it still fails when trying to runas. I tried to runas using a command prompt and it failed with the same error again. I have no idea whats going on. It may be something to do with the Include file Array.au3. I am going to go that way next. END MORE EDITS ********************************************************************************************************************** I am just wondering if the below code is, in fact, correct (the way that the combolists are getting information from the ini files): #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Array.au3> $print = IniReadSection(".ifileprinterlist.ini","PRINTERS") $port = IniReadSection(".ifileportlist.ini","PORTS") $queue = IniReadSection(".ifilequeuelist.ini","QUEUE") $queuemini = IniReadSection(".ifilequeuelist2.ini","QUEUE") globaL $PrintGUI = GUICreate("Printer Installation Assistant", 530, 349, 192, 114) GUISetBkColor(0xA6CAF0) $EnterPC = GUICtrlCreateInput("", 160, 45, 225, 21) $PCNum = GUICtrlCreateLabel("Enter PC number:", 18, 49, 107, 20) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $PrintCombo = GUICtrlCreateCombo("", 160, 77, 225, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) For $iX = 1 To $print[0][0] GUICtrlSetData(-1, $print[$iX][0],"") Next $PortCombo = GUICtrlCreateCombo("", 160, 110, 225, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) For $iY = 1 To $port[0][0] GUICtrlSetData(-1, $port[$iY][0],"") Next $QueueCombo = GUICtrlCreateCombo("", 160, 141, 225, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) For $iZ = 1 To $queue[0][0] GUICtrlSetData(-1, $queue[$iZ][0],"") Next I am trying to use this code: CredCheckPrint.au3 to call this code: Printer Install.au3 as an adminstrator. What I have posted above is the the first part of Printer Install.au3. When Printer Install.au3 is run on its own (compiled or uncompiled), it works absolutely perfectly. If I try to runas from the CredCheckPrint.au3 file, it fails with "Subscript used with non-Array variable error". It cites line 1591 of the Printer Install script as the culprit, but this line does not exist. I can use the CredCheck script to run other scripts with no issue. If I right click Printer Install and Run as an admin manually, it works fine. I am at a loss and I know there is something in the way I have used the array that is not working. There are more combo boxes further down the script (different GUI's) that use the same method as is shown above. I know very little about arrays and have borrowed this from someone on this forum. Once I get this working I am going to post and credit it to who I borrowed it from. Thanks in advance for any help. Edit: Needed to make more sense at the beginning.
×
×
  • Create New...