Jump to content

Custom Macros'?


Recommended Posts

(Hope this isn't in the wrong section this time.....)

Is there a way to create macro's?

I know there's existing macros like:

@DesktopDir
@FavoritesDir
@UserProfileDir
@AppDataDir
@CommonFilesDir

& many more

However, is there a simpler way to access directory inside without extending it?

@userProfiles & "Downloads\"
@userProfiles & "Links\"
@userProfiles & "Music\"

Well, the temp solution I've come up with is simple...

$DownloadsDir = @userProfiles & "Downloads\"
$LinksDir = @userProfiles & "Links\"
$MusicDir = @userProfiles & "Music\"

 

Link to comment
Share on other sites

  • Developers
10 minutes ago, faustf said:

explain much better your problem why you want create a macro?

The basic question is: How can I get the users "Downloads" directory from the system?  

@Purity8, Your posted syntax is wrong as it is missing the backslash between the Marcor value and the string. ;) 

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

the names of the user special folders are language-dependent, so e.g. the Downloads folder may not always be titled "Downloads".

you can retrieve the correct folders either from the registry or by using the function _WinAPI_ShellGetKnownFolderPath().

 

 

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

2 hours ago, faustf said:

explain much better your problem why you want create a macro?

Many people out there have thousands of images. I'm sure they have their own way of organizing it too.  This will make saving to specific locations much easier.

You want to save in Downloads directory? No problem. Pictures? Yes can do. Even more specific? You want to download pictures of your favorite artist joining (/hosting) an event? Yup, that's covered. You even want to download files into your portable external drive? I'm sure that'll work out fine.

Not only do I want to create more macro's, but I'll be making my own .au3 reference file eventually too, so my life will be easier.

 

@Jos, Yes, thank you. I know. I haven't gotten used to fully typing it out from a developer perspective..and..I still miss a forward & backslash here and there. This was also the first time I started using AutoIt, which isn't that long ago really.

As former coder, I know how to find out what's wrong. After going through all the trouble (not knowing how to use "@error, still don't quite get it yet, but I'll get there) printing out all the output does help identify the problem.

I've literally included those 2 statements into my script not too long ago before making this topic (I kid you not):

MsgBox($MB_SYSTEMMODAL, "Caution:", "Please review CAREFULLY! Note that there's no missing forward or backslashes on websites and directory names.")

; Displays all Variables in Message Box for confirmation
MsgBox($MB_SYSTEMMODAL, "Website 1 Breakdown:", "Count : " & $iCount & @CRLF & @CRLF & "Format : " & $sFormat & @CRLF & @CRLF & "Img : " & $sImg & @CRLF & @CRLF & "Url_1    : " & $sUrl_1 & @CRLF & @CRLF & "Full Link : " & $sUrl_1 & $sImg)
MsgBox($MB_SYSTEMMODAL, "Website 2 Breakdown:", "Count : " & $iCount & @CRLF & @CRLF & "Format : " & $sFormat & @CRLF & @CRLF & "Img : " & $sImg & @CRLF & @CRLF & "Url_2  : " & $sUrl_2 & @CRLF & @CRLF & "Full Link : " & $sUrl_2 & $sImg)
MsgBox($MB_SYSTEMMODAL, "Website 3 Breakdown:", "Count : " & $iCount & @CRLF & @CRLF & "Format : " & $sFormat & @CRLF & @CRLF & "Img : " & $sImg & @CRLF & @CRLF & "Url_3  : " & $sUrl_3 & @CRLF & @CRLF & "Full Link : " & $sUrl_3 & $sImg)
MsgBox($MB_SYSTEMMODAL, "Website 4 Breakdown:", "Count : " & $iCount & @CRLF & @CRLF & "Format : " & $sFormat & @CRLF & @CRLF & "Img : " & $sImg & @CRLF & @CRLF & "Url_4  : " & $sUrl_4 & @CRLF & @CRLF & "Full Link : " & $sUrl_4 & $sImg)
MsgBox($MB_SYSTEMMODAL, "Website 5 Breakdown:", "Count : " & $iCount & @CRLF & @CRLF & "Format : " & $sFormat & @CRLF & @CRLF & "Img : " & $sImg & @CRLF & @CRLF & "Url_5  : " & $sUrl_5 & @CRLF & @CRLF & "Full Link : " & $sUrl_5 & $sImg)

I literally just understood how to use if-then with "iAnswer & msgbox" involved an hour ago...certainly different from C/C++. I was mixing them up with AutoIt's loopiing functions.  In C/C++, Do, While, Do-While and Else/If  are essentially If-Then function

@orbs, That's true too. I know FireFox & Chrome set Downloads as default. I don't know about other browsers. I'll check that out, thanks.

Edited by Purity8
removed duplicate code section
Link to comment
Share on other sites

you can create  your constant path and inclue directly in yor file project

example:

file Purity8ConstantMacro.au3 inside of them you write a  path

like global const $Download= "......."

etc..

after when you create your script in top of it

write

include "Purity8ConstantMacro.au3"

ofcoure a copy of Purity8ConstantMacro.au3 must be present in the same directory of new project

after include inside a second prog you can call $Download directly

@error you can see in help F1  here you can find some example 

Link to comment
Share on other sites

  • Developers

When you are looking for the default Windows "Downloads" folder setting you can do that with:

#include <WinAPIShellEx.au3>
$DownLoadsFldr = _WinAPI_ShellGetKnownFolderPath($FOLDERID_Downloads)
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $DownLoadsFldr = ' & $DownLoadsFldr & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console

Jos 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

@faustf, Thanks. I would eventually make something like that when I understood more how to use AutoIt. I've looked around, Local Const isn't used much, most use Global Const. Are there cases where Local Const is used?

@Jos, Thank you. I took a peak at the WinAPI_ShellEx page mentioned above as well.

Edited by Purity8
Link to comment
Share on other sites

@faustf, Thanks, I'll go take a look.

edit: Oh, that's the page I bookmarked and use. I only read what I needed to know at the time and even the word "Const" didn't make sense to me after reading that page (even with the example in mind).

It does make more sense now however.

Before I had read this page, I did my own testing as well.

I used For loop (found in AutoIt's examples of do-for-while of counting) and examined the use of both local & global variables...I already had basic knowledge that Global variables were more flexible and Local variables are fixed.

Edited by Purity8
Added more info
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...