Jump to content
Sign in to follow this  
Tripredacus

Problem using SplashImageOn()

Recommended Posts

Tripredacus

I haven't much experience in GUIs to this extent, and I am sure that I am missing something here. This is a test script. The programs it will eventually run are not the ones listed, and they will use @SW_HIDE. I ran this against beta compile and there are no errors or warning. After executing the program, neither notepad opens nor does the splash screen appear. Based on this code, I am expecting the following:

1. set the variable for notepad

2. Run notepad, minimized

3. Show a picture while notepad is running

4. When notepad is closed, change var for calc

5. Run calc, and show a different picture while running

6. when calc is closed, set the var to 0

7. The picture should disappear.

What am I missing?

$i = 1
RunWait ("notepad.exe", @SW_MINIMIZE)
$i = 2
RunWait ("calc.exe", @SW_MINIMIZE)
$i = 0

While $i = 1
    $destination = "resources\notepad.jpg"
    SplashImageOn("Splash Screen", $destination,250,50)
WEnd

While $i = 2
    $destination = "resources\calc.jpg"
    SplashImageOn("Splash Screen", $destination,250,50)
WEnd

While $i = 0
    SplashOff()
WEnd

Here is a sample picture that I am using for testing, see attachment.

post-22708-1240598520_thumb.jpg

Edited by Tripredacus

Share this post


Link to post
Share on other sites
martin

I haven't much experience in GUIs to this extent, and I am sure that I am missing something here. This is a test script. The programs it will eventually run are not the ones listed, and they will use @SW_HIDE. I ran this against beta compile and there are no errors or warning. After executing the program, neither notepad opens nor does the splash screen appear. Based on this code, I am expecting the following:

1. set the variable for notepad

2. Run notepad, minimized

3. Show a picture while notepad is running

4. When notepad is closed, change var for calc

5. Run calc, and show a different picture while running

6. when calc is closed, set the var to 0

7. The picture should disappear.

What am I missing?

$i = 1
RunWait ("notepad.exe", @SW_MINIMIZE)
$i = 2
RunWait ("calc.exe", @SW_MINIMIZE)
$i = 0

While $i = 1
    $destination = "resources\notepad.jpg"
    SplashImageOn("Splash Screen", $destination,250,50)
WEnd

While $i = 2
    $destination = "resources\calc.jpg"
    SplashImageOn("Splash Screen", $destination,250,50)
WEnd

While $i = 0
    SplashOff()
WEnd

Here is a sample picture that I am using for testing, see attachment.

You have set the variable $i to be 0 and then put a while loop which only loops while $i = 1 so it doesn't loop.

The variable $i does not work how you must have thought. You need to set the picture then wait untill notepad closes; you don't want to keep repeatedly showing the picture that is already shown.

Maybe this will work but I haven't tried it.

$destination = "resources\notepad.jpg"
SplashImageOn("Splash Screen", $destination,250,50)
RunWait("notepad.exe", @SW_MINIMIZE)

 $destination = "resources\calc.jpg"
SplashImageOn("Splash Screen", $destination,250,50)
RunWait ("calc.exe", @SW_MINIMIZE)

SplashOff()

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites
Tripredacus

Do I need to include the GUIConstants file at the top? I was posting my entire code. I tried something else to at least make the programs open. So at this point (new code sample below), I have the following issues.

1. After I close notepad.exe, calc.exe opens, but it does not open Minimized. Notepad opens minimized.

2. The image does not load at any point.

Dim $destination1, $destination2, $var

$var = 0
RunWait ("c:\windows\notepad.exe", "c:\windows", @SW_MINIMIZE)
RunWait ("c:\windows\system32\calc.exe", "c:\windows\system32", @SW_MINIMIZE)
$var = 0

$destination1 = "resources\notepad.jpg"
$destination2 = "resources\calc.jpg"

While ProcessExists ( "notepad.exe" )
    $var = 1
    SplashImageOn("Splash Screen", $destination1, 250,50)
WEnd

While ProcessExists ( "calc.exe" )
    $var = 2
    SplashImageOn("Splash Screen", $destination2, 250,50)
WEnd

While $var = 0
    SplashOff()
WEnd

Share this post


Link to post
Share on other sites
ResNullius

1. After I close notepad.exe, calc.exe opens, but it does not open Minimized. Notepad opens minimized.

Windows Calc is one of those programs that can't be opened in a minimized (or hidden state)...

2. The image does not load at any point.

You are using RunWait() to launch your programs, and it waits until the launched program is closed before your script continues.

You need to rearrange the logic by moving your While/WEnd loops and using Run() instead of RunWait()

Dim $destination1, $destination2, $var


$destination1 = "resources\notepad.jpg"
$destination2 = "resources\calc.jpg"

