Jump to content

Controlling minimized full-screen apps


 Share

Recommended Posts

Is it possible to control a full screen application that is minimized, and do other things on the computer at the same time, without my real mouse cursor being controlled by autoit, only the one in the minimized full screen application? So that I can move my mouse around and do other stuff without interfering with autoit and without autoit interfering with me?

Link to comment
Share on other sites

Sorry forgot to mention.. the things autoit would be clicking on don't have controlids..

The

Func QuickClick($button="left",$x,$y,$clicks=1)

Local $Pos = MouseGetPos()

MouseClick($button,$x,$y,$clicks,0)

MouseMove($Pos[0],$Pos[1],0)

EndFunc

Looks like it would work.. except it won't be able to control an app I have minimized..

Edited by Azu
Link to comment
Share on other sites

I was referring to MouseClickPlus:

;===============================================================================
;
; Function Name:  _MouseClickPlus()
; Version added:  0.1
; Description:    Sends a click to window, not entirely accurate, but works
;                 minimized.
; Parameter(s):   $Window     =  Title of the window to send click to
;                 $Button     =  "left" or "right" mouse button
;                 $X          =  X coordinate
;                 $Y          =  Y coordinate
;                 $Clicks     =  Number of clicks to send
; Remarks:        You MUST be in "MouseCoordMode" 0 to use this without bugs.
; Author(s):      Insolence <insolence_9@yahoo.com>
;
;===============================================================================
Func _MouseClickPlus($Window, $Button = "left", $X = "", $Y = "", $Clicks = 1)
  Local $MK_LBUTTON       =  0x0001
  Local $WM_LBUTTONDOWN   =  0x0201
  Local $WM_LBUTTONUP     =  0x0202
  
  Local $MK_RBUTTON       =  0x0002  
  Local $WM_RBUTTONDOWN   =  0x0204
  Local $WM_RBUTTONUP     =  0x0205

  Local $WM_MOUSEMOVE     =  0x0200
  
  Local $i                = 0
  
  Select
  Case $Button = "left"
     $Button     =  $MK_LBUTTON
     $ButtonDown =  $WM_LBUTTONDOWN
     $ButtonUp   =  $WM_LBUTTONUP
  Case $Button = "right"
     $Button     =  $MK_RBUTTON
     $ButtonDown =  $WM_RBUTTONDOWN
     $ButtonUp   =  $WM_RBUTTONUP
  EndSelect
  
  If $X = "" OR $Y = "" Then
     $MouseCoord = MouseGetPos()
     $X = $MouseCoord[0]
     $Y = $MouseCoord[1]
  EndIf
  
  For $i = 1 to $Clicks
     DllCall("user32.dll", "int", "SendMessage", _
        "hwnd",  WinGetHandle( $Window ), _
        "int",   $WM_MOUSEMOVE, _
        "int",   0, _
        "long",  _MakeLong($X, $Y))
        
     DllCall("user32.dll", "int", "SendMessage", _
        "hwnd",  WinGetHandle( $Window ), _
        "int",   $ButtonDown, _
        "int",   $Button, _
        "long",  _MakeLong($X, $Y))
        
     DllCall("user32.dll", "int", "SendMessage", _
        "hwnd",  WinGetHandle( $Window ), _
        "int",   $ButtonUp, _
        "int",   $Button, _
        "long",  _MakeLong($X, $Y))
  Next
EndFunc

Func _MakeLong($LoWord,$HiWord)
  Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF))
EndFunc
Link to comment
Share on other sites

  • Moderators

Oh.. nice..

But will I have to copy that all for every single click I want it to make? Or is there a way to call it?

Your kidding right?

Func _MouseClickPlus($Window, $Button = "left", $X = "", $Y = "", $Clicks = 1)

_MouseClickPlus($Window, "left", $X, $Y, $Clicks) To call it?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

What am I doing wrong? It's saying

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

AutoIt Error

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

Line 3 (File "C:\Documents and Settings\Administrator\Desktop\test.au3"):

_MouseClickPlus($Window = "text.txt", $Button = "left", $X = "58", $Y = "105", $Clicks = 2)

