Mettz17

Problem with an example

23 posts in this topic

#1 ·  Posted (edited)

Hi guys, I'm a noob with Autoit :sweating:

I would to know how can I do this example replacing notepad with internet explorer.

Thanks in advance!

Example()

Func Example()
    ; Run Notepad
    Run("notepad.exe")

    ; Wait 10 seconds for the Notepad window to appear.
    Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)

    ; Retrieve the position as well as the height and width of the Notepad window. We will use this when we have to move the window back to the original position.
    Local $aPos = WinGetPos($hWnd)

    ; Move the Notepad to the x, y position of 0, 0 and set the height and width at 200, 200.
    WinMove($hWnd, "", 0, 0, 200, 200)

    ; Wait for 2 seconds to display the new position of the Notepad window.
    Sleep(2000)

    ; Move the Notepad window back to the original position by using the array returned by WinGetPos.
    WinMove($hWnd, "", $aPos[0], $aPos[1], $aPos[2], $aPos[3])

    ; Wait for 2 seconds to display the original position of the Notepad window.
    Sleep(2000)

    ; Close the Notepad window using the handle returned by WinWait.
    WinClose($hWnd)
EndFunc   ;==>Example
Edited by Mettz17

Share this post


Link to post
Share on other sites



Welcome to AutoIt and the forum!

What have you tried so far and what doesn't work then?
BTW: To work with IE AutoIt comes with an UDF for Internet Explorer.

1 person likes this

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

So far everything works and I also really like the ease of the code :D

So I have to download an UDF for Internet Explorer in order to make the program.

And after that, what should I do?

 

Thanks for your help!

Share this post


Link to post
Share on other sites

Welcome to AutoIt and the forum!

What have you tried so far and what doesn't work then?
BTW: To work with IE AutoIt comes with an UDF for Internet Explorer.