$var = 0
Run (@WindowsDir & "\notepad.exe", @WindowsDir, @SW_HIDE)
SplashImageOn("Splash Screen", $destination1, 250,50)
While ProcessExists ( "notepad.exe" )
  ;$var = 1
WEnd

Run (@SystemDir & "\calc.exe", @SystemDir, @SW_HIDE)
SplashImageOn("Splash Screen", $destination2, 250,50)
While ProcessExists ( "calc.exe" )
  ;$var = 2
WEnd


;While $var = 0
    SplashOff()
;WEnd

You can probably then do away with the $var variables (which I've commented out in the above code).

Note: if you are looking for any interaction with the programs you launch (like sending keystrokes or clicking buttons), you'll have to put those actions in the appropriate While loop.

Edit: Moved SplashImageOn() out of the While loops

Edited by ResNullius

Share this post


Link to post
Share on other sites
Tripredacus

OK. Using this example, notepad opens minimized but no splash screen appears. I changed the second program to mspaint.exe which can be minimized. After closing notepad, mspaint does not open. I am not certain how this will translate to the finished product, as the actual programs I am launching are going to be compec driven. Here is the full source (currently) which includes the two real commands which are commented out. This exe was originally just those two lines using RunWait() and it worked fine, but I don't want the users to have ability to close the command prompts that they run in and instead show a picture, which will likely need to be animated.

Dim $destination1, $destination2, $var
;RunWait (@ComSpec & " /c x:\windows\system32\diskpart /s x:\windows\system32\full_diskpart.txt", @SW_HIDE)

;RunWait (@ComSpec & " /c imagex /apply c:\sp1.wim 1 d:", @SW_HIDE)

$destination1 = "resources\diskpart.jpg"
$destination2 = "resources\imagex.jpg"

$var = 0
Run (@WindowsDir & "\notepad.exe", @WindowsDir, @SW_MINIMIZE)
SplashImageOn("Splash Screen", $destination1, 250,50)
While ProcessExists ( "notepad.exe" )
  ;$var = 1
WEnd

Run (@SystemDir & "\mspaint.exe", @SystemDir, @SW_MINIMIZE)
SplashImageOn("Splash Screen", $destination2, 250,50)
While ProcessExists ( "mspaint.exe" )
  ;$var = 2
WEnd


;While $var = 0
    SplashOff()
;WEnd

Share this post


Link to post
Share on other sites
ResNullius

OK. Using this example, notepad opens minimized but no splash screen appears. I changed the second program to mspaint.exe which can be minimized. After closing notepad, mspaint does not open. I am not certain how this will translate to the finished product, as the actual programs I am launching are going to be compec driven. Here is the full source (currently) which includes the two real commands which are commented out. This exe was originally just those two lines using RunWait() and it worked fine, but I don't want the users to have ability to close the command prompts that they run in and instead show a picture, which will likely need to be animated.

Your code basically worked for me but I changed the processExists to look for the actual PID of the program launched rather then just the name of the process:

in your code if a user had an instance of notepad already opened, then closed the new one, the script wouldn't move to the next step because "notepad.exe" process was still running.

I also substituted your jpgs with ones that are in my system folder (WinXP) for testing.

Oh, and I added a small sleep in your While loop to lessen the load on the CPU.

Dim $destination1, $destination2, $var
;RunWait (@ComSpec & " /c x:\windows\system32\diskpart /s x:\windows\system32\full_diskpart.txt", @SW_HIDE)

;RunWait (@ComSpec & " /c imagex /apply c:\sp1.wim 1 d:", @SW_HIDE)

$destination1 = @SystemDir & "\oobe\images\backdown.jpg";"resources\diskpart.jpg"
$destination2 = @SystemDir & "\oobe\images\backoff.jpg";"resources\imagex.jpg"

$pNpad = Run(@WindowsDir & "\notepad.exe", @WindowsDir, @SW_MINIMIZE)
SplashImageOn("Splash Screen", $destination1, 250, 50)
While ProcessExists($pNpad)
    Sleep(10)
WEnd

$pPaint = Run(@SystemDir & "\mspaint.exe", @SystemDir, @SW_MINIMIZE)
SplashImageOn("Splash Screen", $destination2, 250, 50)
While ProcessExists($pPaint)
    Sleep(10)
WEnd


;While $var = 0
SplashOff()
;WEnd

Share this post


Link to post
Share on other sites
Tripredacus

OK this works better. I also found out why my pictures weren't showing up. The script is run from root\fscommand, while the images are in root\resources. So I had to change the paths to "..\resources\image.jpg" in order for my pictures to show up.

Now do you suppose that I can simply put my commented out commands in place of the notepad and paint launches and it will show up properly? Also, a question about the splash screen, can it display animated GIFs and can it also not have the "Splash Image" name at the top of it?

I will experiment some anyways.

EDIT: I answered both questions, thanks for the help.

Edited by Tripredacus

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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.