_MouseClickPlus(^ ERROR

Error: Variable used without being declared.

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

OK

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

The script is
#include <GUIConstants.au3>

_MouseClickPlus($Window = "text.txt", $Button = "left", $X = "58", $Y = "105", $Clicks = "2")


Func _MouseClickPlus($Window, $Button = "left", $X = "", $Y = "", $Clicks = 1)
  Local $MK_LBUTTON    =  0x0001
  Local $WM_LBUTTONDOWN   =  0x0201
  Local $WM_LBUTTONUP    =  0x0202
 
  Local $MK_RBUTTON    =  0x0002 
  Local $WM_RBUTTONDOWN   =  0x0204
  Local $WM_RBUTTONUP    =  0x0205

  Local $WM_MOUSEMOVE    =  0x0200
 
  Local $i              = 0
 
  Select
  Case $Button = "left"
     $Button     =  $MK_LBUTTON
     $ButtonDown =  $WM_LBUTTONDOWN
     $ButtonUp   =  $WM_LBUTTONUP
  Case $Button = "right"
     $Button     =  $MK_RBUTTON
     $ButtonDown =  $WM_RBUTTONDOWN
     $ButtonUp   =  $WM_RBUTTONUP
  EndSelect
 
  If $X = "" OR $Y = "" Then
     $MouseCoord = MouseGetPos()
     $X = $MouseCoord[0]
     $Y = $MouseCoord[1]
  EndIf
 
  For $i = 1 to $Clicks
     DllCall("user32.dll", "int", "SendMessage", _
        "hwnd",  WinGetHandle( $Window ), _
        "int",   $WM_MOUSEMOVE, _
        "int",   0, _
        "long",  _MakeLong($X, $Y))
       
     DllCall("user32.dll", "int", "SendMessage", _
        "hwnd",  WinGetHandle( $Window ), _
        "int",   $ButtonDown, _
        "int",   $Button, _
        "long",  _MakeLong($X, $Y))
       
     DllCall("user32.dll", "int", "SendMessage", _
        "hwnd",  WinGetHandle( $Window ), _
        "int",   $ButtonUp, _
        "int",   $Button, _
        "long",  _MakeLong($X, $Y))
  Next
EndFunc

Func _MakeLong($LoWord,$HiWord)
  Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF))
EndFunc
Link to comment
Share on other sites

Thanks.. it runs without errors now :D

But.. it doesn't seem to do anything..

When I run the script nothing happens..

But when I bring up text.txt and click at those coordinates manually with my mouse, it moves the cursor to there.

text.txt is open in notepad btw, and it shows as "text.txt - Notepad" so I changed the script to reflect that.. but still nothing happens.. I don't understand x_x

Link to comment
Share on other sites

It still doesn't do anything..

#include <GUIConstants.au3>

Opt("WinTitleMatchMode", 2)

_MouseClickPlus("Notepad", "left","58", "105", "2")

Func _MouseClickPlus($Window, $Button = "left", $X = "", $Y = "", $Clicks = 1)
  Local $MK_LBUTTON    =  0x0001
  Local $WM_LBUTTONDOWN   =  0x0201
  Local $WM_LBUTTONUP    =  0x0202
 
  Local $MK_RBUTTON    =  0x0002 
  Local $WM_RBUTTONDOWN   =  0x0204
  Local $WM_RBUTTONUP    =  0x0205

  Local $WM_MOUSEMOVE    =  0x0200
 
  Local $i              = 0
 
  Select
  Case $Button = "left"
     $Button     =  $MK_LBUTTON
     $ButtonDown =  $WM_LBUTTONDOWN
     $ButtonUp   =  $WM_LBUTTONUP
  Case $Button = "right"
     $Button     =  $MK_RBUTTON
     $ButtonDown =  $WM_RBUTTONDOWN
     $ButtonUp   =  $WM_RBUTTONUP
  EndSelect
 
  If $X = "" OR $Y = "" Then
     $MouseCoord = MouseGetPos()
     $X = $MouseCoord[0]
     $Y = $MouseCoord[1]
  EndIf
 
  For $i = 1 to $Clicks
     DllCall("user32.dll", "int", "SendMessage", _
        "hwnd",  WinGetHandle( $Window ), _
        "int",   $WM_MOUSEMOVE, _
        "int",   0, _
        "long",  _MakeLong($X, $Y))
       
     DllCall("user32.dll", "int", "SendMessage", _
        "hwnd",  WinGetHandle( $Window ), _
        "int",   $ButtonDown, _
        "int",   $Button, _
        "long",  _MakeLong($X, $Y))
       
     DllCall("user32.dll", "int", "SendMessage", _
        "hwnd",  WinGetHandle( $Window ), _
        "int",   $ButtonUp, _
        "int",   $Button, _
        "long",  _MakeLong($X, $Y))
  Next
