Full screen image display

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
obfusc88
Pro Scripter
Posts: 89
Joined: Wed Mar 14, 2007 6:22 pm

Full screen image display

Post by obfusc88 » Thu Aug 04, 2011 7:08 pm

Using Macro Scheduler 11.1.20 on Windows 7 Professional 32 bit system.

I just used the following code, a modification of what Marcus had provided in 2007. But it is causing me problems. Here is the code:

Code: Select all

GetScreenRes>w,h
Dialog>Dialog2
   Caption=MyDialog
   Width=10
   Height=10
   Top=0
   Left=0
   Image=q:data\images\brightlight.jpg,0,0,w,h
EndDialog>Dialog2

Let>style=0
LibFunc>user32,SetWindowLongA,sres,DIALOG2.HANDLE,-16,style
LibFunc>user32,ShowWindow,sres,DIALOG2.HANDLE,3

Show>Dialog2
Wait>3
I was single stepping with F8. The end result was my image on the screen, in upper left corner with white space filling the rest of the screen. Worse than that, was that my screen was totally locked up and I could not get back to my desktop and Macro Scheduler. I thought the 3 was minutes vs. seconds, but still had the same picture after 5 mins. I discovered that using ALT-TAB I could get back to other applications, but not to Macro Scheduler. Opened Task Manager, killed Macro Scheduler and thought all was good. Now all of my macros are not listed in Macro Scheduler. Luckily they were still there, but I had to go to each group and do Import Macro process.

Don't want to do this again, so the script is commented out until a solution is found. I wonder about a few possible issues ....
1. Do I need to convert the file from jpg to bmp?
2. Do I need to change the size of the image .. if yes how to determine the desired size?
3. When importing macros, I could not find the path for importing settings macros.dat. Where are they located on this system? Different groups have different paths to other workstations and/or central directory. Is there a different dat file for each group? Installation was to normal defaulted paths, set up for all users if a choice was there.
4. If locked up on the image again, how can I break into the script and stop it, or remove the image on the screen?
5. Enhancement request: How about a command like ShowImage>, similar to PlayWav>? Parameters could be path, resolution, size, position?

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Wed Aug 10, 2011 12:39 pm

I thought the 3 was minutes vs. seconds, but still had the same picture after 5 mins.
Since you were single stepping through the editor, you displayed the dialog the dialog took focus so your subsequent F8 press fell on the dialog rather than the editor. you never got to the wait>3 line which is wait three seconds.

Your script works as expected for me. I suspect it is working for you but you have different expectations.
Lets examine the script one section at a time.

- Your first line sets variables "w" and "h" to the width and height of your screen.
- Next you create a dialog. All looks good so far.
- First line after the dialog block sets the variable "Style" to 0.
- Now we get to the fun stuff, your windows API calls. SetWindowLongA "Changes an attribute of the specified window." (Quote from Microsoft) The window being altered is your dialog and the attribute being altered is the "GWL_STYLE" attribute. (The "-16" in the SetWindowLongA line.) The "GWL_STYLE" attribute is being changed to zero. In other words you are removing all style settings from the dialog. It will become a plain grey box with no border, no icons and no title bar.
- The next API call is for ShowWindow. ShowWindow... well...er...um... shows a window. But it allows you to show the window with specified settings. In your case you have set it to "3". Looking that up on the Microsoft page for ShowWindow we find that if the "nCmdShow" parameter is 3 your window will be maximized.
- Your next line is Show> which is normally how we would display a dialog but since your previous line was the ShowWindow API your dialog is already displayed making this line extraneous.
- Your last line waits 3 seconds and seems to do that flawlessly.

If we revisit the "Image" line in the dialog block we can see that you have called a jpg file. "Image" will display either jpeg (jpg) or Windows bitmap (bmp) files. In My Opinion, one is not more desirable than the other for simple display. Next you set the upper left corner of the Image display to be the 0,0 position within the working area of the dialog. Last you set the width and height of the Image display area to be equal to the size of your screen as determined by the GetScreenRes> function. All in all this script works exactly as I would expect. But I've done this trick quite often.

To address your questions.

1) Jpgs and Bmps are equally reliable for display.

2) The desired image size is up to you. What do you want to see? This script should display any jpg or bmp image from 1 pixel by 1 pixel up to whatever your screen resolution is set to.

3) I'm not certain I understand the question but I do understand what happpened. Occasionally, if you use taskmanager to shut down mshed.exe, your macros.dat file will be erased. Macros.dat is where all of the settings are kept that display on the Macro Scheduler main menu. My suggestion is to back up the folder that contains your macros.dat file every day.

4) All you did was display a full sized window on the screen. Unfortunately the window does not have the icon for closing a window. Fortunately the key combination ALT+F4 will close the window.

5) Enhancement requests are more noticeable in the Enhancement Suggestions forum

PS
In version 12 this can be done without the API calls.
The following will display the specified image file in a autosized, borderless dialog that will center itself on the screen.

Code: Select all

Dialog>Dialog2
object Dialog2: TForm
  AutoSize = True
  BorderStyle = bsNone
  Position = poScreenCenter
  object MSImage1: tMSImage
    Left = 0
    Top = 0
    AutoSize = True
  end
end
EndDialog>Dialog2

SetDialogProperty>Dialog2,msImage1,LoadImage,q:data\images\brightlight.jpg
Show>dialog2

