Jump to content

Script just dies in the middle


Recommended Posts

So I'm trying to write a script that will disable one of my monitors. I'm running an nVidia video card, and the nVidia Control Panel software has a function to set up different profiles. I'm trying to write a script that will open the nVidia Control Panel, load the profile, then close the nVidia Control Panel. The problem is, halfway through the scrip, it just seems to die.

Here's my script

; Open the nVidia control panel
Run("nvcplui.exe")

; Once the control panel is open, send a control+P and control+L for Profile > Open
WinWaitActive("NVIDIA Control Panel")
Sleep(1500)
Send("!p")
Send("l")

; Once the "Load Desktop Profile" dialog box is open, type the profile name into
; the text box and hit <ENTER>
Sleep(100)
WinWaitActive("Load Desktop Profile")
Send("single_display.nvp")
Send("{ENTER}")

; Confirmation box will come up asking if you're sure.  Defaults to "Yes", so hit enter
Sleep(2000)
;WinWaitActive("NVIDIA Control Panel", "Loading this profile will replace")
Send("!y")
;ControlClick("NVIDIA Control Panel", "", "[CLASS:Button; TEXT:&Yes; INSTANCE:1]")
;Send("{ENTER}")

This isn't the whole script, but this is where it dies. I get to this window:

Posted Image

And for some reason I can't get it to click the "Yes" button. As you can see from the commented out lines in my script above, this is what I've tried:

  • Hitting {ENTER}(as you can see in the picture, it defaults to "Yes" being active"
  • Sending Alt+Y to hit "Yes"
  • Putting a delay on it to give the window time to open, then hitting {ENTER} or Alt+Y
  • Having it click the Yes button
  • Hitting the {TAB} button twice to highlight "No" then "Yes", then hitting {ENTER}

I've tried all of the above while using the "WinWaitActive" command or just waiting for several seconds to make sure the window has time to pop up, or doing both.

What is happening is that when it gets to the dialog box shown in the screen shot above, the window just disappears] as if I either hit "No" or just closed the window. This is driving me nuts, I appreciate any help anybody can offer.

Thanks

Edited by jjmiller
Link to comment
Share on other sites

Try

; Open the nVidia control panel
Run("nvcplui.exe")

; Once the control panel is open, send a control+P and control+L for Profile > Open
$NVCP = WinWait("NVIDIA Control Panel"); get the window handle
Winactivate($NVCP)
WinWaitActive($NVCP)
;Sleep(1500)
Send("!p")
Send("!l") ; if this is meant to be control+1

; Once the "Load Desktop Profile" dialog box is open, type the profile name into
; the text box and hit <ENTER>
Sleep(100)
WinWaitActive("Load Desktop Profile")
Send("single_display.nvp")
Send("{ENTER}")

; Confirmation box will come up asking if you're sure.  Defaults to "Yes", so hit enter
Sleep(2000)
;WinWaitActive("NVIDIA Control Panel", "Loading this profile will replace")
Send("!y")
;ControlClick("NVIDIA Control Panel", "", "[CLASS:Button; TEXT:&Yes; INSTANCE:1]")
;Send("{ENTER}")
Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

So I've tried both of the methods above with no luck. The mouseclick almost worked, except that the window seems to not always open in the same place, so I can't give it any good coordinates. The method that JohnOne suggested gave me the same results I've been getting.

I'm starting to wonder if LordBlackout is right and nVidia is doing something that stops the script, though I can't imagine why they'd do that.

Any other ideas?

Link to comment
Share on other sites

  • Developers

Show us what au3info tells you about the popup window and add some debugging to your script to make sure you know what line it is at when the popup windows is shown.

This is one option at your disposal:

Opt("TrayIconDebug", 1)         ;0=no info, 1=debug line info

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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