General Windows Questions

AutoIt

 

Q #1: Is it possible to send keystrokes to invisible windows with AutoIt?

 

      ---------------------------------------------------------------------

 

A #1: No

 

-----------------------------------------------------------------------------

 

Q #2: Is their anyway to have AutoIt hold a mouse click down (for a second

      or so)? The reason I ask is some Applications (Adobe Acrobat in this

      case) have "flyout menus" that are activated by holding the mouse

      down over a button for a second or so. Is their anyway to do this

      with AutoIt?

 

      ---------------------------------------------------------------------

 

A #1: I haven't tested it yet, but you might try the SetKeyDelay command

      before the LeftClick command. I've had luck doing this with

      LeftClickDrag command. Syntax example from my script follows.

 

      ; ======= Scriptlet Starts Here =======

      SetKeyDelay, 400

      LeftClickDrag, 590, 235, 247, 235

      SetKeyDelay, 20

      ; ======= Scriptlet Ends Here =======

 

      ---------------------------------------------------------------------

 

A #2: I have not done this, but I believe if you run AutoIT's Reveal Mode

      utility, and then mimic the mouse movements yourself, the utility

      will identify the specific coordinates relative to the display. Then,

      try using the MouseMove function to initially position the mouse at

      the appropriate location, and then use the LeftClickDrag function,

      specifying the same coordinates in both the x1/y1 and x2/y2

      variables. You might also try using the Repeat/EndRepeat functions to

      extend the left-click operation to the desired length.

 

-----------------------------------------------------------------------------

 

Q #3: Its kind of annoying having the mouse position fly off to some odd

      position after the various mouse operations (LeftClick etc.).  Is it

      possible to bring it back to where it was originally?

 

      ---------------------------------------------------------------------

 

A #1: yes you can do it with:

 

      ; ======= Scriptlet Starts Here =======

      WinActivate, Program Manager

      MouseGetPos, X, Y

 

      WinActivate, [your application]

      [Mouse Operation: LeftClick etc ...]

 

      WinActivate, Program Manager

      MouseMove, %X%, %Y%

 

      WinActivate, [your (new) application window]

      ; ======= Scriptlet Ends Here =======

 

      But it's somewhat slow, messy and problematical, having to activate

      the appropriate application window at the end etc.

 

-----------------------------------------------------------------------------

 

Q #4: Does anybody know a clean way to determine that Windows has finished

      booting. I want an autoit script to run after all programs from the

      windows startup have finished, otherwise some windows popping up

      during the boot process interfere with my script. Starting the script

      with a long Sleep is not very 'clean'.

 

      ---------------------------------------------------------------------

 

A #1: Maybe trying WinWait for all of the programs that are supposed to be

      loading; if it hasn't loaded, wait until it does. Do that for all of

      the programs.

 

      ---------------------------------------------------------------------

 

A #2: I'm not sure about the sequence of loading of windows programs, and I

      know this is a bit artificial, but could you put notepad.exe in the

      startup group and just winwait till it is active....close it and

      start your script?

 

      ---------------------------------------------------------------------

 

A #3: I don't think there is any way to do this.  There are so many programs

      that can start at bootup, and they can start from so many different

      places, that I don't think there will ever be a way to do this. I know

      it's a kluge, but I would:

     

      ; ======= Scriptlet Starts Here =======

      repeat, 10

      sleep, 30000

      endrepeat

      Winminizeall

      ; ======= Scriptlet Ends Here =======

 

      ---------------------------------------------------------------------

 

A #4: Piece of cake :)

 

      WinWait, Program Manager

 

-----------------------------------------------------------------------------

 

Q #5: How do I create a shortcut from within AutoIt?

 

      ---------------------------------------------------------------------

 