I tried replacing notepad with iexplore in the example but that didn't work. I'd like to find the class of Internet Explorer (which I'm starting with 'run') so that I can move it with WinMove.

 

 

Share this post


Link to post
Share on other sites

Mettz17,

Use the AutoIt Window Info tool (...\AutoIt3\Au3Info.exe) to get the class of the IE window (probably IEFrame).

M23

1 person likes this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

What exactly do you want to do? Solve a real problem or just "play" a bit with AutoIt ?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Mettz17,

Use the AutoIt Window Info tool (...\AutoIt3\Au3Info.exe) to get the class of the IE window (probably IEFrame).

M23

Yes, the class is IEFrame!

Thanks a lot! :thumbsup:

Share this post


Link to post
Share on other sites

What exactly do you want to do? Solve a real problem or just "play" a bit with AutoIt ?

I've resolved, thank you anyway for the help:)

Share this post


Link to post
Share on other sites

Cattura88.thumb.JPG.921edc4055ef13318b92

Sorry guys, but there is another thing that i don't know how to do.:>

This is what I want to do, 2 windows of Internet Explorer one beside the other.

run('C:\Program Files\Internet Explorer\IEXPLORE.EXE "http:\\www.google.it"', "")
;WinMove ( "title", "text", x, y [, width [, height [, speed]]] )
 Local $hWnd = WinWait("[CLASS:IEFrame]", "", 0)
 WinMove($hWnd, "", 0, 0, 0, 0)
 Sleep(5000)
 run('C:\Program Files\Internet Explorer\IEXPLORE.EXE "http:\\www.google.it"', "")
Local $hWnd2 = WinWait("[CLASS:IEFrame]", "", 0)
WinMove($hWnd2, "", 0, 0, 500, 500)

But using this code, the program doesn't work. 

Can you help me?

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

I would look for examples in the IE UDF, as you will not be able to get what you want with the Run() function.

 

EDIT, sorry, I thought you wanted one window, with two instances of IE running in them.

Your 0, 0 needs to be changed - to move it over use 0, 300

not awake yet

Edited by nitekram

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites

Mettz17,

At the moment the second WinWait is probably picking up the first window. Get the 2 IE windows open and then use WinList to get the handles of them both - that way you can use these handles directly to move each window to the required position.

M23

1 person likes this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites
run('C:\Program Files\Internet Explorer\IEXPLORE.EXE "http:\\www.google.com"', "")
;WinMove ( "title", "text", x, y [, width [, height [, speed]]] )
 ;Local $hWnd = WinWait("google - internet explorer", "", 0)
 WinWaitActive("Google - Windows Internet Explorer")


Sleep(200)

 WinMove("Google - Windows Internet Explorer", "", 0, 0, 500, 500)

 Sleep(2000)

 run('C:\Program Files\Internet Explorer\IEXPLORE.EXE "http:\\www.yahoo.com"', "")
WinWaitActive("Yahoo - Windows Internet Explorer")
Sleep(200)
WinMove("Yahoo - Windows Internet Explorer", "", 501, 0, 500, 500)

Exit

 


All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites
run('C:\Program Files\Internet Explorer\IEXPLORE.EXE "http:\\www.google.com"', "")
;WinMove ( "title", "text", x, y [, width [, height [, speed]]] )
 ;Local $hWnd = WinWait("google - internet explorer", "", 0)
 WinWaitActive("Google - Windows Internet Explorer")


Sleep(200)

 WinMove("Google - Windows Internet Explorer", "", 0, 0, 500, 500)

 Sleep(2000)

 run('C:\Program Files\Internet Explorer\IEXPLORE.EXE "http:\\www.yahoo.com"', "")
WinWaitActive("Yahoo - Windows Internet Explorer")
Sleep(200)
WinMove("Yahoo - Windows Internet Explorer", "", 501, 0, 500, 500)

Exit

 

Thanks bro, but I don't have to change the Code :mellow:

Share this post


Link to post
Share on other sites

Mettz17,

At the moment the second WinWait is probably picking up the first window. Get the 2 IE windows open and then use WinList to get the handles of them both - that way you can use these handles directly to move each window to the required position.

M23

run('C:\Program Files\Internet Explorer\IEXPLORE.EXE "http:\\www.google.it"', "")
;WinMove ( "title", "text", x, y [, width [, height [, speed]]] )
 Local $hWnd = WinWait("[CLASS:IEFrame]", "", 0)
  $aList[1][1] = $hWnd
 WinMove($aList[1][1], "", 500, 500, 500, 500)
 Sleep(5000)
 run('C:\Program Files\Internet Explorer\IEXPLORE.EXE "http:\\www.google.it"', "")
Local $hWnd2 = WinWait("[CLASS:IEFrame]", "", 0)
$aList[2][2] = $hWnd2
WinMove($aList[2][2], "", 500, 500, 500, 500)

 

In this way?

Share this post


Link to post
Share on other sites

Thanks bro, but I don't have to change the Code :mellow:

You are going to have to change something, to get to work, so Melba23 has one way (which is not what you have), I showed you another, but, the best way is to use the IE UDF, as suggested by Water imho


All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites

Something like this

 

#include <IE.au3>

Local $oIE_First = _IECreate("http:\\www.google.it")

Local $oIE_Second = _IECreate("http:\\www.google.it")

$IE_First = _IEPropertyGet($oIE_First, "hwnd")
$IE_Second = _IEPropertyGet($oIE_Second, "hwnd")

WinMove($IE_First, "", 0, 0, 500, 500)
WinMove($IE_Second, "", 501, 0, 500, 500)

 


All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites

Mettz17,

No, like this:

#include <Array.au3>

; Open the IE windows
Run('C:\Program Files\Internet Explorer\IEXPLORE.EXE "http://www.google.it"', "")
Run('C:\Program Files\Internet Explorer\IEXPLORE.EXE "http://www.bbc.co.uk/news"', "")

; Wait until both windows are open
Do
 $aWinList = WinList("[CLASS:IEFrame]")
Until $aWinList[0][0] = 2

; And here are the windows if you want to look
;_ArrayDisplay($aWinList, "", Default, 8)

; Now move them
WinMove($aWinList[1][1], "", 100, 100, 500, 500)
WinMove($aWinList[2][1], "", 600, 100, 500, 500)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

Mettz17,

No, like this:

#include <Array.au3>

; Open the IE windows
Run('C:\Program Files\Internet Explorer\IEXPLORE.EXE "http://www.google.it"', "")
Run('C:\Program Files\Internet Explorer\IEXPLORE.EXE "http://www.bbc.co.uk/news"', "")

; Wait until both windows are open
Do
 $aWinList = WinList("[CLASS:IEFrame]")
Until $aWinList[0][0] = 2

; And here are the windows if you want to look
;_ArrayDisplay($aWinList, "", Default, 8)

; Now move them
WinMove($aWinList[1][1], "", 100, 100, 500, 500)
WinMove($aWinList[2][1], "", 600, 100, 500, 500)

M23

Why every time I run the program windows change position?

Share this post


Link to post
Share on other sites

Mettz17,

Probably because you have more than those two IE windows open. nitekram's solution is the one you need.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

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