Jump to content

ShawnW

Active Members
  • Posts

    192
  • Joined

  • Last visited

Everything posted by ShawnW

  1. If try and upload it still shows as '?'. Also, I don't get the same result after opening in Excel 2016. Running on test file and opening in Excel shows the '?' on both the UTF8 and ANSI versions. I tried something simpler and copied the actual hyphen and just added it in string form. It looks correct in the scite editor, and if I output it to the console when running it shows correctly there as well. Yet after Excel writes it to the csv it breaks, and no matter where I open it, or what font I use, it shows as a '?'. It seems the problem is in the way excel makes the csv, I may just do a more complex csv manual creation building on your 1st example. It seems the display problem i had with the hyphen after writing the file without excel was indeed the font problem you refer to. If I can't do it that way though I may just have to fight every OCD bone in my body and add it as the html code ‑ since it is only ever going to be displayed on a webpage that way.
  2. That didn't seem to change the encoding. I did play with it some more though based on this idea. It seems neither that nor writing to the file in that method changed it to UTF8. I did find that if i read it, then open it in overwrite mode it and write it then it changes to UTF8. $str = FileRead(@DesktopDir & "\test.csv") $hFileOpen = FileOpen(@DesktopDir & "\test.csv",130) FileWrite($hFileOpen, $str) FileClose($hFileOpen) But that still leaves the problem of the hyphen.
  3. Thanks for the suggestion. The first problem there is that 0x2014 is the Em Dash that although present in the excel file data, is not what i need when I add the hyphen in that line. I need the shorter dash like on the keyboard except one that is treated as part of the word when wrapping. I'm thinking it is 0x2011 but I cannot get that to display. In researching the dashes I should honestly be using an En Dash (0x2013) for showing a range of numbers, but that breaks in wrapping, and I didn't get to set the requirements for this, I just have to come up with the solution. Secondly, FileWrite on the array does add commas for the csv but that is all it does. It does not add quotes around cells that contain a comma already, and if it did, it wouldn't escape existing quotes either. I didn't have a line like this in my example because I did not consider a different way of creating the csv, but I do have lines that would require a more accurate csv creation.
  4. I have a script that takes a large excel file, pulls out and reorganizes certain information I need, and spits out a trimmed down csv file which I uses to upload the information on my website. Some of this information contains characters with accents or em dashes. By default it would create a csv file in ANSI which I then uploaded but had to tell my website import system it was windows-1252 in order for it to look correct. This was all working fine except now I need to add in a non-breaking space and non-breaking hyphen into parts of my output. At first I tried using ChrW(0xA0) and ChrW(0x2011) as replacements. A quick test in the console looked correct, however opening the csv output in notepad++ showed the space correctly but a ? for the hyphen and the file was still encoded as ANSI. I tried to view it as UTF-8 instead but this just made the space appear as xAO and also other characters appeared that way like my em dashes appeared as x97 and another symbol as xA7 etc. If I instead do a convert to UTF-8 from notepad++ then those problems go away except the hyphen still displays as ?. I then noticed on the page I linked for the non-breaking hyphen it lists the UTF-8 hex as 0xE2 0x80 0x91 (e28091). I was unsure how to enter this in autoit but several things i tried all failed to get the hyphen inserted. I need a way to get both the space and hyphen added correctly as either ANSI or UTF-8, but if it is UTF-8 then I need a way to convert all of the other data I extracted from the excel file. I've included a test excel file with a single line and test script to create a csv demonstrating the problem. test.xlsx test.au3
  5. Ah thanks, scite wasn't running with admin apparently and I wasn't actually building the exe to test. I did have setpassword before but took it out when trying to find where they error was coming from.
  6. I know there are threads out there for creating local accounts with similar steps and I've used them successfully in the past. When it failed now though I stripped it down to what I assume is the minimum without adding properties or passwords, but still fails and I cannot figure out why. $oSys = ObjGet("WinNT://" & @ComputerName) $oUser = $oSys.Create("user", "tester") $oUser.SetInfo It fails when autoit thinks SetInfo is a method of the object.  ==> The requested action with this object has failed.: $oUser.SetInfo $oUser^ ERROR Anyway, I'm using windows 10. Any ideas are appreciated.
  7. So I work at a university and one of the PhD students and a faculty member I support came to me with this problem. I'm giving backstory because the request itself might come off as rather shady, but it is purely for academic interest, among a controlled group of volunteers for dissertation research. They will be giving a large set of students and other volunteers a set of problems to solve, such as researching the best location for a certain type of business in a particular city. Anyway, they want to study how the volunteers go about finding the answers. The want to be able to track the URLs visited, time spent on each page, number of words on page, number of images/videos on page, and list of the meta tags. They are fine with having the volunteers run an exe before starting in order to track the data. The only solution I have thought of so far is to also ask that the volunteers use IE and have autoit use the IE functions to track and parse the required information. I haven't built anything yet, but before I start I would like to get any other ideas that might not restrict it to IE, or even a non-autoit solution so that they don't have to eliminate mac users from the test. I realize this type of tracking is exactly what browsers and security software tries to prevent and told them as much, if necessary we can force users to take the tests in our lab where we have complete control but this would limit the scope of the test significantly.
  8. Well looks like I stumbled on a need for this a year to late since the original poster seems to not be around anymore but I just want to say Awesome Work!!! Some improvements that are needed from what I have seen so far, and I may have to write them myself for what I need are... Make _ClosePDFFile() clear the buffers so that resources from one pdf do not get loaded into subsequent pdfs and cause larger and larger files the more you create. Since all the stuff gets written at the end, and since order maters as seen in >#224, why not keep a separate buffer for resources that you can put in order later when writing. That way you can loop through some data and dynamically load and insert images within a page, rather than loop to load, then start the page and loop again to insert. Other notes that are just me being picky take udf out of the name, no other udf has udf in the name. Start the function names with a common identifier like _MPDFDrawLine, _MPDFPath,... So users can easily know what the function is referencing.
  9. Nice idea but if the user is running something like a browser page that updates itself, or gets a new email which is cashed in outlooks ost file, or any number of other things that could write to a file while the user is not there, this might throw it off. Plus I've never really trusted windows folder time stamps. To many times I've navigated into a folder noting its "last modified" date, only to find a sub folder with a "last modified" date later than the parent folder.
  10. You'd think right? But apparently I'm supposed to be proactive in supporting idiots. I'm at a university and support faculty, staff, and phd students. Faculty bring in the money with grants and students and such, so we gotta bend over backwards to cater to them, unfortunately they seem to be the most stubborn, hard to work with, and technically challenged group of individuals.
  11. I have AD admin permissions to the computers I support. I'm trying to write a simple script that will give me a popup when a someone is active at a specific computer. I've been playing email tag with a certain user that needs help and needs to be there when I come assist. We keep missing each other so I figure something that lets me know the second they do something at their computer would be helpful. The user stays logged so I cannot just look for that, and they also do not always lock their computer (gonna have to talk with them about that) so I cannot check for that either. Is there anything else I can look for remotely that might help?
  12. So the normal way of resizing a gui control along with your window is to use GUICtrlSetResizing() which requires the controlID. Since _GUICtrlListView_Create() only returns the handle, and I could not find a way to look up a controlID based on that, I used AU3Info to determine that my listview seems to always have an ID of 10000. Using this though I am still unable to get the listview created with the UDF method to resize along with the window. Can someone help?
  13. Umm so if you are able to click the button, would the window not already be on top?
  14. Upon thinking on this further you might be able to write your own script to get a similar effect. Not sure if this will work for everything but if all your concerned about is file and folders located on the c:\ drive then you could do something like this. $current_clip = ClipGet() While True Sleep(100) If Not (ClipGet() == $current_clip) Then If StringLeft(ClipGet(),3) = "C:\" Then ClipPut($current_clip) Else $current_clip = ClipGet() EndIf EndIf WEnd Basically this constantly checks your clipboard to see if the data there is a path on the c:\ drive. If it is then it replaces it with whatever was in the clip previously. This still won't stop you from copying the data off from a networked computer with the proper permissions. I might ask though what purpose might something like this serve?
  15. 1st this post is from 2006 and the functions used no longer exist. AdlibRegister and AdlibUnregister are what would be required. 2nd no, the clip is always global.
  16. Well I didn't wanna dig through a huge script to see what we used in production but I believe I used this in testing. I didn't really have that many variables since a lot of it was just put inline. I pulled it out to make it easier to edit. #include "EnvUpdate.au3" $CompName = 'BA-Test' $ou = 'ou=*****,ou="**** *******",ou=***,dc=***,dc=**,dc=***,dc=***' $fulldomain = '***.**.***.***' $domain = '***' $user = '***********' $password = '***********' ; http://msdn.microsoft.com/en-us/library/ms724931(v=VS.85).aspx ; Parameter int 5 = ComputerNamePhysicalDnsHostname $result = DllCall("Kernel32.dll", "BOOL", "SetComputerNameEx", "int", 5, "str", $CompName) If $result[0] = 0 Then MsgBox(0, "Error: Kernel32.dll", "SetComputerNameEx() Failed. Return code: " & $result[0]) RegWrite("HKLM\SYSTEM\CurrentControlSet\Control\Computername\ActiveComputername", "ComputerName", "REG_SZ", $CompName) RegWrite("HKLM\SYSTEM\CurrentControlSet\Control\Computername\Computername", "ComputerName", "REG_SZ", $CompName) RegWrite("HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters", "Hostname", "REG_SZ", $CompName) RegWrite("HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters", "NV Hostname", "REG_SZ", $CompName) RegWrite("HKEY_USERS\.Default\Software\Microsoft\Windows Media\WMSDK\General", "Computername", "REG_SZ", $CompName) _EnvUpdate("COMPUTERNAME", $CompName, False, True) ; http://msdn.microsoft.com/en-us/library/aa370433(VS.85).aspx $result = DllCall("Netapi32.dll", "long", "NetJoinDomain", "int", 0, "wstr", $fulldomain, "wstr", $ou, "wstr", $domain & "\" & $user, "wstr", $password, "dword", 0x00000423) MsgBox(0, "1", "Return: " & $result[0] & @CRLF & "Error code: " & @error) ; If Dll returned anything but 0 then it failed Try again without creating an object in case it failed because the object already existed. If $result[0] Then $result = DllCall("Netapi32.dll", "long", "NetJoinDomain", "int", 0, "wstr", $fulldomain, "wstr", $ou, "wstr", $domain & "\" & $user, "wstr", $password, "dword", 0x00000421) MsgBox(0, "2", "Return: " & $result[0] & @CRLF & "Error code: " & @error) EndIf RegWrite("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "AltDefaultDomainName", "REG_SZ", $domain) RegWrite("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultDomainName", "REG_SZ", $domain) And the EnvUpdate.au3 I found somewhere here on the forums but here it is so you don't have to search. #include-once ; #INDEX# ======================================================================================================================= ; Title .........: Environment Update ; AutoIt Version.: 3.2.12++ ; Language.......: English ; Description ...: Refreshes the OS environment. ; Author ........: João Carlos (jscript) ; Support .......: trancexx, PsaltyDS, KaFu ; =============================================================================================================================== ; #CURRENT# ===================================================================================================================== ;_EnvUpdate ; =============================================================================================================================== ; #INTERNAL_USE_ONLY# =========================================================================================================== ; =============================================================================================================================== ; #VARIABLES# =================================================================================================================== Global $MAX_VALUE_NAME = 1024 Global $HWND_BROADCAST = 0xffff Global $WM_SETTINGCHANGE = 0x001A Global $SMTO_ABORTIFHUNG = 0x0002 Global $SMTO_NORMAL = 0x0000 Global $MSG_TIMEOUT = 5000 ; #Example# ===================================================================================================================== ;_EnvUpdate("VERSION", "7.07.0110.2600") ;MsgBox(4096, @error, EnvGet("VERSION")) ;_EnvUpdate("VERSION", "", True, True) ;MsgBox(4096, @error, EnvGet("VERSION")) ; =============================================================================================================================== ; #FUNCTION# ==================================================================================================================== ; Name...........: _EnvUpdate ; Description ...: Refreshes the OS environment. ; Syntax.........: _EnvUpdate( ["envvariable" [, "value" [, CurrentUser [, Machine ]]]] ) ; Parameters ....: envvariable - [optional] Name of the environment variable to set. If no variable, refreshes all variables. ; value - [optional] Value to set the environment variable to. If a value is not used the environment ; variable will be deleted. ; CurrentUser - [optional] Sets the variable in current user environment. ; Machine - [optional] Sets the variable in the machine environment. ; Return values .: Success - None ; Failure - Sets @error to 1. ; Author ........: João Carlos (jscript) ; Support .......: trancexx, PsaltyDS, KaFu ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........; ; Example .......; _EnvUpdate("TEMP", @SystemDir & "TEMP", True, True) ; =============================================================================================================================== Func _EnvUpdate($sEnvVar = "", $vValue = "", $fCurrentUser = True, $fMachine = False) Local $sREG_TYPE = "REG_SZ", $iRet1, $iRet2 If $sEnvVar <> "" Then If StringInStr($sEnvVar, "\") Then $sREG_TYPE = "REG_EXPAND_SZ" If $vValue <> "" Then If $fCurrentUser Then RegWrite("HKCU\Environment", $sEnvVar, $sREG_TYPE, $vValue) If $fMachine Then RegWrite("HKLM\System\CurrentControlSet\Control\Session Manager\Environment", $sEnvVar, $sREG_TYPE, $vValue) Else If $fCurrentUser Then RegDelete("HKCU\Environment", $sEnvVar) If $fMachine Then RegDelete("HKLM\System\CurrentControlSet\Control\Session Manager\Environment", $sEnvVar) EndIf ; http://msdn.microsoft.com/en-us/library/ms686206%28VS.85%29.aspx $iRet1 = DllCall("Kernel32.dll", "BOOL", "SetEnvironmentVariable", "str", $sEnvVar, "str", $vValue) If $iRet1[0] = 0 Then Return SetError(1) EndIf ; http://msdn.microsoft.com/en-us/library/ms644952%28VS.85%29.aspx $iRet2 = DllCall("user32.dll", "lresult", "SendMessageTimeoutW", _ "hwnd", $HWND_BROADCAST, _ "dword", $WM_SETTINGCHANGE, _ "ptr", 0, _ "wstr", "Environment", _ "dword", $SMTO_ABORTIFHUNG, _ "dword", $MSG_TIMEOUT, _ "dword_ptr*", 0) If $iRet2[0] = 0 Then Return SetError(1) EndFunc ;==>_EnvUpdate Edit: And this was used and tested on XP only.
  17. Kor you are wrong, I don't know about that program but I have a script somewhere that can rename and join the domain with the new name all without restarting. I've used it in production and it works fine. I'll try and dig it out.
  18. Like many others before me I have found SCCM falls short in many areas and have created an autoit install wrapper for my programs, using a passed .ini file parameter for different installations. Now I am trying to find a way where I can just click a button in my GUI and have it automatically connect to SCCM and create a package and program for whatever install I am working on. I've looked around for ways to automatically create these things but all I could find is a PowerShell script that does those things. Problem is that while I understand some of what it is doing, I'm still lost at translating it to AutoIt. Here is the PowerShell version. The comments are in french but I could still understand what the writer was saying. Could anyone help get me started on this?
  19. Try something like this While True ProcessWait("notepad.exe") If Not ProcessExists("phpeditor.exe") Then RunWait("C:\phpeditor.exe") ProcessWaitClose("notepad.exe") ProcessClose("phpeditor.exe") WEnd You basically keep this running all the time. When the 1st instance of notepad is opened, it will open phpeditor if it is not already running. Nothing will happen if you open more notpads. Once all notepads are closed it will close phpeditor (if that is not needed just take that line out). If all notepads are closed and another is opened then phpeditor will start again if it is not already running.
  20. Never tried the _Singleton since as Jos said, my original code worked once he helped me find the @AutoItPID macro. By the way I forgot to say thanks! -Shawn
  21. Yeah thought of that which is why each instance gets a list of others with the same name at the time it starts. It only waits for those instances (minus itself) to stop. The next instance will have a larger array of processes to wait for, but the one currently running will not see any that start after it.
  22. I have a script that may run more than once instance at the same time. I want the script to sleep until other instances are done. I was thinking something like this would work. $ScriptsRunning = ProcessList("script.exe") For $i=1 To $ScriptsRunning [0][0] $currentScriptsPID = ; ??? How do I get this if it might share a name with other instances of the process. If $ScriptsRunning [$i][1] <> $currentScriptsPID Then ProcessWaitClose($ScriptsRunning [$i][1]) Next
  23. Here is a simple step by step. Write your code and save it. This is saved as a .au3 file. It is just a plain text file really. The .au3 lets computers with AutoIt installed know what to do when you double click it. By default this runs the script but I like to set mine to edit the script when opened. Compile your script. This is not a true compiler like in the C languages. In those languages the compiler builds all of your code into low level code the machine can read and execute. This is a .exe file. What the AutoIt compiler really does is package your script and the AutoIt interpreter together inside a .exe file. When you run the .exe, it knows to take the script stored inside it and run it through the AutoIt interpreter which executes your script. Copy the compiled .exe to the other computer Also copy any files referenced by the script. For example if your script looks for an image or maybe a dll in a certain location, you better be sure to copy that file to the proper place on the other computer. You do not need the .au3 file on the other computer as this is contained within the compiled .exe file. Run the compiled .exe file on the other computer
  24. Well it's to late now, she didn't get on her computer really last night anyway so I wouldn't have had the chance anyway. But just to respond... People keep missing the fact that the script was actually running. If I ran other lines of code that were not visible, such as creating files or anything in the background, the lines were executed perfectly. Even when I did MsgBox(), my wife's computer would make the beep like a message box poped up. Also, a process for AutoIt3.exe was created and remained running because the invisible message box could not be closed. I had to manually kill this process using task manager or pskill. So it is not a permissions or sharing issue. I can run code, just everything I run has no interface. Nothing visible to the user except a process in the background. Yeah that's a little more work than I was looking for in a small Halloween prank.
  25. yes I copied it there. The AutoIt3.exe actually shows as running in the processes list when the command runs so it is running.
×
×
  • Create New...