Jump to content
Qeuep

MouseClick not working after Winactivate ?

Recommended Posts

Hi everyone, this is driving me craaaazy !

So, MouseClick works perfectly fine when I use it on desktop BUT when I open another program, the mouse just doesn't move !

Here is my code :

ShellExecute("MYPROGRAM")
WinWaitActive("MYPROGRAM")

WinActivate("MYPROGRAM")
Opt("MouseCoordMode", 2) --> I've tried relative coords, absolute, everything...
MouseClick("left", 320, 139, 1, 10) --> Same thing, tried all coords with Window Info, nothing moves...

 

Help is welcome !

 

PS : Even tried Controlclick, not working...

Share this post


Link to post
Share on other sites
35 minutes ago, Qeuep said:

BUT when I open another program, the mouse just doesn't move !

Not every program allows automation, what's the program name and what is your intention.

 

Edit: are you sure the window is found and script is not waiting for it (WinWaitActive)? Try this:

Opt("MouseCoordMode", 2)

Local $sName = "notepad.exe"
Local $sWinTitle = "Unbenannt - Editor" ;change to your language
$pid = ShellExecute($sName)
MsgBox(0, "Started", "The PID is " & $pid, 2)
Local $i = 0
Do
    $hWND = WinWaitActive($sWinTitle, "", 1) ;waiting one second
    $i = $i + 1
Until $hWND Or $i > 60                      ;1 minute waited

If $hWND Then
    MouseClick("left", 320, 139, 1, 10) ;--> Same thing, tried all coords with Window Info, nothing moves...
Else
    MsgBox(0, $sWinTitle, "not activated")
EndIf

 

Edited by AutoBert

Share this post


Link to post
Share on other sites

@Qeuep

Are you sure that GPUz doesn't have command line options? :)

 

Best Regards.


Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites

I tried, but it looks incredibly difficult...

I can program in C, but never did any AU3 before.

Anyway, this is what I get in Window Info when I click on the button I need :

>>>> Window <<<<
Title:    TechPowerUp GPU-Z 2.9.0
Class:    #32770
Position:    552, 134
Size:    428, 514
Style:    0x94CE0044
ExStyle:    0x00050100
Handle:    0x0004184E

>>>> Control <<<<
Class:    Button
Instance:    5
ClassnameNN:    Button5
Name:    
Advanced (Class):    [CLASS:Button; INSTANCE:5]
ID:    1019
Text:    
Position:    311, 129
Size:    24, 18
ControlClick Coords:    12, 8
Style:    0x5001004B
ExStyle:    0x00000004
Handle:    0x001F0860

>>>> Mouse <<<<
Position:    323, 137
Cursor ID:    0
Color:    0xF0F0F0

 

This is what I tried : ControlClick("TechPowerUp GPU-Z 2.9.0", "", "[CLASS:Button; INSTANCE:5]")

Share this post


Link to post
Share on other sites
41 minutes ago, AutoBert said:

Not every program allows automation, what's the program name and what is your intention.

 

Edit: are you sure the window is found and script is not waiting for it (WinWaitActive)? Try this:

Opt("MouseCoordMode", 2)

Local $sName = "notepad.exe"
Local $sWinTitle = "Unbenannt - Editor" ;change to your language
$pid = ShellExecute($sName)
MsgBox(0, "Started", "The PID is " & $pid, 2)
Local $i = 0
Do
    $hWND = WinWaitActive($sWinTitle, "", 1) ;waiting one second
    $i = $i + 1
Until $hWND Or $i > 60                      ;1 minute waited

If $hWND Then
    MouseClick("left", 320, 139, 1, 10) ;--> Same thing, tried all coords with Window Info, nothing moves...
Else
    MsgBox(0, $sWinTitle, "not activated")
EndIf

 

Having the exact same problem :/

Share this post


Link to post
Share on other sites
9 minutes ago, FrancescoDiMuro said:

@Qeuep

Are you sure that GPUz doesn't have command line options? :)

 

Best Regards.

No, I don't think so... I have already checked

Share this post


Link to post
Share on other sites

@Qeuep

Are you sure? :)


Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites
1 hour ago, FrancescoDiMuro said:

@Qeuep

Are you sure? :)

Well, you cannot do it that way, it doesn't give you the BIOS. I need a .rom format.

(Or perhaps I'm missing something)

Share this post


Link to post
Share on other sites
2 hours ago, Qeuep said:

This is what I tried : ControlClick("TechPowerUp GPU-Z 2.9.0", "", "[CLASS:Button; INSTANCE:5]")

Can you show me the exact button are you trying to press? Attach an image here :)


Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites
10 minutes ago, FrancescoDiMuro said:

Can you show me the exact button are you trying to press? Attach an image here :)

Here you go. I also need a loop to do it on several Gpus, but that's another problem (less complicated I think :P)

 

screen.jpg

Share this post


Link to post
Share on other sites

Are you sure that this doesn't be a solution? :)


Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites

No, unfortunately...

Actually, my program is very long. And it requires the stock .rom of each gpu (which are amd btw)

I use another tool to flash and modify the BIOS.

Share this post


Link to post
Share on other sites

I am having the same exact problem. When I comment out any commands like WinWaitActive or WinActivate then it works fine. If I add any of those two commands it stops working. I know the MouseMove and MouseClick (I am using coordinates for that latter too just for testing) are being executed because they return 1. Also, I have a ConsoleWrite statement after the mouseclick event and that prints. Here is my code.

#include <AutoItConstants.au3>
Opt("WinTitleMatchMode", 2)
$pos = WinGetPos("[MyProgram]")
ConsoleWrite($pos[0])
ConsoleWrite($pos[1])
;WinWaitActive("[MyProgram]")
WinActivate("[MyProgram]")
Sleep(1000)

ConsoleWrite(MouseMove($pos[0]+290, $pos[1]+290))
ConsoleWrite(MouseClick($MOUSE_CLICK_LEFT, $pos[0]+290, $pos[1]+290))
ConsoleWrite('clicked')

 

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...