Jump to content

Can you Pause Screen Refresh While Script Executes?


 Share

Recommended Posts

I wrote a few simple scripts that perform actions. But I don't want to see windows flashing or the mouse pointer move while it is being executed. I was wondering if there was a way to first turn off display refresh and then turn display refresh back on after the script executes? Of course, even if that is possible, then there is a concern about something going wrong and the screen refresh being turned back on in the event of a crash/other.

Link to comment
Share on other sites

  • Moderators

Are you manually causing a screen refresh, or is it just something you're experiencing during the course of your script running. As is almost always the case, it is a little difficult to provide advice when you don't provide any code to show us what you're doing.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Here is a simple example. This just restores a few windows that may be minimized, but the screen flashes while doing it.

Send("{ALTDOWN}{TAB}{ALTUP}")
Send("{ALTDOWN}{TAB}{TAB}{ALTUP}")
Send("{ALTDOWN}{TAB}{TAB}{TAB}{ALTUP}")

The goal is to not experience that flashing effect by somehow pausing the screen refresh

Edited by LT2000
Link to comment
Share on other sites

  • Moderators

What is the name of the window? You should be able to use WinActivate instead of Send commands, with no flashing.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

A couple issues:

- The window name is unknown. This just restores all existing windows, regardless of the name. There may be multiple instances of a program as well. It actually looks like this in reality. Pretty crude, but gets the job done.

Send("{ALTDOWN}{TAB}{ALTUP}")
Send("{ALTDOWN}{TAB}{TAB}{ALTUP}")
Send("{ALTDOWN}{TAB}{TAB}{TAB}{ALTUP}")
Send("{ALTDOWN}{TAB}{TAB}{TAB}{TAB}{ALTUP}")
Send("{ALTDOWN}{TAB}{TAB}{TAB}{TAB}{TAB}{ALTUP}")
Send("{ALTDOWN}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{ALTUP}")
Send("{ALTDOWN}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{ALTUP}")
Send("{ALTDOWN}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{ALTUP}")
Send("{ALTDOWN}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{ALTUP}")
Send("{ALTDOWN}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{ALTUP}")
Send("{ALTDOWN}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{ALTUP}")
Send("{ALTDOWN}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{ALTUP}")
Send("{ALTDOWN}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{ALTUP}")

- I have another script that would benefit from a non-refresh, which I am nearly certain there is no other way to perform other than Send key commands.

Edited by LT2000
Link to comment
Share on other sites

WinList and WinActivate in a loop would be a lot more efficient.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

  • Moderators

I agree with KingBob, WinList if you have a bunch of windows. And if the window title is unknown, what criteria are you using to identify it, so you're restoring the correct window - text? position? etc? There are very few cases when Send is your only answer.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

WinList and WinActivate in a loop would be a lot more efficient.

I don't disagree, but like I mentioned, that was just an example. There is another script which must use Send key commands that has the same issue. I am actually more interested in the other one, but this one is easier to demonstrate as an example.

Edited by LT2000
Link to comment
Share on other sites

- Its not evasion. I was trying to make it simple and was using that as an example, as requested. As I feared, things then got specific and transitioned into how to solve a problem that didn't need solving. Hence, the reason why I did not post a specific example initially.

- Here is the real problem: In Win10 (which many people don't have yet and why I didn't post an example for), I am trying to access various virtual desktops. The only way to do that is to use WIN+CTRL+arrow. If there is another way to access these virtual desktops, I am all ears. But I can't find anything in AutoIT. Perhaps in a later build though.

- And if there is no way to pause the screen refresh, the can't that just be said since that was the original question? I simply don't know if this is even possible.

Edited by LT2000
Link to comment
Share on other sites

  • Moderators

So, basically this thread is a duplicate of your other thread on this topic? If you didn't get any replies on that first one, why not bump it rather than start a second (much more confusing) topic?

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Oops, yes you are right. I thought I had phrased that differently, but it is basically the same. I should have bumped it. In this thread, I was trying to be more specific with the title since I had given up on doing something more "native" to address it. Pausing the screen refresh is a last resort option, not a primary option. In the other thread, I was still looking for a native option really.

Edited by LT2000
Link to comment
Share on other sites

This is my best idea but it wont help with any kind of virtual desktop setup as anything you display on screen is bound to change with the desktop (I would assume)

 

Of course if this actually does what you want, save to @TempDir and change as needed.

#Include <ScreenCapture.au3>

;Current Desktop Image
_ScreenCapture_Capture(@DesktopDir & "\bg.bmp")
;Display Image
SplashImageOn("", "bg.bmp", @DesktopWidth, @DesktopHeight, -1, -1, 1)
;Do your "stuff"
ShellExecute("Notepad.exe")
Sleep(5000)
;Desktop Reappears After "stuff"

 

Edited by ViciousXUSMC
Link to comment
Share on other sites

You took this thread in a totally different direction, and until you told us what you're really attempting it made more sense. If you had started with the actual issue you were facing rather than trying to tell us it was related to activating windows in a sequence, we could have gotten here sooner.

There is no key sequence or API currently that allows you to choose a specific virtual desktop in Windows 10, you have to cycle through them.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

  • 2 weeks later...

Just curious...is it possible to minimize all windows (on all virtual desktops in Win10) and then restore just the windows that were not originally minimized?

The thought here is that you would (1) minimize all windows (2) use keyboard shortcuts to navigate to desktop (3) restore the window "state" as is was before script was run.

I suspect this would minimize the apparent "flashing" since the flashing is really just the fact that you are viewing all the open windows on the virtual desktops. If you are just seeing the background, it might look OK.

Link to comment
Share on other sites

  • Moderators

You would follow the same general course, get a list of windows and then cycle through them with WinGetState to find out which are Minimized and which are not.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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