PDA

View Full Version : Interfacing ThinBasic with Windows



justin045
22-11-2024, 21:02
Hello everybody. ;)


The TB project I'm working on today requires to open a Windows explorer by the script on certains conditions.

The need has two cases :

Open explorer window and continue the script regarless of what is done in this window by the user.

Open explorer window and wait until user closes the window


In the first case, the window may be closed by the user without interferring with TB script or stay active after the end of the creating script.
Script and explorer window are completely independent.

I used

Pid = OS_Shell( command_exec_path & command_opt & file_to_work_on , %OS_WNDSTYLE_NORMAL, %OS_SHELL_ASYNC)

to call a program (in this case :Acrobat_reader ) and continue execution of script.
The script uses
OS_ProcessKillById(PiD) to stop the program, sometimes it is unuseful as the users already closed the window.

I also used
%OS_SHELL_SYNC if waiting was necessary.


NOTE:

I noticed with 'Sysinternals-Process-explorer' that EXPLORER.EXE has only ONE instance, regardless of the number of explorer windows open.
And when I bundle a script, at the end of succesful bundling, a popup message invites to browse the executable directory.
If I click on 'YES' , a new process'EXPLORER.EXE' is created, independent of the explorer lauched at booting.
Closing the window makes process die, and killing the process closes the window and nothing is done to other explorer windows :D

The creator of BUNDLE could help. :confused:


Many thanks for help.

Justin

ErosOlmi
23-11-2024, 12:32
Hi Justin

In thinBundle ... at the end of a successfully bundled operation ... if you press Yes to open Explorer window I just to something like that:


OS_Shell("EXPLORER.EXE /n, /e, " + $Dq + gBundle_Application_ExePath + $Dq, %OS_WNDSTYLE_NORMAL)


Next thinBasic will have some new functions working on Explorer, for example to execute Explorer in a specific folder and SELECT a specific file.

If you need something else please let me know.

Ciao
Eros

chameau
28-11-2024, 01:28
Hi Justin

In thinBundle ... at the end of a successfully bundled operation ... if you press Yes to open Explorer window I just to something like that:


OS_Shell("EXPLORER.EXE /n, /e, " + $Dq + gBundle_Application_ExePath + $Dq, %OS_WNDSTYLE_NORMAL)


Next thinBasic will have some new functions working on Explorer, for example to execute Explorer in a specific folder and SELECT a specific file.

If you need something else please let me know.

Ciao
Eros

Hi Justin, Eros

The response from Eros is right, but sometime earlier I have to lauch 'explorer' from a C program and I seen then that I was unable
to create an instance and wait until it is closed.
It appears to me that the initial created process whose Pid is returned, opens a subprocess and dies.
So the calling program/script goes on.

As I see in your post, you use 'Sysinternals-Process-explorer' , I invite you to enable the column named 'command line' in the tab 'process image'.
You will see that the parameter passed to the running explorer process has nothing to do with the ones you passed in your callin code !

When I was trying to resolve the issue, I have some interesting infos on the followig web pages :


https://superuser.com/questions/21394/explorer-command-line-switches
https://superuser.com/questions/1519562/way-to-open-a-folder-from-windows-explorer-in-cmd-exe-under-windows-10-with-one
http://smallvoid.com/article/windows-explorer.html
http://davesamuels.com/utils/Explorer%20-%20Command%20Line%20Options.txt
https://www.sevenforums.com/general-discussion/111184-windows-explorer-command-line.html

Perhaps will you find something in these forum pages ??


Best regards and good luck


Chameau