Wait>3
Edit - script snippet above modified to prevent "lockup" per jpuziano's suggestion.
Last edited by JRL on Wed Aug 10, 2011 6:49 pm, edited 1 time in total.

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Wed Aug 10, 2011 6:41 pm

Hi JRL,

I am running the latest MS v 12.1.10 and I ran your code above, substituting a path and filename of a jpg image on my machine... and while it worked, the image did not go away when the script finished. In fact, the script seems not to finish at all because:

- hovering the mouse pointer over the systray icon, a tooltip is displayed that says the script is still running

- the Maro Scheduler main window is not responding... I can't edit or run a different script

- interestingly, its not a total lockup, the "About" selection from the systray right-click menu still works and the "Quick Launch..." menu selection comes up (though I did not try to execute another macro at this point)

I was about to kill msched.exe using the "End Process" button in Task Manager but then I thought... what if I loose all my macro hot keys and settings... it is a pain to have to re-import macros and re-set the hot keys, etc. and I thought a more gentle way to do this would be to just re-start Windows itself...

... more gentle because (and I was hoping) maybe on a restart, msched.exe will "see" that the machine is restarting and be able to save its .dat file before closing and I would not have to go through that hassle...

...well, it all turned out OK, I did not loose any settings but this was unsettling.

Reading the Help File on the Show> command, I see that when you provide a result variable like you did... the dialog is shown modal.
Help File for Show> wrote:Show>DialogName[,Result]
If a result variable is provided in Result the dialog is shown modal.
There are no controls on the image dialog so how would anyone be able to stop the script or make the image go away?

Marcus - when I right-click the Macro Scheduler systray icon and click Stop, why can I not stop JRL's script? Hitting Shift + ESC also did not stop that macro - why not?

JRL - No doubt you only meant to provide a snippet and didn't intend anyone to run your code as posted however I did and others might... so for those that just want to see how this works (v12 and above required) then run the version below instead:

Code: Select all

Dialog>Dialog2
object Dialog2: TForm
  AutoSize = True
  BorderStyle = bsNone
  Position = poScreenCenter
  object MSImage1: tMSImage
    Left = 0
    Top = 0
    AutoSize = True
  end
end
EndDialog>Dialog2

SetDialogProperty>Dialog2,msImage1,LoadImage,q:data\images\brightlight.jpg
Show>dialog2

Wait>3
The image will be displayed then the script will end and the image will go away after 3 seconds.

Thanks for sharing this JRL... great code for a splash screen image for a compiled app or just for displaying images when necessary.

Take care
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Wed Aug 10, 2011 6:54 pm

4) All you did was display a full sized window on the screen. Unfortunately the window does not have the icon for closing a window. Fortunately the key combination ALT+F4 will close the window.
As stated above, use ALT+F4.

It was meant as a snippet but I should not have made it modal since it is oversimplified to the point of having no built in controls. Altered the script to match what you posted.

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Wed Aug 10, 2011 7:59 pm

Hi JRL,

Ahh yes, I see ALT-F4 does work to close the dialog... sorry I missed that in your original post.

However, that does not explain why neither of the following can terminate the script:

a) press SHIFT+ESC

b) right click the macro scheduler systray icon, click "Stop"

Moreover, clicking Stop "seems" to work... in that it is clickable and thereafter, in the right-click menu it appears grayed out... so you'd think it worked... but no, the dialog is still visible...

...and MS itself seems to know the script is still running because when I mouseover the systray icon, the tooltip tells me its still running...

...and, I can no longer access any other macros from the MS main window.

Why can't I terminate your original script using either method above?

Question for Marcus:

Hi Marcus. I know the dialog in JRL's original script (that he's now changed) was originally "modal" but since I am running it from the Macro Scheduler main window, I feel it would be nice if Macro Scheduler itself still had the ability to terminate the script. Perhaps MS could send the ALT-F4 to the modal dialog when someone tried to stop the script using a) or b) above? Your thoughts?
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Aug 24, 2011 8:54 am

jpuziano wrote:Marcus - when I right-click the Macro Scheduler systray icon and click Stop, why can I not stop JRL's script? Hitting Shift + ESC also did not stop that macro - why not?
I don't know. It works for me.

Oh wait, you mean if I open the dialog modal instead. Well, it's modal, and that's the nature of modal dialogs. It's how any application with a modal dialog would behave.
, I feel it would be nice if Macro Scheduler itself still had the ability to terminate the script. Perhaps MS could send the ALT-F4 to the modal dialog when someone tried to stop the script using a) or b) above? Your thoughts?
I don't know if that is possible (or always desirable) but we can look into it.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Wed Aug 24, 2011 2:57 pm

mtettmar wrote:
jpuziano wrote:, I feel it would be nice if Macro Scheduler itself still had the ability to terminate the script. Perhaps MS could send the ALT-F4 to the modal dialog when someone tried to stop the script using a) or b) above? Your thoughts?
I don't know if that is possible (or always desirable) but we can look into it.
Thanks for looking into this... and if it turns out this is not possible or if it would have negative side-effects in some cases... then we'll just have to remember that any modal dialogs we create should have controls that can close them... or else ALT-F4 is going to be the only way to do that... short of using Task Manager to kill the process or restarting the machine. Thanks again Marcus and take care.
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts