Sign in to follow this  
Followers 0
nwbyy

Called window goes to background.

14 posts in this topic

#1 ·  Posted

Hello.

My GUI is for a old PC running under windows XP.

3 buttons are to call "mouse options", "keyboard options" and the "audio mixer".

I didn't find out how to call them directly, so I created shortcuts and tried call them.

run ( "C:\My GUI\mouse.lnk" )

But nothing happened.

So I did a .bat file like this for the 3 links:

@echo off
cd "C:\My GUI\" & start mouse.lnk
exit

And called the bat file instead:

run ( "C:\My GUI\mouse.bat" )

With the "audio mixer" it works.

But the "mouse options" and "keyboard options" windows stay in foreground for about 2 seconds, and then they go background.

Or my GUI goes foreground...

Is it possible to open a window and tell him "stay in foreground"??

Or to tell the GUI to "stay in background"?...

 

Thanks a lot.

Share this post


Link to post
Share on other sites



#2 ·  Posted

Hi @nwbyy, and welcome to the AutoIt forum :)

Did you test WinSetOnTop() yet?

With this function, you can set the window on top of other windows.

Post your entire code, so we can try to help you as much as we can :)


Click here to see my signature:

Spoiler

I will always thank you for the time you spent for me.
I'm here to ask, and from your response, I'd like to learn.
By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

Share this post


Link to post
Share on other sites

#3 ·  Posted

Hi. Thanks.

I will try by myself with WinSetOnTop()

If I don't get it right, I'll post my code.

:-)

Share this post


Link to post
Share on other sites

#4 ·  Posted

:)


Click here to see my signature:

Spoiler

I will always thank you for the time you spent for me.
I'm here to ask, and from your response, I'd like to learn.
By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

Share this post


Link to post
Share on other sites

#5 ·  Posted

Okay, I don't get behind :-(

Here is my code (sorry, some words are in french).
I deleted the lines having nothing to do with this topic.

#include <ColorConstantS.au3>
#include <GUIConstants.au3>

; Page 1
$page_1_GUI = GUICreate ("Menu options", @DesktopWidth , @DesktopHeight, 0 , 0 ,$WS_POPUP)
GUISetState(@SW_SHOW, $page_1_GUI)

; Couleur de fond
GUISetBkColor($COLOR_BLACK)

; Insertion des images
GUICtrlCreatePic("C:\My GUI\Logos options\Logo RETOUR.jpg", 37, 551, 0, 0)
GUICtrlCreatePic("C:\My GUI\Logos options\Logo CLAVIER.jpg", 233, 211, 0, 0)
GUICtrlCreatePic("C:\My GUI\Logos options\Logo SOURIS.jpg", 625, 211, 0, 0)

; Boutons
$b_4 = GUICtrlCreateButton("RETOUR", 42, 680, 155, 25)
$b_6 = GUICtrlCreateButton("CLAVIER", 238, 340, 155, 25)
$b_14 = GUICtrlCreateButton("SOURIS", 630, 340, 155, 25)

While 1
   $msg = GUIGetMsg()
    Select
         Case $msg = $GUI_EVENT_CLOSE
            Exit
         Case $msg = $b_4
            Exit
         Case $msg = $b_6
            run ( "C:\My GUI\LNK_keyboard.bat" )
         Case $msg = $b_14
            run ( "C:\My GUI\LNK_mouse.bat" )
EndSelect
WEnd

The LNK_keyboard.bat file:

@echo off
cd "C:\My GUI\" & start keyboard.lnk
exit

keyboard.lnk goes to "control pannel/ keyboard properties".

 

The LNK_mouse.bat file:

@echo off
cd "C:\My GUI\" & start mouse.lnk
exit

mouse.lnk goes to "control pannel/ mouse properties".

With this, the "mouse properties" and "keyboard properties" windows only stay in foreground for about 2 seconds.

 

I found out that "mouse properties" under windows XP can be called by typing "control main.cpl".

