Jump to content

Send problem using AutoIt [weird]


Recommended Posts

Hey,

So I made a VBScript to simply send a "Next" command to an install dialogue during a setup. Used the AutoItX3.Control and it works just fine. However instead of deploying the AutoItX3.dll to client machines I decided to convert the script to .au3 so that I could convert it to a standalone .EXE.

Then the trouble began, almost everything appears to be working fine but for the life of me I cannot get AutoIt to Send the key combination to the setup dialogue anymore. It just won't work and it's driving me crazy. I observe by testing with Notepad that the Send command DOES infact work however it refuses to send the key to the setup dialog window I've activated. The autoIT script simply completes processing and exits.

Here are the two nearly identical scripts (one works the other does not).

VBScript

Option Explicit

Dim oShell
Dim oAutoIt
Dim WinState

Set oShell = WScript.CreateObject("WScript.Shell")
Set oAutoIt = WScript.CreateObject("AutoItX3.Control")

oAutoIt.WinWait "Petroleum Experts Integrated Production Modelling toolkit Setup"
oAutoIt.Sleep 100

Do while WinState <> 7

WinState=oAutoIt.WinGetState("Petroleum Experts Integrated Production Modelling toolkit Setup", "")
Wscript.Sleep 1000

Loop

oAutoIt.WinActivate "Petroleum Experts Integrated Production Modelling toolkit Setup", ""
oAutoIt.Sleep 100
oAutoIt.Send "!n"

AutoIT

;Opt("SendKeyDelay", 5)
;Opt("SendKeyDownDelay", 5)

Local $WinState

WinWait("Petroleum Experts Integrated Production Modelling toolkit Setup")
Sleep(100)

Do
$WinState=WinGetState("Petroleum Experts Integrated Production Modelling toolkit Setup", "")
Sleep(1000)
Until $WinState=7

WinActivate("Petroleum Experts Integrated Production Modelling toolkit Setup")
Sleep(100)

WinWaitActive("Petroleum Experts Integrated Production Modelling toolkit Setup")
Sleep(100)

Send("!n")

I've tried playing around with the SendKey delay's to no effect. I've tried using ControlSend instead of Send but it did not help.

I'm dumbfounded as to why this is happening, anyone have a clue what's going on? I mean why on earth would it work when calling the object from a VBScript but not directly in an AutoIt script? meh....

Thanks!

Link to comment
Share on other sites

Hi, sometimes send function will lock ctrl or alt modifier keys, so if you use those, check if they are pressed after running the script,

if they are, the keys wont go thru, if you know what i mean. It can have nothing to do with this, but maybe just the way VB uses the function can make a difference.

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

Hi, hmmm, doubt that is the case becasue the Send command does appear to be going through for all other windows as when I test with Notepad it works just fine. I test by open up a new notepad document, write some nonsense and press CTRL+N to create a new document, you then get the "Do you want to save changes to Untilted" dialogue which has the ALT+N shortcut for Don't save which is same key combination I'm trying to activate on my setup dialogue. The script manages to activate ALT+N on that dialogue just fine (I set sleep to 2000 and manually make Notepad the window in focus instead of my setup dialogue to test) but refuses to send any keys to my setup dialogue :(. Note it does bring the setup window into focus correctly, however.

Edited by AveiMil
Link to comment
Share on other sites

The script manages to activate ALT+N on that dialogue just fine (I set sleep to 2000 and manually make Notepad the window in focus instead of my setup dialogue to test) but refuses to send any keys to my setup dialogue :(. Note it does bring the setup window into focus correctly, however.

Ok, i would try to make a mouseclick, since the dialog is the same...

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

Nah, if I can't figure out why this won't work with .au3 I'll simply use the VBScript and deploy the AutoItX3.dll with the necessary COM information prior to the installation. As far as I remember doing a mouse click brings in all sort additional challenges, like xy coordinates changing with resolution etc. Also there’s no guarantee it will work differently with mouse clicks.

Thanks for the tip though :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...