Jump to content

Problem with an example


Mettz17
 Share

Recommended Posts

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
Link to comment
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.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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.

 

 

Link to comment
Share on other sites

  • Moderators

Mettz17,

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

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

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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • Moderators

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

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

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

Link to comment
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:

Link to comment
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?

Link to comment
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

Link to comment
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

Link to comment
Share on other sites

  • Moderators

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

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

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)

Thank you! This code works in the way I want :)

Link to comment
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?

Link to comment
Share on other sites

  • Moderators

Mettz17,

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

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