Is it possible write a PB program that can be used to open a mouse selected file on the main 'Desktop?
For example:
When you click on an object in a 'PB window', you get a response reaction.
For instance if you click on a ButtonGadget, it activates to what ever you have it programmed to do.
On the main 'Desktop screen'. When ever you click on a text file (txt), it opens up under the default program of notepad.
Is there any way to do something like that using PB? Perhaps by setting your PB program, as that files default program?
Here's the problem. I use notepad a lot for scratch notes when working on a project. But if not careful, I found that
you can actually open the same file more then once. This is not good, as you must always be sure to save the last edited
text file 'after closing' the other open files, or you chance losing every thing you edited on that file if you saved the wrong
one first. Believe me, it's happened to me, and on occasion, and too often, that I have lost everything I changed or edited!
That's why I was looking at the possibility if it were possible to do this using PB.
PB has some excellent code for detecting if a file is already opened, which could either be used to warn you of the fact,
or actually possibly switch to the one that is already opened. I would like to write a PB program that could be setup as the
default program for a text file, to first check if the file is already open and do the above, or if not, to use notepad to
open it and then exit my PB program.
Thanks for any input or ideas.
Using PB to open a mouse selected file on Desktop
Re: Using PB to open a mouse selected file on Desktop
You can create a PB program that is launched instead of notepad, and it should be able to test if it's open (either checking task manager or keeping track).
However, I think it might be faster to use notepad++. It has safeguards for this, and it's already done.
However, I think it might be faster to use notepad++. It has safeguards for this, and it's already done.
Last edited by Tenaja on Fri Dec 18, 2020 5:48 am, edited 1 time in total.
Re: Using PB to open a mouse selected file on Desktop
Search the forum for Monitor directory changes
It may help
It may help
Egypt my love
Re: Using PB to open a mouse selected file on Desktop
Hi yrreti, Why use notepad? You must have dozens of oddly named files all over the place, which
sems like a nightmare in progress. Apart from being inefficient.
Have a look at MemPad by Horst Schaeffer, which I believe is written in PureBasic.
It is an excellent program and allows you to easily arrange your information for future reference.
Everything all in one place. A brilliant solution to create your own reference source.
www.horstmuc.de/win/
This will give you far more control over what I think you want to do.
sems like a nightmare in progress. Apart from being inefficient.

Have a look at MemPad by Horst Schaeffer, which I believe is written in PureBasic.
It is an excellent program and allows you to easily arrange your information for future reference.
Everything all in one place. A brilliant solution to create your own reference source.
www.horstmuc.de/win/
This will give you far more control over what I think you want to do.

If it's falling over......just remember the computer is never wrong!
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: Using PB to open a mouse selected file on Desktop
Sounds like you want to right-click a desktop icon and be given open options, which you would like to use your PB program to work with. My answer will be based on that assumption.
If I right-click a desktop icon I get this contextmenu:

One of the options is "Upload to lloydsplace.com" which is accomplished thus:
This code is run as part of the setup routine for my QuickUpload project: https://www.lloydsplace.com/QuickUpload.zip
If I missed the boat on this one, just smile and call me adorable.
If I right-click a desktop icon I get this contextmenu:

One of the options is "Upload to lloydsplace.com" which is accomplished thus:
Code: Select all
Declare ContextMenuAddall (programfriendlyname$,programpath$, state=1, includefolders=1)
OpenPreferences(GetHomeDirectory()+"quickupload.ini")
OpenWindow(0,0,0,320,240,"FTP QuickUpload",$CA0001)
TextGadget(0,20,40,100,20," Server")
TextGadget(1,20,70,100,20," Username")
TextGadget(2,20,100,100,20," Password")
TextGadget(3,20,130,100,18," Folder")
TextGadget(4,20,160,100,20," Port")
StringGadget(5, 100,38,180,18,ReadPreferenceString("server",""))
StringGadget(6, 100,68,180,18,ReadPreferenceString("user",""))
StringGadget(7, 100,98,180,18,ReadPreferenceString("password",""))
StringGadget(8, 100,128,180,18,ReadPreferenceString("folder",""))
StringGadget(9, 100,158,40,18,ReadPreferenceString("port","21"))
CheckBoxGadget(10,168,158,120,20,"Passive Mode")
SetGadgetState(10,ReadPreferenceLong("passive", 1))
ClosePreferences()
FrameGadget(20,15,10,290,185,"Configuration")
ButtonGadget(11,15,210,290,22,"Save Settings")
SetActiveGadget(5)
quit=0
Repeat
ev=WaitWindowEvent()
Select ev
Case #PB_Event_CloseWindow
quit=1
Case #PB_Event_Gadget
Select EventGadget()
Case 11
CreatePreferences(GetHomeDirectory()+"quickupload.ini")
WritePreferenceString("server", GetGadgetText(5))
WritePreferenceString("user", GetGadgetText(6))
WritePreferenceString("password", GetGadgetText(7))
WritePreferenceString("folder", GetGadgetText(8))
WritePreferenceString("port", GetGadgetText(9))
WritePreferenceLong("passive", GetGadgetState(10))
ClosePreferences()
ContextMenuAddAll("Upload to "+GetGadgetText(5),GetHomeDirectory()+"quickupload.exe", 1, 1)
quit=1
EndSelect
EndSelect
Until quit
End
Procedure ContextMenuAddAll(programfriendlyname$, programpath$, state=1, includefolders=1)
; netmaestro November 2007
Protected key.l = #HKEY_CLASSES_ROOT
Protected path$ = "*\shell\"+programfriendlyname$+"\command"
Protected value$ = ""
Protected string$ = programpath$+" "+Chr(34)+"%1"+Chr(34)
Protected keyresult.l
If state
RegCreateKey_(key,@path$,@keyresult)
RegSetValueEx_(keyresult,@value$,0,#REG_SZ,@string$,StringByteLength(string$)+SizeOf(Character))
If includefolders
path2$ = "directory\shell\"+programfriendlyname$+"\command"
RegCreateKey_(key, @path2$, @keyresult)
RegSetValueEx_(keyresult,@value$,0,#REG_SZ,@string$,Len(string$))
EndIf
Else
path$ = "*\shell\"+programfriendlyname$+"\command"
RegDeleteKey_(key,@path$)
path$ = "*\shell\"+programfriendlyname$
RegDeleteKey_(key,@path$)
If includefolders
path2$ = "directory\shell\"+programfriendlyname$+"\command"
RegDeleteKey_(key,@path2$)
path2$ = "directory\shell\"+programfriendlyname$
RegDeleteKey_(key,@path2$)
EndIf
EndIf
RegCloseKey_(keyresult)
EndProcedure
If I missed the boat on this one, just smile and call me adorable.
BERESHEIT