Jump to content

Overkill

Active Members
  • Posts

    73
  • Joined

  • Last visited

Everything posted by Overkill

  1. Running back into this issue for a different script...same concept though. Anybody have input on this? Should I be looking at a full programming language that I can compile in instead?
  2. Hi all, I am working on a GUI program to update Google's Dynamic DNS (API at https://support.google.com/domains/answer/6147083?authuser=1&hl=en if you scroll to bottom). I am not a programmer by any means - just a sysadmin who has picked up on some things along the way. I am sure that there's better ways to do a lot of things in this script; I'm just going with what I know. My challenge right now is that I'd like a better way to store the credentials both in memory as well as in system registry or INI file (not sure which way I want to go for local storage). How should I convert the passwords to a secure string in a manner that can't be easily reversed, yet is still accessible to the script? Is that even an option in AutoIt? Can anybody provide me with links to good reference posts, or coding suggestions for how best to achieve this in the script below? I am using the WinHTTP UDF (https://github.com/dragana-r/autoit-winhttp/releases) to make my API calls. #include<WinHTTP.au3> #include<GUIConstantsEx.au3> #include<EditConstants.au3> #include<iNet.au3> #include<Array.au3> DIM $aDomainList[1][4] $aDomainList[0][0] = 0 $gMainGUI = GUICreate("Overkill's Google DNS Updater",800,800) $gDomainLabel = GUICtrlCreateLabel("FQDN",21,8) $gDomainInput = GUICtrlCreateInput("",60,5,300) $gUserLabel = GUICtrlCreateLabel("Username",5,36) $gUserInput = GUICtrlCreateInput("",60,32,130,Default,BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD)) $gPasswordLabel = GUICtrlCreateLabel("Password",6,64) $gPassInput = GUICtrlCreateInput("",60,60,130,Default,BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD)) $gAddButton = GUICtrlCreateButton("ADD DOMAIN",200,31,160,52) $gCurrentIP = GUICtrlCreateLabel("Current IP: " & _CheckIP(),5,780) $gDomainList = GUICtrlCreateListView("Domain | Resolved IP | Update Status",5,120,600,600) GUISetState(@SW_SHOW,$gMainGUI) while 1 $m = GUIGetMsg() IF $M = $GUI_EVENT_CLOSE then Exit IF $M = $gAddButton Then $sAddDomain = GUICtrlRead($gDomainInput) $sAddUser = GUICtrlRead($gUserInput) $sAddPass = GUICtrlRead($gPassInput) $sResolveIP = _DNSCheck($sAddDomain) ;Google wants you to avoid sending updates when there are no changes If StringCompare($sResolveIP,_CheckIP()) = 0 Then $sStatus = "No change, not sending update" Else $sStatus = _DNSUpdate($sAddDomain,$sAddUser,$sAddPass) EndIf ;Check to make sure all fields are completed before continuing IF StringLen($sAddDomain) = 0 OR StringLen($sAddUser) = 0 OR StringLen($sAddPass) = 0 Then MsgBox(0,"","Please complete all fields") Else ; If the fields all have data, then continue ;Check to see if the entry exists in the array already $iSanity = _ArraySearch($aDomainList,$sAddDomain) IF $iSanity = 0 Then _ArrayAdd($aDomainList,$sAddDomain & "|" & $sAddUser & "|" & $sAddPass ) If @error = 0 Then $aDomainList[0][0] += 1 $aDomainList[$aDomainList[0][0]][3] = GUICtrlCreateListViewItem($sAddDomain & "|" & $sResolveIP & "|" & $sStatus,$gDomainList) Else MsgBox(0,"","Error adding input to list") EndIf Else ; If $iSanity <> 0 ; Update existing info in array and listviewitem $aDomainList[$iSanity][0] = $sAddDomain $aDomainList[$iSanity][1] = $sAddUser $aDomainList[$iSanity][2] = $sAddPass GUICtrlSetData($aDomainList[$iSanity][3],$sAddDomain & "|" & $sResolveIP & "|" & $sStatus) EndIf ; If $iSanity = 0 EndIf ; If StringLen... EndIf ; If $m = $gaddbutton WEnd ;---------------------------------------------------------------------------------------- Func _DNSCheck($sFQDN) $sJSON = _INetGetSource("https://dns.google.com/resolve?name=" & $sFQDN & "&cd=1") ConsoleWrite($sJSON & @CRLF) $sIPAddress = StringRegExpReplace($sJSON,'^.*data": "(.*?)".*?$',"\1") Return $sIPAddress EndFunc ;---------------------------------------------------------------------------------------- Func _DNSUpdate($sFQDN,$sUser,$sPass) Local $sGoogleAPIURI = "https://domains.google.com" Local $hOpen = _WinHttpOpen() Local $hConnect = _WinHttpConnect($hOpen, $sGoogleAPIURI) Local $sHeader = _ 'Authorization: Basic ' & _Base64Encode($sUser & ":" & $sPass) & @CRLF & _ 'Accept: */*' & @CRLF & _ 'User-Agent: AutoITScript/' & @AutoItVersion & @CRLF & _ 'Content-Type: application/x-www-form-urlencoded' Local $aHTTPResponse = _WinHttpSimpleSSLRequest($hConnect, "POST", "/nic/update", Default, "hostname=" & $sFQDN, $sHeader, True, Default, Default, Default, True) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) If IsArray($aHTTPResponse) Then $sHTTPResponse = "Header:" & @CRLF & $aHTTPResponse[0] & @CRLF & "Data:" & @CRLF & $aHTTPResponse[1] & @CRLF & @CRLF & @CRLF Return $aHTTPResponse[1] Else $sHTTPResponse = "NO REPLY" Return "No reply from " & $sGoogleAPIURI EndIf EndFunc ;---------------------------------------------------------------------------------------- Func _Base64Encode($sData) Local $oXml = ObjCreate("Msxml2.DOMDocument") If Not IsObj($oXml) Then SetError(1, 1, 0) EndIf Local $oElement = $oXml.createElement("b64") If Not IsObj($oElement) Then SetError(2, 2, 0) EndIf $oElement.dataType = "bin.base64" $oElement.nodeTypedValue = Binary($sData) Local $sReturn = $oElement.Text If StringLen($sReturn) = 0 Then SetError(3, 3, 0) EndIf Return $sReturn EndFunc ;---------------------------------------------------------------------------------------- Func _CheckIP() Return _INetGetSource("https://domains.google.com/checkip") EndFunc ;----------------------------------------------------------------------------------------
  3. Just tried this UDF - loving it! Quick question/possible bug though... I am a keyboard ninja and I hate mice. So, when I have a dialog pop up and I press tab + spacebar, it returns the default button (in this case, the "No" button) regardless of which one has been selected. When I do the same behavior with the enter key instead, it works fine. Any idea what's going on here? Thanks, Overkill
  4. At my work, most ports including the one used by the Internet Time sync are blocked by a firewall. Some systems (especially those with bad CMOS batteries) need to have the clock set before Windows Update works, so I wrote this for our software toolkit. Any changes, corrections, or criticisms welcome. I am always looking to improve my code! #RequireAdmin #include<Date.au3> ; For the ActiveTimeBias registry key: ; 4294967296 = 0 for UTC +X:YZ time zones; subtract value of key to get time zone offset. ; EG: 4294976296-4294976236 = 60 = UTC +1:00 ; ; UTC time zone uses 0 for the value ; ; UTC -A:BC time zones use the number of minutes of the offset ; EG: 480 = UTC -8:00 ; To-Do: ; 1. Add a timezone check to make sure the system is properly configured for its area ; EG: Time Zone is currently "Pacific Standard Time", is this correct? [Y/N] ; 2. Add error checking to _EndOfMonth() should the need arise [user editing of code] ; EG: -2 is not a valid month, you silly goose! ; ---------------------------------------------------------------------------------------------------------------------------------- ; Get time from HTTP server (Defaults to google.com ... pool.ntp.org is a good alternative) ; ---------------------------------------------------------------------------------------------------------------------------------- $site = "www.google.com" $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("GET", "http://" & $site & "/", False) $oHTTP.Send() $date = $oHTTP.GetResponseHeader("Date") ; ---------------------------------------------------------------------------------------------------------------------------------- ; ---------------------------------------------------------------------------------------------------------------------------------- ; ---------------------------------------------------------------------------------------------------------------------------------- ; Set Global variables used throughout the script ; ---------------------------------------------------------------------------------------------------------------------------------- ; $tzo: TimeZoneOffset (the number of hours by which the local machine varies from UTC) Global $tzo = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation","ActiveTimeBias") Global $y = StringMid($date,13,4) ; The current year Global $m = StringMid($date,9,3) ; The current month Global $d = StringMid($date,6,2) ; The current day of month Global $h = StringMid($date,18,2) ; The current hour Global $n = StringMid($date,21,2) ; The current minute Global $s = StringMid($date,24,2) ; The current second IF $M = "JAN" THEN $M = 1 ; 31 days in month IF $M = "FEB" THEN $M = 2 ; 28/29 days in month IF $M = "MAR" THEN $M = 3 ; 31 days in month IF $M = "APR" THEN $M = 4 ; 30 days in month IF $M = "MAY" THEN $M = 5 ; 31 days in month IF $M = "JUN" THEN $M = 6 ; 30 days in month IF $M = "JUL" THEN $M = 7 ; 31 days in month IF $M = "AUG" THEN $M = 8 ; 31 days in month IF $M = "SEP" THEN $M = 9 ; 30 days in month IF $M = "OCT" THEN $M = 10 ; 31 days in month IF $M = "NOV" THEN $M = 11 ; 30 days in month IF $M = "DEC" THEN $M = 12 ; 31 days in month Global $epm = _EndOfMonth($M-1) ; The last day of the previous month (28-31) Global $ecm = _EndOfMonth($M) ; The last day of the current month (28-31) ; Correct value for $tzo from the registry value to a +/- number of hours IF $tzo < 1500 Then $tzo /= -60 Else $tzo = (4294967296 - $tzo)/60 EndIf ; ---------------------------------------------------------------------------------------------------------------------------------- ; ---------------------------------------------------------------------------------------------------------------------------------- ; ---------------------------------------------------------------------------------------------------------------------------------- ; Calculate time zone changes (correct the hour/day/month/year based on timezone/hour/day/month changes ; ---------------------------------------------------------------------------------------------------------------------------------- $h += $tzo ; Set the local hour based on offset from UTC Select ; If the hour changes day forward/backward, correct appropriate values. Case $h >= 24 $d += 1 $h -= 24 Case $h < 0 $d -= 1 $h += 24 EndSelect Switch $d ; If the day changes month forward/backward, correct appropriate values. Case $ecm+1 $m += 1 $d = 1 Case 0 $m -= 1 $d = $epm EndSwitch Switch $m ; If the month changes year forward/backward, correct appropriate values. Case 0 $m = 12 $d = 31 $y -= 1 Case 13 $m = 1 $d = 1 $y += 1 EndSwitch ; ---------------------------------------------------------------------------------------------------------------------------------- ; ---------------------------------------------------------------------------------------------------------------------------------- ; ---------------------------------------------------------------------------------------------------------------------------------- ; Set system date/time using functions from #include<Date.au3> ; ---------------------------------------------------------------------------------------------------------------------------------- _SetDate($d,$m,$y) _SetTime($h,$n,$s) ; ---------------------------------------------------------------------------------------------------------------------------------- ; ---------------------------------------------------------------------------------------------------------------------------------- ; ---------------------------------------------------------------------------------------------------------------------------------- ; FUNCTION: _EndOfMonth ::: Determine the ending date of the month (28, 29, 30, or 31) ; ---------------------------------------------------------------------------------------------------------------------------------- Func _EndOfMonth($vMON) local $end Switch $vMON Case 0, 1, 3, 5, 7, 8, 10, 12, 13 $end = 31 Case 4, 6, 9, 11 $end = 30 Case 2 If IsInt(@YEAR/4) Then $end = 29 Else $end = 28 EndIf Case Else SetError(-1) Return(0) EndSwitch Return($end) EndFunc ; ---------------------------------------------------------------------------------------------------------------------------------- ; ----------------------------------------------------------------------------------------------------------------------------------
  5. We're trying to run our store's tech toolkit, written in autoit, on an XP machine and this error pops up when we try to run. Is there something like the VB runtime we need to install first (note: we tried VB and .NET first, no luck), but it seems like the computer isn't recognizing the commands being passed to it. This is the first time we've seen this in the 20 months I've been with the company. Thanks, Overkill
  6. Thanks for all the help guys, I'll take a look into all this!
  7. I'm going to be using the Administrator account to do everything from now on because I'm sick of Windows trying to save me from myself...if only I could just stick "sudo" in front of everything... Anyway, I'll try doing that when I get around to logging back over to the other account so that people who search for this later will see some how to steps ^.^
  8. I'm planning on writing a script that will check to see if my installer library of several dozen programs (I do a lot of installs for clients >.>) is up to date. I've been looking at using _IEBodyReadText and regular expressions to determine the latest version available, then comparing that against the current installer version. I'm sitting here thinking that this is way too complicated, and that there has to be an easier way to do it...but I can't find anything that fits. I figured I'd ask here and see if anybody had an idea or two that'd be helpful xD
  9. I suspect that this has something to do with the way the installer is packaged, since "Run as Administrator" didn't help at all...but when I installed AutoIt on my machine the "New" > "AutoIt v3 Script" context menu item isn't there. I checked under HKCR/.au3/ShellNew and it's set up properly, but it won't show up even after a reboot. When I run the installer directly from the Administrator account, however, it shows up immediately following installation (but only for the Admin account!) I edited the "Classes" entry under the PostSetup key, but the changes will not stick even when run as admin. This is probably the source of the problem, but I can't find a way to fix this. Any ideas? -Overkill +EDIT 3/12 19:27 GMT Just tried running an AU3 script with #requireadmin to change the value, still won't stay changed (it shows, then disappears) Also, I can't see the MRU values for the Run dialog...may be something bigger at play here.
  10. We sell a lot of floor models this time of year and I'd much prefer to have a script set up that we can remove quickly and easily when needed without making any software changes to the computer so that if the customer doesn't want to wait to for the computer to be re-imaged we can get them out the door in a timely manner. I appreciate your alternative ideas but there is a method to my madness, and at this point I'd like to focus on the question asked instead of different theories.
  11. 1) CTRL+SHIFT+ESC is the hotkey combo for taskmgr in Windows ME II (Vista) and Windows 7. 2) I suppose in the stop function you could have a password window pop up instead of exiting the script, but I'd really just like to have this installed as a service that restarts itself when the script is closed like many AV programs, netlimiter, and others do. As for DeepFreeze/HDGuard - retail store = corporate licensing = costs money = declined. This script is officially unsanctioned by the management (though unofficially they like the idea), so they're going to be "unaware" of my actions and will "take appropriate action" if something goes wrong. We're not even allowed to use our own toolkits on virus removals when the provided AV software fails, so something like this is of course very much a violation of policy.
  12. The short version is that we may need access to all of that stuff at the drop of a hat, and rather than go through something complicated I can enter a password into the admin login for my script and it will give me or another associate control of whatever is needed. The svchost.exe idea is something that I've used in the past but this needs to be a little smarter than that since Win7 has the "full path" option in the task manager. Running it as a service may be the best way to do this but I don't have the experience/knowledge needed to do this quickly and efficiently.
  13. You rang? Use the RegRead/RegDelete commands to check for and delete entries in HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU The key names used are MRUList and the letters a through z.
  14. I work as a tech/salesperson for a retail outlet and one of our biggest problems is kids messing with our floor models (adding passwords, changing homepage, etc) and I'm writing a script that will stop all that once and for all. The question I have for you guys is what's the most effective way to prevent the script from being closed via the task manager? Would it be to write a second script and have each script ProcessExists($otherscript), or is there a more elaborate way that would take more than fast fingers to get around?
  15. Worked perfectly! Thanks =) Getting the last kinks worked out of my first 'major' script...this was bugging me for a while lol.
  16. That effectively achieves part of my goal, but I still want it to behave like a button (with mouseover/onclick behaviors), which is why I'm not using it. Plus, you can click on a button and it won't set GUIGetMsg() until you release the mouse button with the cursor still over it (gives you the ability to change your mind or correct a misclick). the label sends immediately on clicking, which removes this ability. It might be that the source of my problem is in the Windows XP theme, but I haven't done anything other than ponder it yet. If there's no other workaround then I suppose the label trick will have to do.
  17. How do I get rid of the blue outer border surrounding a button? I don't want the blue killing the GUI >< Also, how can I customize the mouseover/onclick colors of the button? If I specify GUICtrlSetBkColor or GUICtrlSetColor the button loses the default mouseover properties (mouseover=gold inner border, onclick=no inner border). I tried using the style/exstyle stuff and nothing I tried worked. Created a second button so that I could tab off of my main button's focus. Example: (forgive my bored humor) #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $GUI = GUICreate("This is a test GUI",300,100) GUISetBkColor(0x000000) GUICtrlCreateButton("X",0,0,1,1) GUICtrlSetBKColor(-1,0x000000) GUICtrlSetColor(-1,0x000000) $BTN = GUICtrlCreateButton("This is not a test",25,25,250,50) GUICtrlSetBKColor(-1,0x000000) GUICtrlSetColor(-1,0x00FF00) GUISetState() While 1 Switch GUIGetMsg() Case $BTN MsgBox(16,"EXPLOSION!","Told you it wasn't a test. You die in the explosion.") Case $GUI_EVENT_CLOSE MsgBox(0,"SAFE!","Congratulations: Curiosity didn't kill you...this time...") Exit EndSwitch Wend
  18. I'm on XP...the list can be modified on the machine to include other values (for instance, the +4 attribs on my PC). That's what I was talking about.
  19. I came across this while building an app for my MP3 files. When I tried using the # values for Artist and Title, neither returned what it was "supposed" to. I found that part of the reason was because I had an external app, called FolderSize, installed. FolderSize adds a column to explorer called "FolderSize" which displays the size of both files and folders...really useful sometimes Anyway, I thought that was the whole story, and I right clicked on the top of the listview and selected "more". This gave me the full list of the possible fields in the same order as the UDF returned them. So I went on to investigate, and long story short, came up with the following: The max value for a few of the music files on my PC was 44 (45th array item). Using this UDF to read one of the files returned the following: For $I=40 to 44 ConsoleWrite($I & ": " & _GetExtProperty($PATH,$I) ) Next Wrote this into the console: 40: Description 41: File Version 42: Product Name 43: Product Version 44: Keywords Also, the value I used for artist was 20, and the title was 14 I may set it up to scan all of my HDDs for another max but that'd take a while...3097 files took me roughly 4.5 minutes scanning from $I=40 to 60. Anyway...any thoughts, comments, etc? Anyway, I got my script working thanks to this UDF =) +Pretend Rep
  20. Brain isn't quite ready to absorb this at 6:45AM so I'll come back later. I wish you better luck tomorrow M =) While $ballinhole=False MsgBox(48,"Warning","FORE!!!") HitBall($club,$power,$direction) Wend
  21. I'll give this a test as soon as I have my dual-monitor setup back (I'm currently reinstalling Windows on a box that was 'bricked' by a failed SP3 install on the other monitor). Also, the whole goal was to get reposition it with the window resize :/ I suppose I could add a button to do it for me...but that would be messy...not to mention not automated! Have fun golfing ^.^
  22. I'll try and keep that in mind Any insight you may have on the other thread would be appreciated...program works like this but it'd work better if I could make the listview take up more space...some of the artists i have on here are 200-400 songs ><
  23. Yeesh...you've got 38 years of coding on me. I'll start catching up in the next 30-40 years though, no worries I also need to figure out how I'm going to build the array that reads which item is checkmarked and associates it with the filename since $songlist gets pushed out each step of the for loop. I wonder if a 56x302 arrray would use up too much memory... Nope, guess not....Yay! Now it'll tell me which MP3s are selected TODO: Make application actually do something
  24. Well, I appreciate the help I'm usually doing 3 things at once while reading these posts and i miss something glaringly obvious This is a major hump I'm climbing over too...my coding experience is very very limited =) Been learning and teaching myself a lot, and having fun doing it We'll see how this goes...and now all I need to do is find a way to resize the listview to be right below the tabs even if i maximize it and I'm good That's what the thread i linked earlier is ^^
  25. I lied...once I got back to the file and reworked the code, etc. It started telling me that everything is checkmarked. I've edited the code a bit so that it'll work on any PC, and the main code is still the same. If I need to go through and comment it, I can. Thanks again for being awesome FileList2.au3
×
×
  • Create New...