A #1: You have to use the Shortcut Wizard that's part of the Desktop

      Explorer shell (Program Manager).  The following script should work

      on all Windows versions and resolutions, but no guarantees.

 

      ; ======= Script Starts Here =======

      ; Get the screen resolution.

      GoSub, FindResolution

      EnvDiv, Horizontal, 2

      EnvDiv, Vertical, 2

 

      ; Bring up a shortcut creation wizard.

      WinActivate, Program Manager

      RightClick, %Horizontal%, %Vertical%

      Send, ws

 

      ; Specify the full UNC.

      WinWaitActive, Create Shortcut

      Send, C:\\autoexec.bat{ENTER}

 

      ; Specify the shortcut text.

      WinWaitActive, Select a Title for the Program

      Send, Test 1{ENTER}

 

      WinMinimizeAllUndo

      Exit

 

      FindResolution:

          ; Find out what resolution the display is at.

 

          ; Find out what OS we're on.

          IfEqual,A_OSTYPE,WIN32_WINDOWS, goto, Win9x

          IfEqual,A_OSTYPE,WIN32_NT, goto, WinNT

 

          Win9x:

          ; Get the resolution from the registry.

    RegRead, VideoDevice, REG_SZ, HKEY_CURRENT_CONFIG, Display\\Settings, Resolution

          ; Get the Vertical resolution.

          StringGetPos, P, VideoDevice, \,

          StringLen, L, VideoDevice

          SetEnv, L2, %P%

          EnvAdd, L2, 1

          StringTrimLeft, Vertical, VideoDevice, %L2%

 

          ; Get the Horizontal resolution.

          SetEnv, L2, %L%

          EnvSub, L2, %P%

          StringTrimRight, Horizontal, VideoDevice, %L2%

          Return

     

          WinNT:

          ; Get the resolution from the registry.

    regread, Videodevice, REG_SZ, HKEY_LOCAL_MACHINE, HARDWARE\\DEVICEMAP\\VIDEO,

\\Device\\Video0

     

          StringtrimLeft, Videodevice1, videodevice, 48

          StringtrimRight, videodevice2, videodevice1, 8

     

          ; Put the proper values in the variables.

    RegRead, Horizontal, REG_DWORD, HKEY_CURRENT_CONFIG,

System\\CurrentControlSet\\SERVICES\\%videodevice2%\\DEVICE0, DefaultSettings. XResolution

    RegRead, Vertical, REG_DWORD, HKEY_CURRENT_CONFIG,

System\\CurrentControlSet\\SERVICES\\%videodevice2%\\DEVICE0, DefaultSettings. YResolution

      Return

      ; ======= Script Ends Here =======

 

      ---------------------------------------------------------------------

 

A #2: You might want to check out a program called PC Updater. It will

      create shortcuts, etc. You can use variables to send it exactly where

      you want. Works on NT, and 9x boxes. Also, it works very well with

      profiles. A great program for software installs also.  Makes self

      extracting EXE's. I use it for installs if they're too complicated

      for AutoIt.

 

      ---------------------------------------------------------------------

 

A #3: Here is a command line utility I wrote to create a shortcut.  You can

      create the "group" by just creating a directory within the StartMenu

      tree. Attached is a console (DOS window) program that will take a

      text file and create a shortcut from it.  Also attached iis the

      Visual C++ source for the program.

 

      Source File Format

 

      Line 1 - Target Link File

      Line 2 - Source Executable File

      Line 3 - Description

      Line 4 - Command Line Args

      Line 5 - Starting Directory

      Line 6 - Icon File

      Line 7 - Icon Index

 

      ---------------------------------------------------------------------

 

A #4: make the shortcuts ready to work in the directory from where you

      install the program after the installation is done copy it with

      lnkcopy in the users profile.

 

      ---------------------------------------------------------------------

 

A #5: Why not create a shortcut that has a filename of C:\autoexec.bat in

      the "Target" location, and then at the end of the installation when

      you know what the path is you modify the shortcut to add the real

      path and filename into the "Target" and "Start in" locations?

 

      Or do what most installation programs do.  Wait until the

      installation is complete, and then make the shortcut when you know

      the path and filename.

 

      ---------------------------------------------------------------------

 

A #6: this is where you can download the scut.exe,

 

      http://www.jsiinc.com/TIP0400/rh0422.htm

 

      This program has all the capabilities of the full Microsoft

      shortcut.exe program except the ability to create them.

 

      ---------------------------------------------------------------------

 

A #7: Have you thought about using a .pif file for the shortcut?

 

      I don't use AutoIt to create my shortcuts - since I wrap my AutoIT

      scripts in either an SMS Installer executable or a Wise InstallMaster

      Executable.

 

-----------------------------------------------------------------------------

Q #6: In a script I want to detect a window to be active. The problem is
      that the windowtext varies. The text is: "A\xxxxxxxxxx\B", where A
      and B are constant and xxx varies. The xxx are depending on Project
      name and path.

      How can I solve this?

      ---------------------------------------------------------------------

A #1: I think you can use StringRight and StringLeft to get the first
      two and the last two characters from the title into variables
      and then test IFEqual to A\\ and \\B.

      ---------------------------------------------------------------------

A #2: Copy the Window title into a variable, use the String functions to
      parse it for the proper text?

      ---------------------------------------------------------------------

A #3: Try to use the command SetTitleMatchMode.