Sign in to follow this  
Followers 0
Xenobiologist

Scite commands on unsaved file

43 posts in this topic

Hi @all,

I know that it is possible to interact with SciTE and I know that I can place commands like :

# 36 OrganizeIncludes
command.36.*.au3="$(autoit3dir)\beta\autoit3.exe" "$(SciteDefaultHome)\OrganizeIncludes\OrganizeIncludes3.7.au3" "$(FilePath)"
command.name.36.*.au3=OrganizeIncludes
command.save.before.36.*.au3=1
command.is.filter.36.*.au3=1
command.shortcut.36.*.au3=Ctrl+Shift+Alt+I

in the SciteUser.properties.

The commands do only work when the file is already saved as an au3 file. (btw. saved at all)

Anybody who can point me to the right direction how to run a command on an unsaved file?

Thanks in advanced!

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites



Jooooooosssss :)


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

On the unsaved file, SciTE doesn't know what file type it is, thus the reason it won't run. I do believe Jos has addressed this in the past with having a default file type when creating a new file. You may need to research SciTE to see how to make a default file type. Personally, I would not recommend changing the way SciTE is setup. It may cause issues later if you update your AutoIt version. If you insist on going down this road, here are some threads that will give you some direction:

http://www.autoitscript.com/forum/index.ph...=Scite++default

http://www.autoitscript.com/forum/index.ph...=Scite++default

Share this post


Link to post
Share on other sites

Another route you may want to add is simply use my SciTE toolbar as a base, and have a button that makes a new file and makes it as a .au3 file. Be a good project for someone to update it. Currently I do not have the time, but the sourcecode is out there.

Share this post


Link to post
Share on other sites

Jooooooosssss :)

I am not on the forum till the evening on workingdays... :)

SciTE's commands are defined per extension or as generic command. The way you defined it's only available for files with ext *.au3.

Now tell me how you expect the command you specified to work on an NONE saved file ? :)

command.36.*.au3="$(autoit3dir)\beta\autoit3.exe" "$(SciteDefaultHome)\OrganizeIncludes\OrganizeIncludes3.7.au3" "$(FilePath)"

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

I am not on the forum till the evening on workingdays... :)

SciTE's commands are defined per extension or as generic command. The way you defined it's only available for files with ext *.au3.

Now tell me how you expect the command you specified to work on an NONE saved file ? :)

command.36.*.au3="$(autoit3dir)\beta\autoit3.exe" "$(SciteDefaultHome)\OrganizeIncludes\OrganizeIncludes3.7.au3" "$(FilePath)"
Okay, :)

This is the way I thought of:

# 37 AU3Save
command.37="$(autoit3dir)\beta\autoit3.exe" "$(SciteDefaultHome)\OrganizeIncludes\AU3Save.au3" "$(FilePath)"
command.name.37.*=AU3Save
command.shortcut.37.*.au3=Ctrl+Shift+Alt+S

But nothing happens. Maybe it is possible to add a command like CTRL+S under filemenu for starting a script (user defined command)

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

This is the way I thought of:

# 37 AU3Save
command.37="$(autoit3dir)\beta\autoit3.exe" "$(SciteDefaultHome)\OrganizeIncludes\AU3Save.au3" "$(FilePath)"
command.name.37.*=AU3Save
command.shortcut.37.*.au3=Ctrl+Shift+Alt+S

But nothing happens. Maybe it is possible to add a command like CTRL+S under filemenu for starting a script (user defined command)

Mega

Do you mean you want to get the save prompt first thus force the file to be saved first before running the program you precified ?

think the program line should look like:

command.37.*="$(autoit3dir)\beta\autoit3.exe" "$(SciteDefaultHome)\OrganizeIncludes\AU3Save.au3" "$(FilePath)"

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Do you mean you want to get the save prompt first thus force the file to be saved first before running the program you precified ?

think the program line should look like:

command.37.*="$(autoit3dir)\beta\autoit3.exe" "$(SciteDefaultHome)\OrganizeIncludes\AU3Save.au3" "$(FilePath)"
Okay, I'll give it a try and report later ...

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

I like that idea, but I was wondering something - when you click on file save, the default types are missing. How does one add them so you have a choice in the save as type dropdown?

99.9% sure that SciTE doesn't support that currently. Think I looked at the source a while ago to see if it could default to *.au3 for the Lite version of SciTE (Scite4AutoIt3) we compile and destribute with the AutoIt3 installer.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Hmmh,

okay doesn't work. My idea was the following: Adding a command to Scite with a shortcut which works even if the file currently editing hasn't been saved. The command starts an au3 Script like (just a beginning)

#include<WindowsConstants.au3>
Opt('MustDeclareVars', 1)
Opt('WinSearchChildren', 1)
Global $SciTECmd = 0

Global $GUI = GUICreate('', 1, 1, 1, 1, $WS_SYSMENU)
Global $Scite_hwnd = WinGetHandle('DirectorExtension')
GUIRegisterMsg($WM_COPYDATA, 'MY_WM_COPYDATA')
Global $My_Dec_Hwnd = Dec(StringTrimLeft($GUI, 2))

Global $path = _getPath()

_saveAU3_SciTE($path)

Func _saveAU3_SciTE($path)
    ConsoleWrite($path & @CRLF)
    ;SendSciTE_Command($My_Dec_Hwnd, $Scite_hwnd, 'saveas:' & $path)
EndFunc   ;==>_saveAU3_SciTE

Func _getPath()
    Local $path = FileSaveDialog("Choose a filename ...", @ScriptDir, "Autoit scripts (*.au3)", 18)
    If @error Then Return 0
    Return $path
EndFunc   ;==>_getPath

; Send command to SciTE
Func SendSciTE_Command($My_Hwnd, $Scite_hwnd, $sCmd)
    $sCmd = ':' & $My_Dec_Hwnd & ':' & $sCmd
    ;ConsoleWrite('-->' & $sCmd & @LF)
    Local $CmdStruct = DllStructCreate('Char[' & StringLen($sCmd) + 1 & ']')
    DllStructSetData($CmdStruct, 1, $sCmd)
    Local $COPYDATA = DllStructCreate('Ptr;DWord;Ptr')
    DllStructSetData($COPYDATA, 1, 1)
    DllStructSetData($COPYDATA, 2, StringLen($sCmd) + 1)
    DllStructSetData($COPYDATA, 3, DllStructGetPtr($CmdStruct))
    DllCall('User32.dll', 'None', 'SendMessage', 'HWnd', $Scite_hwnd, _
            'Int', $WM_COPYDATA, 'HWnd', $My_Hwnd, _
            'Ptr', DllStructGetPtr($COPYDATA))
EndFunc   ;==>SendSciTE_Command

; Received Data from SciTE
Func MY_WM_COPYDATA($hWnd, $msg, $wParam, $lParam)
    Local $COPYDATA = DllStructCreate('Ptr;DWord;Ptr', $lParam)
    Local $SciTECmdLen = DllStructGetData($COPYDATA, 2)
    Local $CmdStruct = DllStructCreate('Char[255]', DllStructGetData($COPYDATA, 3))
    $SciTECmd = StringLeft(DllStructGetData($CmdStruct, 1), $SciTECmdLen)
EndFunc   ;==>MY_WM_COPYDATA

this script deals the saving of the file. That's all. I do not like the possibilty to start another progress (like a toolbar) which does the trick. I want to have it done by Scite itself.

Edit: Okay, it works! But the save dialog from Scite appears first. If you click No there, then the script starts and I can create my own FileSaveDialog.

Mega

Edited by Xenobiologist

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

I don't understand the process you are trying to implement here. How can you have a command executed with as parameter "$(FilePath)" on an unsaved file and then run the script to prompt for the filename and save it ?

Maybe you need to explain the whole process you are thinking of in simple steps for me.


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

I don't understand the process you are trying to implement here. How can you have a command executed with as parameter "$(FilePath)" on an unsaved file and then run the script to prompt for the filename and save it ?

Maybe you need to explain the whole process you are thinking of in simple steps for me.

Ok, no problem on that. The goal is avoiding to type .au3 when creating a (au3)file in Scite.

What I got till now is:

I've written a script called AU3save.au3. I want to start this script via shortcut or scitemenucommand within SciTE. The script copies the source code from the edit pane in Scite, opens a FileSaveDialog where the extension .au3 will be automatically added when save button is clicked and then it saves the file with .au3. This way there will be no need anymore to always add .au3 to files created via Scite.

I think I can get it working, but there is still one thing left. Starting my AU3Save.au3 through SciTE command Tools --> AU3Save, Scite first asks, whether I want to save the file. If I click no then my script is started and everything can go on as desinged.

Any better now?

Currently I'm looking through the Globalproperties whether I can avoid that "Save changes to (Untitles)?" dialog.

Mega

Edited by Xenobiologist

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

I've been doing lots of research on this. I'm thinking until Neil makes a change or tells me a solution to the problem, the best method is to simply make a menu item that runs a script. This script would opens a file dialog window that has the au3 as default. Once you name the file, the file is open in the SciTE Editor. The toolbar I have for SciTe would be a good way to go on this.

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

I don't see why Neil wouldn't accept a well-written patch that adds a property that SciTE can use to populate the SaveAs dialog. Automatically appending a file extension is a bit tricky - at first glance the lpstrDefExt of OPENFILENAME looks useful until you realize you can't save files without an extension; you can only save files with a custom extension or the default. You could perhaps do something clever like extract the first extension in the filter and append it to the end of the file name if a filter is selected and nFileExtension (of OPENFILENAME) points to the NULL terminator.

For what it's worth, Visual Studio 2008 (and probably all versions) automatically appends the first file extension in the filter when no extension is typed. For example, this is the C++ filter: (*.cc;*.cpp;*.cxx;*.tlh;*.tli). When you try to save a file without an extension, it automatically appends .cc to the file (even though .cpp is more widely used for C++ files on Windows).

So, I think that Neil would accept a well-written patch which adds a save.filter property and also automatically deduces the file extension from the first extension in the selected filter when no extension is manually typed. Jos, you could probably knock this out in less than an hour.

Edited by Valik
Grammar

Share this post


Link to post
Share on other sites

That would be great. Let me know if you are working on it and when you guess you get it working.

Thanks!

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

One of the reasons I'm wary of Scite (I use UltraEdit) is that it's unclear which menu functions work within the editor, and which act on the disk file itself.

If you don't know the ins and outs of this, it's extremely easy to trash your saved copy of the script, without even realising you've done so.

Perhaps it would be better if functions which act directly on the disk file (and hence have an irreversible effect) were grouped separately from those which edit the open document.

Share this post


Link to post
Share on other sites

One of the reasons I'm wary of Scite (I use UltraEdit) is that it's unclear which menu functions work within the editor, and which act on the disk file itself.

The difference between the 2 editors cannot be different because running the same tools from UltraEdit need to be saved before processing just like they need to within Scite as they process the file on disk. The inbuilt commands within both editors AFAIK work within the buffers in memory like so many other editors available for use. So the difference you mention seems odd to comprehend as being a valid reason to argue against Scites' behaviour.

Share this post


Link to post
Share on other sites

.. Jos, you could probably knock this out in less than an hour.

Don't hold your breath :)

That would be great. Let me know if you are working on it and when you guess you get it working.

Thanks!

Mega

I didn't read any promises in Valik's reply ... but you never know with him ...

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

I admit it is terribly tempting to do this as I don't think it would take too long, but, if I'm going to put that kind of time into something, I should really work on one of the many out-standing AutoIt bugs or some of the other behind-the-scenes projects I am in the middle of.

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