Save file Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
trojankungen
Posts: 2
Joined: 18 Jan 2022, 04:10

Save file

Post by trojankungen » 27 Jan 2022, 14:07

Hello,
First of all need to say sorry for my english. But hopefully most of you can understand my question:
I wrote a script to save a file when i press in menu "Save" i get window of library where i want to save, but when i press cancel window disappears and i get message box about do i want to save "Yes" or "No". When i press "Yes" afterwards then script detects button "Yes" and save file without getting window and to get a choose where i want to save it or name the file. Can someone tell me how to solve this problem?
I need to get it when i press "yes" again to get window up to select name and folder where i want to save the file.

Code: Select all

FileSelectFile, OutputVar, S
Msgbox 0x4,, Do you want save?
IfMsgBox Yes, {   
    Splitpath, OutputVar, , , ext
    (ext = "")
    OutputVar .= ".doc"
    MsgBox % OutputVar
    FileAppend, , %OutputVar%
    return
} 
IfMsgBox No, {
    MsgBox, Document was not saved
}
return

amateur+
Posts: 655
Joined: 09 Oct 2021, 15:43

Re: Save file

Post by amateur+ » 27 Jan 2022, 15:13

The script you've posted isn't as you described it.
Have found any drawback in my code or approach? Please, point it out. /The moderator ordered to remove the rest of the signature, I had obeyed.
And I really apologize for our russian president. Being a citizen of an aggressor country is very shameful. Personally I tried to avoid this trying to defend elections from fraud being a member of the election commission of one of the precincts but only was subjected to a hooligan attack and right before the vote count was illegally escorted from the polling station and spent the night behind bars (in jail) in a result of illegal actions of corrupt policemen.

trojankungen
Posts: 2
Joined: 18 Jan 2022, 04:10

Re: Save file

Post by trojankungen » 27 Jan 2022, 15:23

amateur+ wrote:
27 Jan 2022, 15:13
The script you've posted isn't as you described it.
Yeah, you'r right, but this is a part of the script. I have a GUI window with the menu bar most like all software window, with settings, archive and so on.

User avatar
boiler
Posts: 16965
Joined: 21 Dec 2014, 02:44

Re: Save file  Topic is solved

Post by boiler » 27 Jan 2022, 15:32

Other fixes beyond when the file selector box was canceled because you had other things wrong:

Code: Select all

FileSelectFile, OutputVar, S
if ErrorLevel {
	MsgBox, No file was selected
	ExitApp
}
Msgbox 0x4,, Do you want save?
IfMsgBox Yes, {   
    Splitpath, OutputVar,,,, NameNoExt
	OutputVar := NameNoExt ".doc"
    MsgBox % OutputVar
    FileAppend, Some text to be saved, %OutputVar%
    return
} 
IfMsgBox No, {
    MsgBox, Document was not saved
}
return
It will save it in the script's directory. Your description makes it sound like a directory selector box would need to be added so you can select where to save the newly named file. That would be easy to add.

BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Save file

Post by BoBo » 27 Jan 2022, 19:04

@trojankungen - Kinda senseless bc once a file gets selected you already know that you wanna save it (you're even using the commands "S"ave-option), otherwise you would skip the file selection dialog, right? An additional "Please confirm again that you wanna save the file" bears the risk to be seen as an annoying nag-screen.

Post Reply

Return to “Ask for Help (v1)”