Jump to content

Learn in Autoit


Phlegm
 Share

Recommended Posts

This is my first attempt at scripting; I have used Autoit in the past to automate settings and installing programs. But now I want to try to use Autoit to create a GUI to create a user interface for a user to map a drive. This should be an easy enough exercise and a good way to start learning. So I was able to create a GUI interface using KODA. I read thru some of the tutorials and have general idea of how things work but have no clue as to how to use or implement any of it. So if you all could be so kind as to comment on how to accomplish this.

First off I do not understand how to take input from a user and use it to map a drive or access a share, I understand that you have to first declare a variable like $address to represent the user‘s input. But where do you put it in the script to start mapping the drive? Is there a proper format? Do you use something like “net use Y: \\$address\” ? or do you use DriveMapAdd (“Y:\\$address, 0, “domain\$username”, “password”? I know these are a lot of basic question but I would like to know how to correctly write using Autoit. Also, I see stuff indented in the scripts is there rules to follow on when to do this?

Thanks for your patient on this.

test Logon.au3

Link to comment
Share on other sites

First off I do not understand how to take input from a user and use it to map a drive or access a share, I understand that you have to first declare a variable like $address to represent the user‘s input. But where do you put it in the script to start mapping the drive?

You have an input control, $Address? right? So to read the control we use GuiCtrlRead, which returns the data in the control.

$strAddr = GuiCtrlRead($Address)

Is there a proper format? Do you use something like “net use Y: \\$address\” ? or do you use DriveMapAdd (“Y:\\$address, 0, “domain\$username”, “password”? I know these are a lot of basic question but I would like to know how to correctly write using Autoit. Also, I see stuff indented in the scripts is there rules to follow on when to do this?

Close. To concatenate (join) a string, we use the & operator:

DriveMapAdd("Y:\\" & $strAddr, 0, "Domain\" & $Username, $Password)
Hope that helps ;)

Edit: Forgot to add the closing autoit tag.

Edited by JamesBrooks
Link to comment
Share on other sites

You have an input control, $Address? right? So to read the control we use GuiCtrlRead, which returns the data in the control.

$strAddr = GuiCtrlRead($Address)

Close. To concatenate (join) a string, we use the & operator:

DriveMapAdd("Y:\\" & $strAddr, 0, "Domain\" & $Username, $Password)
Hope that helps ;)

Edit: Forgot to add the closing autoit tag.

Ahh so I need another command to "read" the $addres ($strAddr = GuiCtrlRead($Address)) What is "$straddr"? Is this made up or there some where I readup on it?

Link to comment
Share on other sites

  • Moderators

Phlegm,

You are obviously a complete beginner. Nothing wrong with that - we all started there! :evil:

Reading the first few sections of the Help file (Using AutoIt, Tutorials and the first couple of References) will help you enormously. You should also look at the excellent tutorials that you will find here and here. There are even video tutorials on YouTube if you prefer watching to reading.

Go and study these for a while - you will find that it is not a daunting as you fear. You know where we are when you have some specific questions. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Phlegm,

You are obviously a complete beginner. Nothing wrong with that - we all started there! :evil:

Reading the first few sections of the Help file (Using AutoIt, Tutorials and the first couple of References) will help you enormously. You should also look at the excellent tutorials that you will find here and here. There are even video tutorials on YouTube if you prefer watching to reading.

Go and study these for a while - you will find that it is not a daunting as you fear. You know where we are when you have some specific questions. ;)

M23

Why yes I am, hopefully not for long. Never even thought about checking YouTube for tutorials thanks!

Link to comment
Share on other sites

  • Moderators

Phlegm,

hopefully not for long

With that attitude, I am sure you are correct! :evil:

By the way, when you reply please use the "Add Reply" button at the top and bottom of the page rather then the "Reply" button in the post itself. That way you do not get the contents of the previous post quoted in your reply and the whole thread becomes easier to read. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

By the way, when you reply please use the "Add Reply" button at the top and bottom of the page rather then the "Reply" button in the post itself. That way you do not get the contents of the previous post quoted in your reply and the whole thread becomes easier to read.

If you do want to quote someone, at least strip out the irrelevant bits, or quote bit by bit ;)
Link to comment
Share on other sites

Thanks for pointing me to the Youtube Tutorials. I found them , for me at least, more helpful than some of the other documentations.

I have a question:

On my little excersise I want to create a GUI for a user to enter an IP address or a share name and use it to map a drive. I noticed I can use GUICtrlCreateLabel or GUICtrlCreateInput to create an input box for the information to be used later to map a drive. Please tell me which one I should use and what the diffrences are or perhaps there is a better way.

thanks

Link to comment
Share on other sites

  • Moderators

Phlegm,

If you want user input, the 2 functions you should look at are GUICtrlCreateInput and InputBox.

InputBox does most of the work for you as it produces its own GUI, input area, buttons and labels. However, it is limited to a single input, which means a succession of InputBoxes to get several pieces of user information.

If you want the user to be able to input several pieces of information at the same time then you need to go down the route of creating your own GUI with multiple input controls created with GUICtrlCreateInput - and all the other controls you will need like labels, buttons, etc.

The choice is yours! ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Okay I understand. Is there a special "WinNet_UseConnection" for ID and Password when trying to map a drive? I think I need a #Include <WinNet.au3> to make it work too. Any helpful tips or insight on this for me?

Thanks

Link to comment
Share on other sites

  • Moderators

Phlegm,

Out of my comfort zone now, I am afraid! ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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...