And "keyboard properties" by typing "control main.cpl keyboard" (this one does not work with me :-( )

Here:

http://www.geekgirls.com/2010/03/xp-control-panel-shortcuts/

 

So I tried with:

Case $msg = $b_14
            run ( "control main.cpl" )

But the problem remains the same, window goes background after 2 secs.

I tried to add:

Case $msg = $b_14
            $winMouse = run ( "control main.cpl" )
            WinSetOnTop ( $winMouse, "", $WINDOWS_ONTOP )

This opens the "mouse properties" window, but closes my GUI.
Of course there is a problem with my WinSetOnTop () line, but I can't figure it out...

 

Any help would be great.
Thanks in advance.

Share this post


Link to post
Share on other sites

#6 ·  Posted

for shortcut (.ink file) run by ShellExecute()

if use RUN need get file path with FileGetShortcut()


Regards,
 

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Thanks. I'll try.

Edited by nwbyy

Share this post


Link to post
Share on other sites

#8 ·  Posted

shortcut:

Run('control main.cpl,@0') ; opens the Mouse Properties
 Run('control main.cpl,@1') ; opens the Keyboard Properties


 


Regards,
 

Share this post


Link to post
Share on other sites

#9 ·  Posted

With

Run('control main.cpl,@0') ; opens the Mouse Properties
 Run('control main.cpl,@1') ; opens the Keyboard Properties

the windows still go background. They must be a little shy :lol:

But using ShellExecute() pointing to the links, it works like a charm:

ShellExecute ( "C:\My GUI\mouse.lnk" )
ShellExecute ( "C:\My GUI\keyboard.lnk" )

Thank you!
What would I do without you?? ;)

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Can you try this code and tell me, it works on your Apps or not?

ShellExecute('control', 'main.cpl,@0') ; opens the Mouse Properties
ShellExecute('control', 'main.cpl,@1') ; opens the Keyboard Properties

 

Edited by Trong
Spell

Regards,
 

Share this post


Link to post
Share on other sites

#11 ·  Posted

Yes I tried.
The windows open... and go background...

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

I'll do with

ShellExecute ( "C:\My GUI\mouse.lnk" )

That's perfect for me ;-)

Edited by nwbyy

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

try new solution without ink:
 

#include <ColorConstantS.au3>
#include <GUIConstants.au3>

; Page 1
Global $page_1_GUI = GUICreate("Menu options", @DesktopWidth, @DesktopHeight, -1, -1, $WS_POPUP)
; Couleur de fond
GUISetBkColor($COLOR_BLACK)
; Insertion des images
GUICtrlCreatePic("C:\My GUI\Logos options\Logo RETOUR.jpg", 37, 551, 0, 0)
GUICtrlCreatePic("C:\My GUI\Logos options\Logo CLAVIER.jpg", 233, 211, 0, 0)
GUICtrlCreatePic("C:\My GUI\Logos options\Logo SOURIS.jpg", 625, 211, 0, 0)
; Boutons
Global $b_4 = GUICtrlCreateButton("RETOUR", 42, 680, 155, 25)
Global $b_6 = GUICtrlCreateButton("CLAVIER", 238, 340, 155, 25)
Global $b_14 = GUICtrlCreateButton("SOURIS", 630, 340, 155, 25)

GUISetState(@SW_SHOW, $page_1_GUI)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $b_4
            Exit
        Case $b_6
            ShellExecute('control', 'main.cpl,@0') ; opens the Mouse Properties
;~          Run('control main.cpl,@0') ; opens the Mouse Properties
            WinSetOnTop($page_1_GUI, "", 0)
            WinSetOnTop("Mouse Properties", "", 1)
            WinActive("Mouse Properties")
            WinActivate("Mouse Properties")
        Case $b_14
            ShellExecute('control', 'main.cpl,@1') ; opens the Keyboard Properties
;~          Run('control main.cpl,@1') ; opens the Keyboard Properties
            WinSetOnTop($page_1_GUI, "", 0)
            WinSetOnTop("Keyboard Properties", "", 1)
            WinActive("Keyboard Properties")
            WinActivate("Keyboard Properties")
    EndSwitch
WEnd

 

 

Edited by Trong
THE END

Regards,
 

Share this post


Link to post
Share on other sites

#14 ·  Posted

Thank you.
But I'm afraid the problem comes back with this new code.
It'll be smarter to do without creating a .lnk file. That's right.

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  
Followers 0