Jump to content

Mouse click doesn't work if the program isn't open


Recommended Posts

Hey guys,

I struggled last few days because of ControlClick didn't work for me so I tried with MouseClick. I wrote a script that checks if a program is open, if it's not, it opens it. If it's open it uses activate window (because mouseclick doesn't work without it I don't know why) then it click where I want it to.
The problem is, if the program isn't open, it opens it without issues but it doesn't click anywhere on the screen.

If the program is open, it does click the right way.


Where is the issue of mouseclick not working without activate window ?
and the issue of mouseclick not executing if the script doesn't find the program at first and opens it ?

Link to post
Share on other sites

Sorry I'm not used to it.

 

$variable1= TimerInit()


$checkWin = WinExists("Internet Download Manager 6.36")
Sleep(2000)
If $checkWin = 0 Then
   ShellExecute("Internet Download Manager" , "", @DesktopDir)
   Sleep(8000)

ElseIf $checkWin = 1 Then
   sleep(3000)

      WinActivate("Internet Download Manager")
      MouseClick("left" , 680, 457, 1)
      Sleep(1000)
      MouseClick("left" , 1169, 55, 1)


EndIf
$variable2= TimerDiff($variable1)
MsgBox(0, "lesson 3", "beinning time: " & $variable1 & @CRLF & "total time " & $variable2)

 

 

 

If I remove the WinActivate("Internet Download Manager") it won't click even if idm is open

it won't click if idm isn't open even after it opens it

Link to post
Share on other sites

The way you have your code written it will only do one of the two things NOT both

It will either:

1. "If statement"  Open Internet Download Manger if not open

2. "ElseIf Statement"  If it is already open it will click the mouse in the selected coordinates. 

Then if gives you the TimerDiff ()

If I am understanding correctly. You want it to click whether Internet Download Manger was already open or not.

If that is the case you don't need the ElseIf

$variable1= TimerInit()


$checkWin = WinExists("Internet Download Manager 6.36")
    Sleep(2000)

If $checkWin = 0 Then
    Msgbox(0,"","If Statment")
    ;;ShellExecute("Internet Download Manager" , "", @DesktopDir)
        ;;Sleep(8000)
    
ElseIf $checkWin = 1 Then
      Msgbox(0,"","ElseIf Statment")
        ;;Sleep(3000)
      ;;WinActivate("Internet Download Manager")
     ;; MouseClick("left" , 680, 457, 1)
        ;;Sleep(1000)
      ;;MouseClick("left" , 1169, 55, 1)
EndIf

Msgbox(0,"","On to the next line")

$variable2= TimerDiff($variable1)

MsgBox(0, "lesson 3" ,"beinning time: " & $variable1 & @CRLF & "total time " & $variable2)

Try running this code with download manager open and then again with download manager closed. You should get the idea. 

Notice if you run this you will only get either the If statement msgbox or the ElseIF statement msgbox. Not both 

 

Edited by SkysLastChance

Life's simple. You make choices and you don't look back.

Link to post
Share on other sites
1 minute ago, SkysLastChance said:

The way you have your code written it will only do one of the two things NOT both

It will either:

1. "If statement"  Open Internet Download Manger if not open

2. "ElseIf Statement"  If it is already open it will move the mouse. 

Then if gives you the TimerDiff ()

If I am understanding correctly. You want it to click whether Internet Download Manger was already open or not.

If that is the case you don't need the ElseIf

$variable1= TimerInit()


$checkWin = WinExists("Internet Download Manager 6.36")
    Sleep(2000)

If $checkWin = 0 Then
    Msgbox(0,"","If Statment")
    ;;ShellExecute("Internet Download Manager" , "", @DesktopDir)
        ;;Sleep(8000)
    
ElseIf $checkWin = 1 Then
      Msgbox(0,"","ElseIf Statment")
        ;;Sleep(3000)
      ;;WinActivate("Internet Download Manager")
     ;; MouseClick("left" , 680, 457, 1)
        ;;Sleep(1000)
      ;;MouseClick("left" , 1169, 55, 1)
EndIf

Msgbox(0,"","On ot the next line")

$variable2= TimerDiff($variable1)

MsgBox(0, "lesson 3" ,"beinning time: " & $variable1 & @CRLF & "total time " & $variable2)

 

Notice if you run this you will only get either the If statement  msgbox the Else IF msg box. Not both 

Thank you for the answer. I want to check if IDM is open. If it's not then I want it to start.
If it is, I want it to click on a certain pixel.
So the overall goal is to open IDM and click on a certain pixel, if it's open then I only want to click a certain pixel. 

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...