EndFunc

Func _MakeLong($LoWord,$HiWord)
  Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF))
EndFunc
Link to comment
Share on other sites

I make a bunch of newlines in a text document, and moved the cursor to the top.. and got the coords for the bottom line.. and tried to set the script to click there.. when I run the script, and then un-minimize the notepad, the cursor is still at the very top, as if autoit didn't click.. O_o

Link to comment
Share on other sites

I've found the problem. You're sending the x,y and clicks parameters as a string. They should be sent as an Int. Dll's are picky when it comes to datatypes (AutoIt has only one datatype)

Edit: I have modified the function to check for errors.. I've also tried doing this myself ^^ It doens't work.. lool.

Edit2: From the original comment: ; Remarks: You MUST be in "MouseCoordMode" 0 to use this without bugs.

:D

Edit3: I still can't get it to work!

Opt("WinTitleMatchMode", 2)
Opt("MouseCoordMode", 0)

_MouseClickPlus("Notepad", "left","","", 1)
If @error Then
    MsgBox(0, "@error", @error)
EndIf

Func _MouseClickPlus($Window, $Button = "left", $X = "", $Y = "", $Clicks = 1)
  Local $MK_LBUTTON       =  0x0001
  Local $WM_LBUTTONDOWN   =  0x0201
  Local $WM_LBUTTONUP     =  0x0202

  Local $MK_RBUTTON       =  0x0002 
  Local $WM_RBUTTONDOWN   =  0x0204
  Local $WM_RBUTTONUP     =  0x0205

  Local $WM_MOUSEMOVE     =  0x0200

  Local $i                = 0

  If WinGetHandle($Window) = 0 Then
     SetError(2)
  EndIf

  Select
  Case $Button = "left"
     $Button     =  $MK_LBUTTON
     $ButtonDown =  $WM_LBUTTONDOWN
     $ButtonUp   =  $WM_LBUTTONUP
  Case $Button = "right"
     $Button     =  $MK_RBUTTON
     $ButtonDown =  $WM_RBUTTONDOWN
     $ButtonUp   =  $WM_RBUTTONUP
  Case Else
     SetError(1)
  EndSelect

  If $X = "" OR $Y = "" Then
     $MouseCoord = MouseGetPos()
     If Not @error Then
        $X = $MouseCoord[0]
        $Y = $MouseCoord[1]
     Else
        SetError(3)
     EndIF
  EndIf

  For $i = 1 to $Clicks
     DllCall("user32.dll", "int", "SendMessage", _
        "hwnd",  WinGetHandle( $Window ), _
        "int",   $WM_MOUSEMOVE, _
        "int",   0, _
        "long",  _MakeLong($X, $Y))
       
     DllCall("user32.dll", "int", "SendMessage", _
        "hwnd",  WinGetHandle( $Window ), _
        "int",   $ButtonDown, _
        "int",   $Button, _
        "long",  _MakeLong($X, $Y))
       
     DllCall("user32.dll", "int", "SendMessage", _
        "hwnd",  WinGetHandle( $Window ), _
        "int",   $ButtonUp, _
        "int",   $Button, _
        "long",  _MakeLong($X, $Y))
  Next
EndFunc

Func _MakeLong($LoWord,$HiWord)
    Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF))
EndFunc
Edited by Manadar
Link to comment
Share on other sites

DllCall("user32.dll", "int", "SendMessage", _

"hwnd", WinGetHandle( $Window ), _

"int", $WM_MOUSEMOVE, _

"int", 0, _

"long", _MakeLong($X, $Y))

DllCall("user32.dll", "int", "SendMessage", _

"hwnd", WinGetHandle( $Window ), _

"int", $ButtonDown, _

"int", $Button, _

"long", _MakeLong($X, $Y))

DllCall("user32.dll", "int", "SendMessage", _

"hwnd", WinGetHandle( $Window ), _

"int", $ButtonUp, _

"int", $Button, _

"long", _MakeLong($X, $Y))"

Shouldn't that be sending it as int?

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