Jump to content

Hoping someone can help


Recommended Posts

I used to use Autoit heavily in my working environment years ago. I've been trying to figure out how to do something I think is very simple for days and I simply can no longer do it.  I suffered some health issues a few years ago and the combination of Neural damage and medication just kill my functional.  

I'm trying to create a script that I can trigger with a key stroke that will click a button on an application running on my other monitor. It seems like it should be ease but I can not it work.  If someone has a similar script I would love to see it. Thank you s much.

Link to comment
Share on other sites

Below you will find an example script that will:

1 Record user's active window.

2 Open Calculator

3 Move it to the second monitor

4 Return user active window

Loop [

Wait for UP ARROW to be pressed

1 Record user's active window.

2 Send 1234 + 5 = at Calculator

3 Return user active window

]

Function _DesktopDimensions() written by guinness to find the size of the primary monitor.

Please note this script was written expecting English and a Calculator.

 

#include <Misc.au3>
#include <WinAPI.au3>
#include <GuiConstants.au3>

; Save user active window
$hWin_active = WinGetHandle("")

; Calculate the size of monitors
$aMonitors_info = _DesktopDimensions()

; open a new calc
ShellExecute("Calc")
; wait for it
Sleep(300)
; Move it to the second monitor
$x = WinMove("Calculator", "", $aMonitors_info[1] + 250, $aMonitors_info[2] / 2)

; Return user active window
WinActivate($hWin_active)

While 1
    ; Test sending keys at right window
    ; "26" is UP ARROW KEY
    If _IsPressed("26") Then
        ; Save user active window
        $hWin_active = WinGetHandle("")

        ;$hWin_send = "Your Specified Window Title, be exact or change the WinTitleSetMode"
        $hWin_send = WinGetHandle("Calculator")

        ; Send your commands

        controlsend($hWin_send, "", 0, "1234")
        controlsend($hWin_send, "", 0, "{+}")
        controlsend($hWin_send, "", 0, "5")
        controlsend($hWin_send, "", 0, "{=}")
        ; pst it's 1239

        ; Return user active window
        WinActivate($hWin_active)

    EndIf; _IsPressed("26")
WEnd; 1

; https://www.autoitscript.com/forum/topic/134534-_desktopdimensions-details-about-the-primary-and-secondary-monitors/
; #FUNCTION# ====================================================================================================================
; Name ..........: _DesktopDimensions
; Description ...: Returns an array containing information about the primary and virtual monitors.
; Syntax ........: _DesktopDimensions()
; Return values .: Success - Returns a 6-element array containing the following information:
;                  $aArray[0] = Total number of monitors.
;                  $aArray[1] = Width of the primary monitor.
;                  $aArray[2] = Height of the primary monitor.
;                  $aArray[3] = Total width of the desktop including the width of multiple monitors. Note: If no secondary monitor this will be the same as $aArray[2].
;                  $aArray[4] = Total height of the desktop including the height of multiple monitors. Note: If no secondary monitor this will be the same as $aArray[3].
; Author ........: guinness
; Remarks .......: WinAPI.au3 must be included i.e. #include <WinAPI.au3>
; Related .......: @DesktopWidth, @DesktopHeight, _WinAPI_GetSystemMetrics
; Example .......: Yes
; ===============================================================================================================================
Func _DesktopDimensions()
    Local $aReturn = [_WinAPI_GetSystemMetrics($SM_CMONITORS), _ ; Number of monitors.
            _WinAPI_GetSystemMetrics($SM_CXSCREEN), _ ; Width or Primary monitor.
            _WinAPI_GetSystemMetrics($SM_CYSCREEN), _ ; Height or Primary monitor.
            _WinAPI_GetSystemMetrics($SM_CXVIRTUALSCREEN), _ ; Width of the Virtual screen.
            _WinAPI_GetSystemMetrics($SM_CYVIRTUALSCREEN)] ; Height of the Virtual screen.
    Return $aReturn
EndFunc   ;==>_DesktopDimensions

 

I'm not real sure what you need here is a video of AutoIt using an Xbox controller on youtube right monitor (and returning user focused window)

Acquire window by location, Play. Pause, Fast Forward, Rewind, Fullscreen

Youtube likes when you give it focus before sending any keystrokes at it.

 

Edited by Xandy
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...