Jump to content
Sign in to follow this  
Sprinto

Running exe in a GUI window?

Recommended Posts

Sprinto

Hello Guys.

I know how to run a IE in a GUI window, but is there a way to run ex. solitaire in a gui window?

- Sprinto

Share this post


Link to post
Share on other sites
Michel Claveau

Hi!

Sorry, I do not have Solitaire.

But, I have Calculator.

Therefore, a exemple of code:

#include<guiconstants.au3>
#include<WindowsConstants.au3>

;opt("WinTitleMatchMode",3)
$hGui1 = GUICreate("GUI Embedder",400,400,-1,-1,BitOr($GUI_SS_DEFAULT_GUI ,$WS_CLIPCHILDREN))
GUISetState(@SW_SHOW)

$title="Calculatrice"     ;french
$title="Calculator"       ;english


ShellExecute("calc.exe")
WinWait($title,"",4)
$Handle = WinGetHandle($title)
$origParent = DllCall("user32.dll", "int", "SetParent", "hwnd", $Handle, "hwnd",$hGui1)
sleep(24)
WinSetState($Handle,"",@SW_MAXIMIZE)

While 1
    $nMSG = GUIGetMsg()    
    Switch $nMSG
  Case $GUI_EVENT_CLOSE
   ;set child back To Original parent or it will be destroyed with ouyr window
   DllCall("user32.dll", "int", "SetParent", "hwnd", $Handle, "hwnd", $origParent[0])
   Sleep(24)
   WinClose($Handle)
   Exit
EndSwitch
sleep(12)
WEnd
Edited by Michel Claveau

Share this post


Link to post
Share on other sites
Sprinto

This works fine :).. But any way to start the calc inside the GUI so it does not have to move it first?

Share this post


Link to post
Share on other sites
Emiel Wieldraaijer

This works fine :) .. But any way to start the calc inside the GUI so it does not have to move it first?

Haven't tested it but

Run calc with @SW_HIDE flag

Edited by Emiel Wieldraaijer

Best regards,Emiel Wieldraaijer

Share this post


Link to post
Share on other sites
Emiel Wieldraaijer

Haven't tested it but

Run calc with @SW_HIDE flag

I've tried it and Calc isn't a good example ... use another program.. sol.exe for example

The shellexecute command should be like this

ShellExecute("sol.exe", "", @TempDir, "open", @SW_HIDE)


Best regards,Emiel Wieldraaijer

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.