Jump to content

Search the Community

Showing results for tags 'windows'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

  1. Automate the change of the (current) user account picture was a script that I was missing, but I was sure to find an easy command line, like a simple powershell. It was not the case, I found only methods to change it in Active Directory environments, and my goal was to change the account picture also in freshly installed win 10/11 non domain OSes, and it works also in domain machines. The focus is to take care of every aspect of the process. The code: #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=Icone\angryRabbit.ico #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ;UAP ;User Account Picture ;()NSC 2023 ;notes ; only way to access 64-bit node in a 32-bit compiled script is using HKLM64 ;Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AccountPicture\Users ;main inspiration ;https://social.msdn.microsoft.com/Forums/sqlserver/en-US/3f50b25a-4c47-4bc8-959e-1108419288a7/how-to-set-specific-users-account-picture-from-cmd?forum=scripting ;PSexec to use as System '-s' switch ;https://learn.microsoft.com/it-it/sysinternals/downloads/psexec ;image processing ;https://imagemagick.org/index.php ;https://imagemagick.org/script/command-line-processing.php ;needed VCredist ;https://learn.microsoft.com/it-it/cpp/windows/latest-supported-vc-redist?view=msvc-170 ;https://aka.ms/vs/17/release/vc_redist.x64.exe ;permissions SETACL ;https://helgeklein.com/setacl/ ;https://www.autoitscript.com/forum/topic/162656-change-registry-key-permissions/?do=findComment&comment=1182956 ;interesting but not used (AD related) ;https://woshub.com/how-to-set-windows-user-account-picture-from-active-directory/ #RequireAdmin #include <Security.au3> #include <Array.au3> #include <File.au3> #include <String.au3> #include <_Gollog.au3> $mygui = "UAP - NSC 2023" gollog_ini($mygui, 600, 300, 200, 200, "0x050980", "0xf2dcc3", "consolas") ;f2dcc3 Global $tempfolder = "c:\temp", $ver = "V.1.0" Global $onlyexe4conversion = "magick.exe", $exe4conversion = $tempfolder & "\" & $onlyexe4conversion Global $onlyexe4regperm = "setacl.exe", $exe4regperm = $tempfolder & "\" & $onlyexe4regperm Global $onlyexe4PsExec = "psexec64.exe", $exe4PsExec = $tempfolder & "\" & $onlyexe4PsExec Global $vcredist = $tempfolder & "\" & "VC_redist.x64.exe" Global $registrypath = "hklm64\SOFTWARE\Microsoft\Windows\CurrentVersion\AccountPicture\Users\" Global $registrypath4SETACL = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\AccountPicture\Users\" Global $aSizes[11] = ["32x32", "40x40", "48x48", "64x64", "96x96", "192x192", "208x208", "240x240", "424x424", "448x448", "1080x1080"] Gollog("START UAP " & $ver) Global $sConsoleUser = _GetConsoleUser() Gollog("Console User: " & $sConsoleUser & @CRLF) Global $aUserProfile = _GetProfile($sConsoleUser) Gollog("Console User Path: " & $aUserProfile[1][1] & @CRLF) Global $folder4accountPictures = $aUserProfile[1][1] & "\" & "UAP" ;_ArrayDisplay($aUserProfile, "current USER") Global $aexpprof = _StringExplode($aUserProfile[1][2], "\") Global $CUreg = $aexpprof[UBound($aexpprof) - 1] Gollog("current user SID: " & $CUreg & @CRLF) ;TEST all users Gollog("enumerating all users:") Global $allUserProfiles = _GetProfile() For $i = 1 To UBound($allUserProfiles) - 1 Gollog($allUserProfiles[$i][0] & " " & $allUserProfiles[$i][2]) Next ;_ArrayDisplay($allUserProfiles, "all USERS") createFolder4userPictures() TempCreate() SetRegPermissions() VcRedist() GenPicS() Gollog("END UAP") Func GenPicS() ;image prepare Gollog("picking image for avatar") Local $sourceimg = FileOpenDialog("Select Image for your User Profile", @UserProfileDir & "\" & "downloads", "Images (*.png;*.jpg;*.jpeg;*.gif;*.bmp)", 1) Local $sDrive = "", $sDir = "", $sFileName = "", $sExtension = "" Local $aPathSplit = _PathSplit($sourceimg, $sDrive, $sDir, $sFileName, $sExtension) ;registry prepare If RegDelete($registrypath & $CUreg) Then Gollog("regdelete ok " & @CRLF) Gollog($registrypath & $CUreg & @CRLF) Else Gollog("regdelete error " & @error & @CRLF) Gollog($registrypath & $CUreg & @CRLF) EndIf If RegWrite($registrypath & $CUreg) Then Gollog("regwrite root ok " & @CRLF) Else Gollog("regwrite root error " & @error & @CRLF) EndIf For $i = 0 To UBound($aSizes) - 1 ;image conversion ShellExecuteWait($exe4conversion, $sourceimg & " -resize " & $aSizes[$i] & " " & $folder4accountPictures & "\" & $sFileName & "_" & $aSizes[$i] & $sExtension) ;registry write Local $apartsize = _StringExplode($aSizes[$i], "x") If RegWrite($registrypath & $CUreg, "Image" & $apartsize[0], "REG_SZ", $folder4accountPictures & "\" & $sFileName & "_" & $aSizes[$i] & $sExtension) Then Gollog("regewrite image ok " & $aSizes[$i] & @CRLF) Gollog($registrypath & $CUreg & " Image" & $apartsize[0] & " REG_SZ " & $folder4accountPictures & "\" & $sFileName & "_" & $aSizes[$i] & $sExtension) Else Gollog("regwrite image error " & @error & @CRLF) Gollog($registrypath & $CUreg & " Image" & $apartsize[0] & " REG_SZ " & $folder4accountPictures & "\" & $sFileName & "_" & $aSizes[$i] & $sExtension) EndIf Next EndFunc ;==>GenPicS Func VcRedist() Gollog("installing Microsoft Visual C++ Redistributable ") ShellExecuteWait($vcredist, "/install /passive /norestart") EndFunc ;==>VcRedist Func SetRegPermissions() Gollog("creating file to set registry permissions") ;writing bat file Local $batfile = $tempfolder & "\" & "UAPsetacl.bat" If FileExists($batfile) Then FileDelete($batfile) gollog("deleted old " & $batfile) EndIf Local $hFileOpen = FileOpen($batfile, $FO_APPEND) If $hFileOpen = -1 Then MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst writing the UAPsetacl.bat file", 3) GOLLOG("An error occurred whilst writing the UAPsetacl.bat file") Exit EndIf FileWriteLine($hFileOpen, 'c:\temp\setacl.exe -on "' & $registrypath4SETACL & $CUreg & '" -ot reg -actn ace -ace "n:Administrators;p:full"') FileClose($hFileOpen) Gollog("set registry permissions") ;launch permission set on registry ShellExecuteWait($exe4PsExec, " -s -accepteula " & $batfile) EndFunc ;==>SetRegPermissions Func TempCreate() Gollog("deploying necessary temp files") If Not FileExists($tempfolder) Then DirCreate($tempfolder) FileInstall("C:\nsc_TEST\resources\imagemagick\magick.exe", $exe4conversion, 1) FileInstall("C:\nsc_TEST\resources\SetACL\64 bit\setacl.exe", $exe4regperm, 1) FileInstall("C:\NSC_test\resources\PSExec\PsExec64.exe", $exe4PsExec, 1) FileInstall("C:\nsc_TEST\resources\VCredist\VC_redist.x64.exe", $vcredist, 1) EndFunc ;==>TempCreate ;Create folder for user pictures - cleaning pre existing Func createFolder4userPictures() Gollog("creating folder for new avatar pictures") If FileExists($folder4accountPictures & "\") Then DirRemove($folder4accountPictures, 1) EndIf DirCreate($folder4accountPictures) EndFunc ;==>createFolder4userPictures ;Use WMI query to get user logged onto console Func _GetConsoleUser() Local $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!//.") Local $colUsers, $objUser Local $strAccount $colUsers = $objWMIService.InstancesOf("Win32_ComputerSystem") For $objUser In $colUsers $strAccount = $objUser.UserName Next If $strAccount <> "" Then Return $strAccount Else Return (1) EndIf EndFunc ;==>_GetConsoleUser ; #FUNCTION# ==================================================================================================================================== ; Name...........: _GetProfile ; Description ...: Determine each user's Profile folder, the user's SID and if the profile is loaded to the registry ; Syntax.........: _GetProfile([$sAccount, $sComputer]) ; Parameters ....: $sAccount - User account name, defaults to all users ; $sComputer - Computer name, the local computer is default ; Requirement(s).: Service 'RemoteRegistry' running on the target computer ; When the target computer is the local computer, the 'RemoteRegistry' service isn't required ; Return values .: An array containing the path to each user's profile folder, the user's SID ; The array returned is two-dimensional and is made up as follows: ; $array[0][0] = Number of profiles ; $array[1][0] = 1st user name ; $array[1][1] = Path to 1st user profile ; $array[1][2] = 1st user registry hive ; $array[1][3] = 1 if 1st user profile is loaded to the registry, 0 if not ; $array[2][0] = 2nd user name ; $array[2][1] = Path to 2nd user profile ; $array[2][2] = 2nd user registry hive ; $array[2][3] = 1 if 2nd user profile is loaded to the registry, 0 if not ; ... ; $array[n][0] = nth user name ; $array[n][1] = Path to nth user profile ; $array[n][2] = nth user registry hive ; $array[n][3] = 1 if nth user profile is loaded to the registry, 0 if not ; Author ........: engine ; Modified.......: AdamUL ; Remarks .......: ; Related .......: ; Link ..........; ; Example .......; _GetProfile("Default User") to get Default User's profile data on the local computer ; =============================================================================================================================================== Func _GetProfile($sAccount = "", $sComputer = @ComputerName) Local $avArray[1][4], $sDefaultUser, $sEnv Local Const $sProfileListKey = "\\" & $sComputer & "\HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList" Local Const $sRootKey = "\\" & $sComputer & "\HKEY_USERS\" Local Const $sDefaultUser1 = RegRead($sProfileListKey, "DefaultUserProfile") Local Const $iDefaultUser1Error = @error Local Const $sDefaultUser2 = RegRead($sProfileListKey, "Default") Local Const $iDefaultUser2Error = @error If $iDefaultUser1Error And $iDefaultUser2Error Then $avArray[0][0] = 0 Return $avArray EndIf If $iDefaultUser1Error Then $sDefaultUser = "Default" Else $sDefaultUser = $sDefaultUser1 EndIf If $sAccount = "" Or $sAccount = $sDefaultUser Then Local $iInstance, $sSID While 1 $iInstance += 1 $sSID = RegEnumKey($sProfileListKey, $iInstance) If @error Then ExitLoop If StringLen($sSID) > 8 Then ProfileAdd($avArray, $sSID, $sProfileListKey, $sRootKey) WEnd Local $u = UBound($avArray), $iSum For $k = 1 To $u - 1 $iSum += $avArray[$k][3] Next ReDim $avArray[$u + 1][4] $avArray[$u][0] = $sDefaultUser $avArray[$u][1] = RegRead($sProfileListKey, "ProfilesDirectory") & "\" & $sDefaultUser If $iSum = 0 Then $avArray[$u][2] = "\\" & $sComputer & "\HKEY_CURRENT_USER" $avArray[$u][3] = 1 Else Local $avDomain, $iN = 998, $sDSID, $avDU $avDomain = _Security__LookupAccountName($sComputer, $sComputer) Do $iN += 1 $sDSID = $avDomain[0] & "-" & $iN $avDU = _Security__LookupAccountSid($sDSID, $sComputer) Until $avDU = 0 $avArray[$u][2] = $sRootKey & $sDSID $avArray[$u][3] = 0 EndIf If $sAccount = $sDefaultUser Then Local $avNew[2][4] = [["", "", "", ""], [$avArray[$u][0], $avArray[$u][1], $avArray[$u][2], $avArray[$u][3]]] $avArray = $avNew EndIf Else Local $avSID = _Security__LookupAccountName($sAccount, $sComputer) If $avSID = 0 Then $avArray[0][0] = 0 Return $avArray Else ProfileAdd($avArray, $avSID[0], $sProfileListKey, $sRootKey) EndIf EndIf $avArray[0][0] = UBound($avArray) - 1 For $j = 1 To $avArray[0][0] $sEnv = StringRegExp($avArray[$j][1], "\x25\S{1,128}\x25", 1) If Not @error Then $avArray[$j][1] = StringReplace($avArray[$j][1], $sEnv[0], EnvGet(StringReplace($sEnv[0], "%", ""))) Next Return $avArray EndFunc ;==>_GetProfile ; #INTERNAL_USE_ONLY#============================================================================================================================ ; Name...........: ProfileAdd ; Description ...: Add profile data to an array that will be returned by _GetProfile function ; Syntax.........: ProfileAdd($avArray, $sSID, $sProfileListKey, $sRootKey) ; Parameters ....: $avArray - Array ; $sSID - Account SID ; $sProfileListKey - Constant defined inside _GetProfile function ; $sRootKey - Constant defined inside _GetProfile function ; Requirement(s).: ; Return values .: ; Author ........: engine ; Modified.......: AdamUL ; Remarks .......: For internal use only ; Related .......: ; Link ..........; ; Example .......; ; =============================================================================================================================================== Func ProfileAdd(ByRef $avArray, $sSID, Const $sProfileListKey, Const $sRootKey) Local $sPath, $i Local $asSplit = Split_sKey("\" & $sProfileListKey) Local $avUser = _Security__LookupAccountSid($sSID, $asSplit[0]) If Not @error And $avUser <> 0 Then If $avUser[2] = 1 Then $sPath = RegRead($sProfileListKey & "\" & $sSID, "ProfileImagePath") If Not @error Then $i = UBound($avArray) ReDim $avArray[$i + 1][4] $avArray[$i][0] = $avUser[0] $avArray[$i][1] = $sPath $avArray[$i][2] = $sRootKey & $sSID RegEnumKey($sRootKey & $sSID, 1) If @error Then $avArray[$i][3] = 0 Else $avArray[$i][3] = 1 EndIf EndIf EndIf EndIf EndFunc ;==>ProfileAdd ; #INTERNAL_USE_ONLY#============================================================================================================================ ; Name...........: Split_sKey ; Description ...: Splits $sKey between computername, username and keyname ; Syntax.........: Split_sKey($sKey) ; Parameters ....: $sKey - Reg function main key ; Requirement(s).: ; Return values .: ; Author ........: engine ; Modified.......: ; Remarks .......: For internal use only ; Related .......: ; Link ..........; ; Example .......; ; =============================================================================================================================================== Func Split_sKey($sKey) Local $asArray[3] If StringInStr($sKey, "\\\") = 1 Then Local $asComputer = StringRegExp($sKey, "\\\\\\[^\\]*\\", 1) If Not @error Then $asArray[0] = StringTrimRight(StringTrimLeft($asComputer[0], 3), 1) $sKey = StringReplace($sKey, $asComputer[0], "\", 1) If Not StringInStr($sKey, "\\") = 1 Then $sKey = StringTrimLeft($sKey, 1) EndIf EndIf If $asArray[0] = "" Then $asArray[0] = @ComputerName If StringInStr($sKey, "\\") = 1 And Not StringInStr($sKey, "\\\") = 1 Then Local $asUser = StringRegExp($sKey, "\\\\[^\\]*\\", 1) If Not @error Then $asArray[1] = StringTrimRight(StringTrimLeft($asUser[0], 2), 1) $sKey = StringReplace($sKey, $asUser[0], "", 1) EndIf EndIf If Not (StringInStr($sKey, "\") = 1 Or StringInStr($sKey, "\", 0, -1) = StringLen($sKey) Or StringInStr($sKey, "\\")) Then $asArray[2] = $sKey EndIf Return $asArray EndFunc ;==>Split_sKey 3+1 external executables are needed, look at notes at the top of che code. The _gollog udf is here. The abstract is this : it determines the current user SID it gives control to the admin user to the right registry entries, because they are changeable only by "system" account") it creates the needed pictures and write down to the registry the correct keys. Research on these topics was made in this thread.
  2. Greetings! I was exploring as I saw the below URL which reads the event logs from specific type (Application, Security, System, etc.) So, I was in need to read a specific event id instead of the type of event, i.e. I need to read event id 1074 which lands under Security type. Any assistance will be grateful. Happy new year in advance!!
  3. Vaiola

    Robocopy

    We need to transfer from windows server 2012 to windows server 2016, we didn't find a way using to transfer the data automatically or to email us after tasks are finished. Is there a way to copy the data with NTFS/Shared permissions and timestamps without any loss?
  4. WiFi Disconnects Automatically Windows 10 / 8 / 7 Laptop. This video guide very help to me
  5. hello autoit team please i need your help today am trying to make the list of features in list view and control it am using the dism command line to read output i've made the code but i found some problems what i need is the list of features in 2d array $array[$n][0]= name $array[$i][1] = state when i tested the code it give me some results that i don't need to it e.g ------ ------ | -------- or name | state i need just the list of features and there state please help me to do that here is my example #RequireAdmin #NoTrayIcon #include <AutoItConstants.au3> Wow64EnableWow64FsRedirection(false) _Windows_Get_Features() func _Windows_Get_Features() local $a_FeaturesArray[1][2] $a_FeaturesArray[0][0] local $i_Dism_Run = Run("DISM /online /english /get-features /format:table", "", @sw_hide, BitOR($STDERR_CHILD, $STDOUT_CHILD)) local $s_OutputDism = "", $a_OutPutDism While 1 $s_OutputDism = StdoutRead($i_Dism_Run) If @error Then exitLoop if ($s_OutputDism = "") or (StringRegExp($s_OutputDism, "^((\-){1,})?(?:\s)\|?(?:\s)((\-){1,})$", 0) = 1) then ContinueLoop if (StringRegExp($s_OutputDism, "((([\s\d\-\+\_\,]{1})\|([\s\d\-\+\_\,]{1})){1,})", 0) = 1) then $a_OutPutDism = StringSplit($s_OutputDism, @lf) for $i = 1 to $a_OutPutDism[0] if msgBox(1, $i, $a_OutPutDism[$i]) = 1 then exitLoop next endIf Wend endFunc func Wow64EnableWow64FsRedirection($b_Enabled) local $h_OpenFS = DLLOpen("kernel32.dll") local $Return = DllCall($h_OpenFS, "boolean", "Wow64EnableWow64FsRedirection", "boolean", $b_Enabled) if @error then DLLClose($h_OpenFS) Return SetError(@error, @extended, -1) else DLLClose($h_OpenFS) Return $Return[0] endIf endFunc
  6. question about _WinAPI_CreateWindowEx good morning welcome autoit team please i need your help i've searched a lot about how to use the _WinAPI_CreateWindowEx finally i found an example but i found some problem i hope you can help me firstly, i want to set the controls focussable with the keyboard input i already used the ws_tabStop but it did not work with me. secondly, i want to set some access keys linked with the window such as control+o enable the open button and control+f4 exit the app note: i need a local access keys and not a global hotkeys such as GUISetAccelerators finaly, before i will put the code here i must clarify a few things. 1. you will ask me why you don't use the GUICreate function here i'll tell you that it as dialog and It is a little heavy in motion with screen readers. the screen readers for blind has some function that work with dialogs and others work with full windows style 2. you will ask me why you didn't search the net for that? i will tell you that all examples that i found in the internet with pdfs and Picture books. i found some examples in microsoft but it with cpp. ok here is the code i hope you can help me to do what i want thank you in advance ; Small AutoIt Application that uses Windows API ; Written by Yuraj #NoTrayIcon #include <_RegisterClassEx.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <FontConstants.au3> AutoItSetOption("MustDeclareVars", 1) ; Window definitions Const $WinWidth = 370 Const $WinHeight = 350 Const $WinXPos = (@DesktopWidth / 2) - ($WinWidth / 2) Const $WinYPos = (@DesktopHeight / 2) - ($WinHeight / 2) Const $WinTitle = "Win32 Application - Text reader" Const $WinClass = "mainapp" Const $WinIcon = _WinAPI_LoadIcon(_WinAPI_GetModuleHandle("shell32.dll"), 13) ; Windows handles Global $hwnd, $edit1, $btn1, $btn2 ; Fonts Global $fnt1 ; Register class, Create the window Local $retVal = __WinAPI_RegisterClassEx($WinClass, "WindowCallback", $WinIcon, 0, _WinAPI_GetSysColor($COLOR_BTNFACE), BitOR($CS_DEFAULTSTYLE, $CS_DROPSHADOW)) ; If $retVal == 0 Then ; If registerclass fails MsgBox(16, "Error", "Error while registering window class!") Exit EndIf ; Create windows/controls $hwnd = _WinAPI_CreateWindowEx($WS_EX_STATICEDGE, $WinClass, $WinTitle, BitOR($WS_OVERLAPPED,$WS_SYSMENU, $WS_MINIMIZEBOX, $WS_GROUP, $WS_DLGFRAME), $WinXPos, $WinYPos, $WinWidth, $WinHeight, 0) $btn1 = _WinAPI_CreateWindowEx(0, "button", "Open file ...", BitOR($WS_VISIBLE, $WS_CHILD, $WS_TABSTOP, $WS_CLIPCHILDREN), 25, 270, 100, 30,$hwnd) $btn2 = _WinAPI_CreateWindowEx(0, "Button", "Exit", BitOR($WS_VISIBLE, $WS_CHILD, $WS_TABSTOP, $WS_CLIPCHILDREN), 235, 270, 100, 30, $hwnd) $edit1 = _WinAPI_CreateWindowEx(0, "edit", "text", BitOR($WS_VISIBLE, $WS_CHILD, $WS_VSCROLL, $ES_AUTOVSCROLL, $es_readOnly, $WS_TABSTOP), 5, 5, $WinWidth - 15, $WinHeight - 100, $hwnd) ; Set controls identifiers _WinAPI_SetWindowLong($btn1,$GWL_ID,150) _WinAPI_SetWindowLong($btn2,$GWL_ID,160) ; Set (controls) fonts $fnt1 = _CreateFont("MS Sans Serif", 15) _WinAPI_SetFont($btn1, $fnt1) _WinAPI_SetFont($btn2, $fnt1) _WinAPI_SetFont($edit1, $fnt1) ; Set focus to edit _WinAPI_SetFocus($edit1) ; Show window _WinAPI_ShowWindow($hwnd) _WinAPI_UpdateWindow($hwnd) ; Main loop that keep application opened While 1 Sleep(100) WEnd ;=================================================================; ; WINDOW CALLBACK ... ;=================================================================; Func WindowCallback($_hwnd, $iMsg, $wParam, $lParam) Local $iNC, $iID Switch $iMsg ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Case $WM_CLOSE ; Show message on closing If MsgBox(48 + 4, $WinTitle, "Do you want really exit?", 0, $hwnd) <> 6 Then Return 0 ; Call destructor and then exit main thread FinalizeApp() Exit ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Case $WM_COMMAND $iNC = _WinAPI_HiWord($wParam) $iID = _WinAPI_LoWord($lParam) Switch $iNC Case $BN_CLICKED ; When is control clicked Switch _WinAPI_GetDlgCtrlID($iID) Case _WinAPI_GetDlgCtrlID($btn1) BtnOpenFileClick() Case _WinAPI_GetDlgCtrlID($btn2) BtnExitClick() EndSwitch EndSwitch ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; EndSwitch Return _WinAPI_DefWindowProc($_hwnd, $iMsg, $wParam, $lParam) EndFunc ;==>WindowCallback Func FinalizeApp() _WinAPI_DeleteObject($fnt1) _WinAPI_DestroyWindow($hwnd) __WinAPI_UnregisterClass($WinClass) EndFunc ;==>FinalizeApp Func _CreateFont($fontName, $height = 16, $style = $FW_NORMAL, $italic = False, $underline = False, $strikeout = False) Local $hFont = _WinAPI_CreateFont($height, 0, 0, 0, $style, $italic, $underline, $strikeout, $DEFAULT_CHARSET, _ $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, $DEFAULT_PITCH, $fontName) Return $hFont EndFunc ;==>_CreateFont ;=================================================================; ; WINDOW EVENTS ;=================================================================; Func BtnOpenFileClick() Local $ret = _WinAPI_GetOpenFileName("", "Text files (*.txt)|All files (*.*)", ".", "", "", 1, 0, 0, $hwnd) If ($ret[0] > 0) Then Local $path = $ret[1] & "\" & $ret[2] Local $file = _WinAPI_CreateFile($path, 2, 2) Local $buf = DllStructCreate("byte[" & _WinAPI_GetFileSizeEx($file) & "]") Local $i = 0 _WinAPI_ReadFile($file, DllStructGetPtr($buf), _WinAPI_GetFileSizeEx($file), $i) ; Close file handle _WinAPI_CloseHandle($file) _WinAPI_SetWindowText($edit1, BinaryToString(DllStructGetData($buf, 1))) EndIf EndFunc ;==>BtnOpenFileClick Func BtnExitClick() FinalizeApp() Exit EndFunc ;==>BtnExitClick _RegisterClassEx.au3
  7. Hi everyone, i just need your help. i have script for cleaning browsing history and other unwanted file but the problem is i don't want to see the GUI i have attached below. It should not show anything on the screen. is it possible to do it in autoit. thanks in advance. So for i have tried flag Run("rundll32.exe InetCpl.cpl,ClearMyTracksByProcess 255", "", @SW_HIDE) @SW_DISABLE Looking forward your help.........
  8. Hi Guys, I've noticed that the SoundGetWaveVolume UDF in an older topic isn't working on Windows Vista, 7, 8, 8.1 and 10. It's probably a Windows XP UDF. The UDF below does work. It successfully returns the volume set by SoundSetWaveVolume. It might need checking by the AutoIt community for some synthax finetuning. ; #FUNCTION# ==================================================================================================================== ; Name...........: _SoundGetWaveVolume ; Description....: Returns app volume of script, Windows Vista, 7, 8, 10 only ; Syntax.........: _SoundGetWaveVolume([$iValueOnError = -1]) ; Parameters.....: $iValueOnError - Value to return when an error occurs ; Return values..: App volume of script or $iValueOnError at an error ; Error values...: @error = 1 - Unable to create Struct ; @error = 2 - Dll file not found ; @error = 3 - Wrong call so not on Windows Vista, 7, 8 or 10 ; @error = 4 - Internal error, array not returned ; @error = 5 - Volume wasn't received ; @error = 6 - Volume couldn't read ; Author.........: Peter Verbeek ; Modified.......: ; =============================================================================================================================== Func _SoundGetWaveVolume($iValueOnError = -1) Local $LPDWORD,$aMMRESULT,$iVolume $LPDWORD = DllStructCreate("dword") If @error <> 0 Then SetError(1) ; 1 = unable to create Struct Return $iValueOnError EndIf ; get app volume of this script $aMMRESULT = DllCall("winmm.dll","uint","waveOutGetVolume","ptr",0,"long_ptr",DllStructGetPtr($LPDWORD)) Switch @error Case 1 SetError(2) ; 2 = dll file not found Return $iValueOnError Case 2,3,4,5 SetError(3) ; 3 = wrong call so not on Windows Vista, 7, 8 or 10 Return $iValueOnError EndSwitch If not IsArray($aMMRESULT) Then SetError(4) ; 4 = internal error, array not returned Return $iValueOnError EndIf If $aMMRESULT[0] <> 0 Then SetError(5) ; 5 = volume wasn't received Return $iValueOnError EndIf $iVolume = DllStructGetData($LPDWORD,1) If @error <> 0 Then SetError(6) ; 6 = volume couldn't read Return $iValueOnError EndIf Return Round(100*$iVolume/4294967295) ; return in range 0 to 100 as SoundSetWaveVolume() EndFunc
  9. Recently, I am interested to build a windows app to reset Windows login password as a side off project. I am still a newbie in programming so i am not able to build the app from scratch. Is there any open source project i could learn from on this?
  10. Hi, Does anyone knows why this command doesn't work? Run(@ComSpec & " /c " & "devcon.exe hwids * | findstr /R ""1050&PID_0114&REV_0340&MI_01"" || (rundll32.exe user32.dll, LockWorkStation)", "", "") This is the command in commandline: devcon.exe hwids * | findstr /R "1050&PID_0114&REV_0340&MI_01" && (echo USB Device is connected) || (rundll32.exe user32.dll, LockWorkStation) This works, but i want to convert this to AutoIT, but it doesn't work. In short what i am trying to accomplish is that a script checks every 1 sec. if there is an USB device plugged in and if not ( so it is removed ) it will lock Windows OS. Can someone help me with this?
  11. How do i pass the IE handle to an active windows authentication prompt when the IE shows it is " waiting " , right now it is nt detecting the windows security prompt I used the below to wait for it to load until the 60ms timeout but still it isnt working : #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile=ps_test.exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <Constants.au3> #include <IE_v1.au3> If $CmdLine[0] < 2 Then MsgBox($MB_OK, "Usage", "ps_WAN <username> <password>") Else wan($CmdLine[1], $CmdLine[2]) EndIf Func wan($email, $password) $oIE = _IECreate() $ieo=_IENavigate($oIE, "https://cccc") _IELoadWait($ieo,0,60) Local $hWnd = WinExists("Windows Security") if $hWnd = 0 Then MsgBox($MB_OK, "Usage", "timeout") EndIf ControlFocus("Windows Security", "", "[CLASS:DirectUIHWND]") ControlFocus("Windows Security", "", "[CLASS:Edit; INSTANCE:1]")
  12. I have read the help files, and tried the example, but nothing is happening, I see some code 0,0,0,0 and changed settings, but the window does nothing. How can I change the parameters for window size and position, where in the code and how? #include <MsgBoxConstants.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Example() Func Example() ; Assign a Local variable the handle of the NotePad window Local $hWnd = WinGetHandle("[CLASS:Notepad]") ; If the window does not exists, display a message and return False. If @error Then MsgBox($MB_SYSTEMMODAL, "", "Notepad window not found.") Return False EndIf ; Assign a Local variable the style of the Notepad window. Local $iStyle = _WinAPI_GetWindowLong($hWnd, $GWL_STYLE) ; Remove from the window style the MAXIMIZEBOX, MINIMIZEBOX and SIZEBOX styles. $iStyle = BitXOR($iStyle, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SIZEBOX) ; Set the style of the window. _WinAPI_SetWindowLong($hWnd, $GWL_STYLE, $iStyle) ; Apply the style _WinAPI_SetWindowPos($hWnd, $HWND_TOP, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE)) EndFunc ;==>ExampleThanks
  13. Hello, I'm working on a script that writes detailed application event logs, and I'd like to know if there is a way with Autoit to write multiple lines of XML EventData (see example below): <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event"> <System> <Provider Name="Application" /> <EventID Qualifiers="0">1001</EventID> <Level>4</Level> <Task>0</Task> <Keywords>0x80000000000000</Keywords> <TimeCreated SystemTime="2015-07-12T21:26:07.000000000Z" /> <EventRecordID>86554</EventRecordID> <Channel>Application</Channel> <Computer>YOUR_COMPUTER</Computer> <Security /> </System> <EventData> <Data>DeskTop Agent: Mike</Data> <Data>Observer Username: Miguel</Data> etc... </EventData> </Event> So far, using EventCreate, everything I send end's up in a single <data> entry (see below): <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event"> <System> <Provider Name="Application" /> <EventID Qualifiers="0">1001</EventID> <Level>4</Level> <Task>0</Task> <Keywords>0x80000000000000</Keywords> <TimeCreated SystemTime="2015-07-12T21:26:07.000000000Z" /> <EventRecordID>86554</EventRecordID> <Channel>Application</Channel> <Computer>YOUR_COMPUTER</Computer> <Security /> </System> <EventData> <Data>DeskTop Agent: Mike Observer Username: Miguel</Data> </EventData> </Event> Here is the code I'm using thus far (which does not work the way I'd like): $LogData = @CRLF & "DeskTop Agent: " & @UserName & @CRLF & "Observer Username: " & $DTObserver & @CRLF & "File name/s with extension: " & $FilenameWextension & @CRLF & "Action Performed: " & $ActionPerformed & @CRLF & "Explanation: " & $Explanation & @CRLF & "Machine Name: " & @ComputerName & @CRLF & "IP Address: " & @IPAddress1 & @CRLF & "App1Installed: " & $App1 & @CRLF & "App2Installed: " & $App2 Run("eventcreate /T Information /ID 100 /L Application /SO DTALog /D " & Chr(34) & "DTALog Details: " & $LogData & Chr(34), "", @SW_HIDE, 2) I found a Stackoverflow post that talks about doing it in C# (https://stackoverflow.com/questions/7694276/how-to-add-multiple-lines-of-eventdata-to-an-eventlog-in-windows) but I'd like to determine if it can be accomplished with AutoIt!. Thanks for your time, -Mike
  14. Hi, I'm currently saving process time stamps of my employer's other employees and saving it in a text document as data storage. However, my employer wants it to be processed in a day to day basis to generate their average process time per day. How can I compare today from yesterday and so on and so forth with the succeeding days? Whats the best approach to this? Thank you. ~XN~
  15. Folks, I have an issue I've been trying to solve for a while, I'm trying to add static routes in DHCP via a 121 route rule in Windows 2012 R2 is a brutal manual process and wanted to automate this via AutoIT. When I use the "ControlGetText" everything displays properly in the MSG box but when I try and use "ControlSetText" or "ControlSend" the values won't display in the input box but the action comes back as successful? Anyone able to help me with this? I'm thinking this might be an active window issue but i'm not sure. Here is a part of my code. $hWnd = WinWait("[TITLE:Add a Static Route]","", 10) WinActivate($hWnd) $Status = ControlSend($hWnd, "", "[CLASS:Edit; INSTANCE:4]", "192"); Does not add 192 to the text box. Local $sTextEdit1 = ControlGetText($hWnd, "", "[CLASS:Edit; INSTANCE:1]") ConsoleWrite ( "ControlSend Status: " & $Status & @CRLF); Returns a Value of 1 ConsoleWrite ( "ControlGetText Value Edit1: " & $sTextEdit1 & @CRLF); Please see attachment for more info.
  16. i am working on a application where if the flashing is success i get a window saying "SUCCESS" and if the flashing failed a window saying "FAILED" and i have to automatically identify pass or fail.the problem is both the windows are having the same control ID. how can i differentiate between both windows? so that i can make use of that in script for automation/// Thanks
  17. Hello! I created some scripts for a simple farming bot a few years ago and they rely on ControlSend. A year ago I quit that game and then installed Windows 10 (was using windows 7). Recently I installed that game and tried running them again and they seem to work (I have some messages displayed on the screen with the state of the bot ), except for the ControlSend part (which obviously is crucial). I started debugging the scripts so I created a basic script that makes use of Send. I tested this with Notepad in focus and works just fine and then with my game window in focus and it didn't work (it's supposed to write that text in an input box from the game). #include <MsgBoxConstants.au3> Sleep(3000); Send("some text"); MsgBox($MB_OK, "Notification", "Control was sent!"); Is there a way for the creators of the game to create some kind of security system against this? Or something happens because I updated to Windows 10? Is there something I'm missing? Thank you!
  18. Hi dear I have a question about the display language of the system How can I get the current display language and how can I change it by autoit Of course, if this is possible Greetings to all and hope you help me
  19. AutoIT AU3info doeas not detect all gui objects uniquely for .NET GUIs developed in C#. this is not working now i am using COM windows approach for this, But its very difficult. Please let me know if anyone has done it before.
  20. With _WinWaitActivate we can wait for a window to process it. But is there any logic so that we can wait for this window title and based on the window text (like 2 or more patterns will be there) we can click yes or no on the window. Func _WinWaitActivate($title,$text,$timeout=0) WinWait($title,$text,$timeout) If Not WinActive($title,$text) Then WinActivate($title,$text) WinWaitActive($title,$text,$timeout) EndFunc
  21. I am trying to spawn a cmd.exe shell on a remote machine using psexec then proceed to running commands on that machine and reading the output. I.e. running pwd. Unfortunately, the code I have now will just immediately exit cmd on the remote system I'm trying to use the current code #include <Constants.au3> $pid = Run('C:\Users\test\Desktop\psexec.exe \\192.168.1.123 -u test -p "P@$$word1" -h -s cmd',@SystemDir, @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD) StdinWrite($pid,"pwd") StdinWrite($pid,@CRLF) Local $data Sleep(2000) $data &= StdoutRead($pid) ConsoleWrite("Debug:" & $data & @LF) StdinWrite($pid,"cd ") StdinWrite($pid,"C:\users\test2") StdinWrite($pid,@CRLF) StdinWrite($pid) $data &= StdoutRead($pid) ConsoleWrite("Debug:" & $data & @LF) http://stackoverflow.com/questions/19206834/command-prompt-and-autoit-stdinwrite <- credits to this stack overflow post Unfortunately, on my end, my cmd just starts/stops with this prompt Connecting with PsExec service on 192.1.123...Starting cmd on 192.168.1.123... cmd exited on 192.168.1.123 with error code 0. Any ideas how I can keep my shell open over psexec and still interact with it using AutoIT? Any feed back would be amazing! Thanks!
  22. If I create a service to run a program , Application window cannot Appear - How can I make the App window visible
  23. Whenever we try to access a network share it will prompt for credentials based on the shared folder settings. Like the below prompt Once you save them, they are saved in Windows Credentials of Credentials Manager in Control panel (run --> control keymgr.dll). But not able to found exact file or registry for this setting. So, can anyone suggest how to do this process of adding network credentials using AutoIT.
  24. Basically, I want to unlock a user account by executing a script (while a user see's their locked screen, if this script is executed in the background, it unlocks their account without having to type in any password). In a perfect world, I would have a service running that can automatically log specific users in whether their account is locked or they just turned their computer on and no users have been logged in yet. I don't want to have anything special enabled on the computer (like the remote desktop workaround). I can provide the actual password to the account and I would like this to be compatible on Windows 7. Has anyone come across any script that can do this? If there isn't a way to unlock the computer from startup, is there at least a way to unlock the account that's currently already logged into but just has the lock screen up?
  25. Hello. I'm building a script to install some windows updates with a GUI. For this, the script need to know witch windows version to work: Windows 7, Windows 7 SP1, Windows 8, Windows 8.1 and so on. I read this article, but it don't list Windows 10 Anniversary Edition. So, I run into build version, because they are different between them. The first is 10586, and Anniversary is 14393. So, somewhere on my script I have this: If @OSVersion = 'win_10' Then $versao_windows = 'Windows 10' ElseIf @OSVersion = 'win_10' And @OSBuild = 14393 Then $versao_windows = 'Windows 10 Edição De Aniversário' $win10ae = 1 EndIf As you see, "$versao_windows" is the "friendly" name to be showed on the GUI, and "$win10ae" will be the variable to be used to distinguish the windows version to use. But the script still showing the 'normal' Windows 10 version, even if it is running on Anniversary Edition. On the status bar, it rightly shows the 14393 build, but don't shows "Windows 10 Edição De Aniversário". I need this to install the correct updates, because they are different from one build to another. Where I'm wrong on my code? Thanks in advice!
×
×
  • Create New...