CT

open window application from "open dialogue box" and make it always on top?

3 posts in this topic

Hi guys!  Here is my code:


 

Spoiler

 

#include <GUIConstantsEx.au3>
#include <StructureConstants.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>

AutoItSetOption ( "MustDeclareVars", 1)



;==========code here============
_Run_file()

Func _Run_file()
   
    ; path of window application
    Local $_duong_dan_file_name = FileOpenDialog("chọn tập tin của bạn",  @WindowsDir & "\", "All (*.*)", $FD_FILEMUSTEXIST)
   
    ; execute it
    local $_app_run = ShellExecute($_duong_dan_file_name,"","","",@SW_MAXIMIZE)
   
    ; make it "always on top"
    WinSetOnTop($_app_run, "", $WINDOWS_ONTOP)

EndFunc

 

WinSetOnTop Func doesn't work! :(

Share this post


Link to post
Share on other sites



It couldn't work:

Quote

ShellExecute

Runs an external program using the ShellExecute API.

Return Value

Success: the PID of the process that was launched. Or -1 if there was no PID available.
Failure: 0 and sets the @error flag to non-zero.
Quote

WinSetOnTop

Change a window's "Always On Top" attribute.

WinSetOnTop ( "title", "text", flag )

Parameters

title The title/hWnd/class of the window to change. See Title special definition.
text The text of the window to change. See Text special definition.
flag Determines whether the window should have the "TOPMOST" flag set.
    $WINDOWS_NOONTOP (0) = remove on top flag
    $WINDOWS_ONTOP (1) = set on top flag

Constants are defined in "AutoItConstants.au3".

because a pid is not the needed hwnd.

1 person likes this

Share this post


Link to post
Share on other sites
8 minutes ago, AutoBert said:

It couldn't work:

because a pid is not the needed hwnd.

I get it, thanks Bert :) 

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