-
Posts
10,526 -
Joined
-
Last visited
-
Days Won
89
Community Answers
-
JLogan3o13's post in WinClose versus ProcessClose was marked as the answer
I think you have answered your own question in the link. ProcessClose is an termination action; just like going into Task Manager and ending the process through the GUI. WinClose sends a close message to a window (similar to clicking the x). It is not so forceful as WinKill or ProcessClose, as you will be prompted if there is data to save. So, as to the "preferred" option, like most questions, it depends on what you're trying to accomplish.
-
JLogan3o13's post in set User Account Picture was marked as the answer
Well if they are non-domain, are the computers company-owned or BYOD? If company-owned, you're going to be limited to PSExec running as SYSTEM, and are going to run into issues connecting to them over the open internet. If BYOD, you're out of luck as you don't have permission to do anything on those devices.
-
JLogan3o13's post in Beginer to JavaScript was marked as the answer
I have had good experience with Pluralsight in the past for other languages. I have not done their javascript courses, but I see quite a bit of content out there. You get a 10-day free all-access pass to try it out:
https://www.pluralsight.com/browse?=&q=javascript&type=all&sort=default
-
JLogan3o13's post in _IECreate vs ShellExecute was marked as the answer
You have to understand the difference between the two functions to understand which you want to rely on. _IECreate is going to create a browser object, and will return that object to you. It gives you something "solid" to script against after it is created. Using ShellExecute, you are basically just running the external program. The most you get back I believe is the Process ID is available; you don't get an actual object for further use.
-
JLogan3o13's post in AND operator and work with if statement was marked as the answer
As MikahS pointed out, it is a bit irritating having to first guess at what you're doing, and then troubleshoot the problem. Workable, running code is always best. Try something like this and see if it works for you:
If $pwdinput is blank, fails. If $pwdinput does not equal $pwlabeled, fails.
If $pwdinput is not blank, and equals $pwlabeled, then if $namelist equals $bArray[1], succeeds.
#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> GUICreate("Test", 300, 300) $pwdinput = GUICtrlCreateInput("", 10, 10, 280, 40) $namelist = GUICtrlCreateInput("", 10, 60, 280, 40) $button = GUICtrlCreateButton("Go", 10, 120, 40, 40) $pwlabeled = 1 Local $bArray[2] = ["Sue","Henry"] GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $button If GUICtrlRead($pwdinput) <> "" And GUICtrlRead($pwdinput) <> $pwlabeled Then If GUICtrlRead($namelist) = $bArray[1] Then MsgBox(0, "", "Worked") Else MsgBox(0, "", "Failed") EndIf EndSwitch WEnd GUIDelete() -
JLogan3o13's post in Cpu at 50% was marked as the answer
Add a short sleep, like 100ms, to keep your While loop from being so CPU intensive.
-
JLogan3o13's post in Display Object Collection was marked as the answer
Usually with a collection, like a SQL or WMI query, I find I have to cycle through the collection and manually populate an array. For a list of printers though, I do this:
#include <Array.au3> Local $aPrinters[0] $sPC = @ComputerName $oWMI = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $sPC & "\root\cimv2") $colPrinters = $oWMI.ExecQuery("Select * from Win32_Printer") For $sPrinter In $colPrinters _ArrayAdd($aPrinters, $sPrinter.Name) Next _ArrayDisplay($aPrinters) -
JLogan3o13's post in Simple fast question... was marked as the answer
The help file states "Copies one or more files", and under the Related section, points you to DirCopy for folders. What, exactly, is confusing you?
-
JLogan3o13's post in Group/Radio button question was marked as the answer
What about something like this?
#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) $Main = GUICreate("Parameter Entry", 385, 135, 192, 114) $File = GUICtrlCreateMenu("&File") $ProcessFile = GUICtrlCreateMenuItem("Process by File"&@TAB&"Ctrl+F", $File) $SearchTypeLabel = GUICtrlCreateLabel("Search Type:", 4, 12, 85, 20) GUICtrlSetFont(-1, 11, 400, 0, "MS Sans Serif") $SearchTypeCombo = GUICtrlCreateCombo("", 93, 10, 153, 25) GUICtrlSetData(-1, "Person Name|ID search") $ParameterLabel = GUICtrlCreateLabel("Parameter:", 4, 41, 85, 20) GUICtrlSetFont(-1, 11, 400, 0, "MS Sans Serif") $ParameterInput = GUICtrlCreateInput("", 93, 39, 153, 21) $ModeGroup = GUICtrlCreateGroup("Mode", 280, 8, 97, 65) GUIStartGroup() $Radio = GUICtrlCreateRadio("1", 288, 24, 81, 17) GUICtrlSetOnEvent(-1, "setState") $Radio2 = GUICtrlCreateRadio("2", 288, 44, 81, 17) GUICtrlSetOnEvent(-1, "setState") $DODLabel = GUICtrlCreateLabel("Date", 10, 70, 85, 20) GUICtrlSetFont(-1, 11, 400, 0, "MS Sans Serif") $DODInput = GUICtrlCreateDate("", 123, 68, 123, 21,(0x00)) $Button1 = GUICtrlCreateButton("Submit", 296, 77, 75, 25) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) $cEnterDummy = GUICtrlCreateDummy() $cFileDummy = GUICtrlCreateDummy() Local $aAccelKeys[2][2] = [["{ENTER}", $cEnterDummy],["^f", $cFileDummy]] GUISetAccelerators($aAccelKeys) GUISetOnEvent($GUI_EVENT_CLOSE, "closeGUI") While 1 Sleep(100) WEnd Func setState() GUICtrlSetState($DODLabel, (GUICtrlRead($Radio) = 1) ? $GUI_SHOW : $GUI_HIDE) GUICtrlSetState($DODInput, (GUICtrlRead($Radio) = 1) ? $GUI_SHOW : $GUI_HIDE) EndFunc Func closeGUI() Exit EndFunc -
JLogan3o13's post in Read MSI data programatically with AutoIT was marked as the answer
Try something like this. It returns all properties, but you could easily have it check only for the ones you want:
$sMSI = FileOpenDialog("MSI Properties", @ScriptDir, "Windows Installer Files (*.msi)") $oInstaller = ObjCreate("WindowsInstaller.Installer") $oDB = $oInstaller.OpenDataBase($sMSI, 0) $oView = $oDB.OpenView("SELECT Property,Value FROM Property") $oView.Execute() $oCount = 0 While @error = 0 $oRecords = $oView.Fetch $oPropValue = $oRecords.StringData(2) $oPropName = $oRecords.StringData(1) If $oPropName <> "" Then $oCount += 1 ConsoleWrite($oPropName & " = " & $oPropValue & @CRLF) EndIf WEnd -
JLogan3o13's post in GUI Labels Export to Excel was marked as the answer
Something like this will write to the first empty row:
Func Upload() Local $oExcel = _Excel_Open() Local $oWorkbook = _Excel_BookOpen($oExcel, @DesktopDir & "\Test.xls") Local $oSheet = $oWorkbook.ActiveSheet $sMember = GUICtrlRead($TeamMemberValue) $aTemp = _Excel_RangeFind($oWorkbook, GUICtrlRead($TeamMember)) $sColumn = StringMid($aTemp[0][2], 2, 1) $oSheet = $oWorkbook.Worksheets(1) $oRange = $oSheet.UsedRange $oRange.SpecialCells($xlCellTypeLastCell).Activate $newRow = $oExcel.ActiveCell.Row + 1 _Excel_RangeWrite($oWorkbook, Default, $sMember, $sColumn & $newRow) EndFunc -
JLogan3o13's post in Capturing the error without halting script was marked as the answer
For the latest beta, try capturing the error yourself. Something like this:
Global $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") $sqlCon = ObjCreate("ADODB.Connection") $sqlCon.Open($connectionString) Func _ErrFunc() $CheckForLocal=MsgBox(4, "ERROR", "Failed to connect to the database") If $CheckForLocal='7' Then $trackLocal='Y' Else Exit EndIf EndFunc -
JLogan3o13's post in _ScreenCapture_CaptureWnd problem, it works in all functions except one was marked as the answer
Your path has no :
_ScreenCapture_CaptureWnd(@MyDocumentsDir & $date & "ÜKegyenleg.jpg", $Egyenleg) Should be more like
_ScreenCapture_CaptureWnd(@MyDocumentsDir & "\" & $date & "\ÜKegyenleg.jpg", $Egyenleg) -
JLogan3o13's post in String Trim or RegExp? was marked as the answer
If you want the numbers only (phone number, I'm assuming), and they're always in the same spot, try this:
$sString = "367-1111 random blah blah blah" ConsoleWrite(StringLeft($sString, 8) & @CRLF) -
JLogan3o13's post in Having an issue with using an environment variable in a UNC path... was marked as the answer
Common mistake, you have your variable inside your quotes. Try this:
Local $DomainController = EnvGet("LOGONSERVER") RunAs("User", "domain FQDN", "Password", 0, $DomainController & "\NETLOGON\BatchCommand.cmd") -
JLogan3o13's post in Getting Word from Title was marked as the answer
For the most part, yes you can. Given a window title of My Awesome Notepad Example.txt, you could do something like this:
$sTitle = WinGetTitle("[CLASS:Notepad]", "") ;get the full title $aSplit = StringSplit($sTitle, " ") ;split the title by spaces ConsoleWrite($aSplit[4] & @CRLF) ;get the fourth element If you're unable to get the class of the window, try using text inside the window (the second parameter in WinGetTitle).
-
JLogan3o13's post in method to use for array value when unknown size? was marked as the answer
If you're using StringSplit, the resultant array's [0] index will show you how many total elements there are.
Quick and dirty example:
$sDir = "c:\Users\Hades\Desktop\Test\Test1\Test2" Local $aArray = StringSplit($sDir, "\") $x = $aArray[0] ConsoleWrite($aArray[$x] & @CRLF) -
JLogan3o13's post in How to expand AutoIt macros in regwrite was marked as the answer
A couple of things. In your last post, you have quotes around @ScriptDir. I am assuming that is just a typo, as you did not have them before. So to clarify, this does not work?
RegWrite("HKEY_CURRENT_USER64\Software\Microsoft\Windows\CurrentVersion\RunOnce","Run(C:\Dnload\LoginAutoWindowsBack.exe)","REG_EXPAND_SZ", @ScriptDir & "\LoginAutoWindowsBack.exe") If that is the case, what about this?
$sPath = @ScriptDir & "\LoginAutoWindowsBack.exe" RegWrite("HKEY_CURRENT_USER64\Software\Microsoft\Windows\CurrentVersion\RunOnce","Run(C:\Dnload\LoginAutoWindowsBack.exe)","REG_EXPAND_SZ", $sPath) And...as we've all done it...your LoginAutoWindowsBack.exe is in the same directory as the script, right?
-
JLogan3o13's post in _FileListToArray was marked as the answer
Again, read the help file:
Local $List = _FileListToArray (@DesktopDir, "*", $FLTA_FOLDERS,False) _ArrayDelete($List, 0) _ArrayDisplay ($List) -
JLogan3o13's post in ControlSend throwing random Question Marks into Command Prompt was marked as the answer
You're asking if @ComSpec would be more reliable, I would suggest trying it and judging for yourself. Do something like this:
/k will keep the window open, whereas /c will close it immediately.
Run(@ComSpec & " /k <command>") -
JLogan3o13's post in Help with a Loop was marked as the answer
Hi, ardak2000. Try taking the WinWaitClose and the ContinueCase out, and see what that does for you. Also, put in a Debug option at the top of your script so you can see what line the script is hanging on:
Opt("TrayIconDebug", 1) -
JLogan3o13's post in ProcessList | Error : Subscript used on non-accessible variable. was marked as the answer
You initalize $PID to 0, then call the function passing the ProcessName, but never do anything more with $PID. Why wouldn't you get an error? Try this to see why it is failing:
Func _getPID($ProcessName) Local $i = 0 Local $PID = 0 While ( $i + 1 <= ProcessList($ProcessName)[0][0] ) If Not IsArray($PID) Then MsgBox(0, "", "$PID is NOT an array so $PID[$i] will FAIL. $PID = " & $PID) Exit EndIf $PID[$i] = ProcessList($ProcessName)[$i+1][1] ; probably this one. $i = $i + 1 WEnd Return ($PID) EndFunc _getPID("explorer.exe") -
JLogan3o13's post in Automatically Add QAT Items was marked as the answer
What version of Office? In 2007 I know you had to copy the actual file (<User Profile>AppDataLocalMicrosoftOffice*.qat).
But in 2010 and above you should be able to export:
File>>Options>>Customize Ribbon or Quick Access Toolbar Create Customizations then Export Import the *.exportedUI file on another PC -
JLogan3o13's post in Locking Computer was marked as the answer
ShellExecute("rundll32.exe", 'user32.dll,LockWorkStation') -
JLogan3o13's post in Problem with Func... EndFunc usage with Send("{ALTDOWN}{TAB}{ALTUP}") was marked as the answer
Rather than resorting to Send, I would do something like this:
$sTitle = WinGetTitle("[ACTIVE]") ;Get title of active window before switching Func ActivateWindow2() If WinExists("AutoIt Forums -", "") Then WinActivate("AutoIt Forums -", "") WinWaitActive("AutoIt Forums -","") EndFunc Func SwitchBackToPrevious() If WinExists($sTitle, "") Then WinActivate($sTitle, "") WinWaitActive($sTitle,"") EndFunc