Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/18/2022 in all areas

  1. This is a quick start guide to using the AutoIt PowerShell Cmdlets. The best bits of AutoIt directly from PowerShell The files you need are as follows (get them from the zip file or the Program Files folder after installation): AutoItX.psd1AutoItX3.PowerShell.dllAutoItX3.Assembly.dllAutoItX3.dllAutoItX3_x64.dllTo use the Cmdlets open a PowerShell cmd prompt and enter: Import-Module .\AutoItX.psd1 Now you can get a list of available AutoIt Cmdlets by doing Get-Command *AU3*: PS> Get-Command *AU3* Name Category Module ---- -------- ------ Invoke-AU3MouseWheel Cmdlet AutoItX Move-AU3Mouse Cmdlet AutoItX Invoke-AU3MouseClickDrag Cmdlet AutoItX Get-AU3MouseCursor Cmdlet AutoItX Invoke-AU3MouseUp Cmdlet AutoItX Assert-AU3WinActive Cmdlet AutoItX Assert-AU3WinExists Cmdlet AutoItX Assert-AU3IsAdmin Cmdlet AutoItX Invoke-AU3Shutdown Cmdlet AutoItX Send-AU3ControlKey Cmdlet AutoItX Invoke-AU3MouseDown Cmdlet AutoItX Invoke-AU3MouseClick Cmdlet AutoItX Invoke-AU3ControlTreeView Cmdlet AutoItX Invoke-AU3ControlListView Cmdlet AutoItX Invoke-AU3ControlCommand Cmdlet AutoItX Invoke-AU3ControlClick Cmdlet AutoItX Move-AU3Control Cmdlet AutoItX Set-AU3ControlText Cmdlet AutoItX Show-AU3Control Cmdlet AutoItX Hide-AU3Control Cmdlet AutoItX Get-AU3ControlText Cmdlet AutoItX Get-AU3ControlFocus Cmdlet AutoItX Set-AU3ControlFocus Cmdlet AutoItX Disable-AU3Control Cmdlet AutoItX Enable-AU3Control Cmdlet AutoItX Get-AU3StatusbarText Cmdlet AutoItX Invoke-AU3RunAsWait Cmdlet AutoItX Invoke-AU3RunAs Cmdlet AutoItX Invoke-AU3RunWait Cmdlet AutoItX Invoke-AU3Run Cmdlet AutoItX Set-AU3Clip Cmdlet AutoItX Get-AU3Clip Cmdlet AutoItX Set-AU3WinTrans Cmdlet AutoItX Set-AU3WinTitle Cmdlet AutoItX Set-AU3WinState Cmdlet AutoItX Set-AU3WinOnTop Cmdlet AutoItX Move-AU3Win Cmdlet AutoItX Show-AU3WinMinimizeAllUndo Cmdlet AutoItX Show-AU3WinMinimizeAll Cmdlet AutoItX Get-AU3WinState Cmdlet AutoItX Get-AU3WinProcess Cmdlet AutoItX Get-AU3WinClassList Cmdlet AutoItX Get-AU3WinCaretPos Cmdlet AutoItX Get-AU3WinClientSize Cmdlet AutoItX Get-AU3ControlPos Cmdlet AutoItX Get-AU3ControlHandle Cmdlet AutoItX Get-AU3MousePos Cmdlet AutoItX Get-AU3WinPos Cmdlet AutoItX Get-AU3WinHandle Cmdlet AutoItX Get-AU3ErrorCode Cmdlet AutoItX Initialize-AU3 Cmdlet AutoItX Show-AU3WinActivate Cmdlet AutoItX Close-AU3Win Cmdlet AutoItX Wait-AU3WinClose Cmdlet AutoItX Wait-AU3WinNotActive Cmdlet AutoItX Set-AU3Option Cmdlet AutoItX Send-AU3Key Cmdlet AutoItX Wait-AU3Win Cmdlet AutoItX Wait-AU3WinActive Cmdlet AutoItX Get-AU3WinTitle Cmdlet AutoItX Get-AU3WinText Cmdlet AutoItX I’ll show how to use the Cmdlets using a simple example that will open notepad.exe and modify the edit window by setting the text and simulating some keystrokes. First create a blank PowerShell script called notepad_example.ps1 in the same folder as the AutoItX components above and open it for editing. Now we want to import the PowerShell module which is AutoItX.psd1. Enter the following in the script: Import-Module .\AutoItX.psd1 We want to run notepad.exe: Invoke-AU3Run -Program notepad.exe After notepad opens we want to wait for the notepad “Untitled -Notepad” window to appear. You might need to change the title for non-English versions of Windows: $notepadTitle = "Untitled - Notepad" Wait-AU3Win -Title $notepadTitle $winHandle = Get-AU3WinHandle -Title $notepadTitle Get-AU3WinHandle returns a native Win32 handle to the notepad window. We can use this handle in many other AutoIt functions and it uniquely identifies the window which is much more reliable than constantly using a windows title. If you have obtained a window handle using any other Win32 function you can use it with AutoIt. After obtaining the handle to the notepad window we want to ensure that the window is active and then get a handle to the Edit Control. Using the AU3Info.exe tool that comes with AutoIt we can find that the name of the edit control in notepad is Edit1. Show-AU3WinActivate -WinHandle $winHandle $controlHandle = Get-AU3ControlHandle -WinHandle $winhandle -Control "Edit1" Now that we have a handle to the edit control we can set text in two ways: Directly (Set-AU3Controltext) or with simulated keystrokes (Send-AU3ControlKey): Set-AU3ControlText -ControlHandle $controlHandle -NewText "Hello! This is being controlled by AutoIt and PowerShell!" -WinHandle $winHandle Send-AU3ControlKey -ControlHandle $controlHandle -Key "{ENTER}simulate key strokes - line 1" -WinHandle $winHandleNow let’s see what the entire script looks like: # Import the AutoIt PowerShell module Import-Module .\AutoItX.psd1 # Run notepad.exe Invoke-AU3Run -Program notepad.exe # Wait for an untitled notepad window and get the handle $notepadTitle = "Untitled - Notepad" Wait-AU3Win -Title $notepadTitle $winHandle = Get-AU3WinHandle -Title $notepadTitle # Activate the window Show-AU3WinActivate -WinHandle $winHandle # Get the handle of the notepad text control for reliable operations $controlHandle = Get-AU3ControlHandle -WinHandle $winhandle -Control "Edit1" # Change the edit control Set-AU3ControlText -ControlHandle $controlHandle -NewText "Hello! This is being controlled by AutoIt and PowerShell!" -WinHandle $winHandle # Send some keystrokes to the edit control Send-AU3ControlKey -ControlHandle $controlHandle -Key "{ENTER}simulate key strokes - line 1" -WinHandle $winHandle Send-AU3ControlKey -ControlHandle $controlHandle -Key "{ENTER}simulate key strokes - line 2" -WinHandle $winHandle Send-AU3ControlKey -ControlHandle $controlHandle -Key "{ENTER}{ENTER}" -WinHandle $winHandle This is how the notepad window should look if everything is working correctly:
    1 point
  2. You did not set PixelCoordMode in your script. On default, hWnd is simply ignored. (help file is your friend you know)
    1 point
  3. I have added your functions into your Curl library and successfully cooked up some examples for Telegram: There is enough in that Telegram UDF to steal for your own examples.
    1 point
  4. hi, This is my first project in AutoIT I only started using it today. It a very basic program that asks the user to enter a length for the password then, one is generated and is copiyed to the clipboard. Well Hope you may find it usfull it's my first attement as I not used to this cool AutoIT yet, but lucky I done some VB and know a little bit, I hope to update this project to support a GUI as time goes on. Comments are welcome. #include <StringConstants.au3> const $pwsMask = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" Const $Msg1 = "Your password was copiyed to the clipboard." const $msgPrompt = "Please enter the size of the password you want to create below:" Local $len Local $n Local $buff $Len = InputBox("Ben Password Generator v1.0",$msgPrompt,"8") $len = StringStripWS($len,$STR_STRIPALL) ;Check that user has entered a vaild password length if not StringIsDigit($len) or $len = 0 Then MsgBox(48,"Error","Invaild Integer was entered" & @CRLF & "Program will now exit.") Exit EndIf ;This creates the random password. for $i = 1 to $Len ;Pick a random chat between 1 and the pwsMask Length $n = int(random(1,StringLen($pwsMask))) ;Concat each chat that has been picked out of pwsMask to $buff $buff = $Buff & StringMid($pwsmask,$n,1) Next ;Put new password on the clipboard. ClipPut("Password: " & $buff) ;Inform user password was created MsgBox(64,"Password",$msg1) Exit
    1 point
×
×
  • Create New...