Jump to content

Script not working


onlineth
 Share

Go to solution Solved by Prime03,

Recommended Posts

Hi, I know that I am missing something obvious but the $Username seems to come up with numbers

#include <ie.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ###
$Form1 = GUICreate("BSG", 285, 313, 192, 124)
$Group1 = GUICtrlCreateGroup("Group1", 0, 0, 281, 305)
$Username = GUICtrlCreateInput("", 20, 72, 249, 21)
$Label1 = GUICtrlCreateLabel("Username", 116, 48, 52, 17, $SS_CENTER)
$Password = GUICtrlCreateLabel("Password", 117, 112, 50, 17, $SS_CENTER)
$PasswordLabel = GUICtrlCreateInput("", 20, 144, 249, 21)
$Label2 = GUICtrlCreateLabel("Number of Random Searches", 70, 212, 144, 17, $SS_CENTER)
$NOS = GUICtrlCreateInput("90", 132, 240, 25, 21)
$Label3 = GUICtrlCreateLabel("BSG", 41, 16, 203, 29)
GUICtrlSetFont(-1, 16, 400, 0, "MS Sans Serif")
$Start = GUICtrlCreateButton("Start", 105, 272, 75, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###



While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
         Case $Start
            ExitLoop
    EndSwitch
WEnd
MsgBox(0,'test',$Username)

$oIE = _IECreate ("http://login.live.com")
$oForm = _IEFormGetObjByName ($oIE, "f1")
$oQuery1 = _IEFormElementGetObjByName ($oForm, "i0116")
$oQuery2 = _IEFormElementGetObjByName ($oForm, "i0118")
_IEFormElementSetValue ($oQuery1,$Username)
_IEFormElementSetValue ($oQuery2,$PasswordLabel)
$oButton=_IEGetObjById($oIE,"idSIButton9")
_IEAction ($oButton, "click")
_IELoadWait($oIE,0)

online.png?theme=dark profile for Tom on Stack Exchange, a network of free, community-driven Q&A sites 

scientia potentia est

Link to comment
Share on other sites

  • Solution

 

Hi, I know that I am missing something obvious but the $Username seems to come up with numbers

#include <ie.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ###
$Form1 = GUICreate("BSG", 285, 313, 192, 124)
$Group1 = GUICtrlCreateGroup("Group1", 0, 0, 281, 305)
$Username = GUICtrlCreateInput("", 20, 72, 249, 21)
$Label1 = GUICtrlCreateLabel("Username", 116, 48, 52, 17, $SS_CENTER)
$Password = GUICtrlCreateLabel("Password", 117, 112, 50, 17, $SS_CENTER)
$PasswordLabel = GUICtrlCreateInput("", 20, 144, 249, 21)
$Label2 = GUICtrlCreateLabel("Number of Random Searches", 70, 212, 144, 17, $SS_CENTER)
$NOS = GUICtrlCreateInput("90", 132, 240, 25, 21)
$Label3 = GUICtrlCreateLabel("BSG", 41, 16, 203, 29)
GUICtrlSetFont(-1, 16, 400, 0, "MS Sans Serif")
$Start = GUICtrlCreateButton("Start", 105, 272, 75, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###



While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
         Case $Start
            ExitLoop
    EndSwitch
WEnd
MsgBox(0,'test',$Username)

$oIE = _IECreate ("http://login.live.com")
$oForm = _IEFormGetObjByName ($oIE, "f1")
$oQuery1 = _IEFormElementGetObjByName ($oForm, "i0116")
$oQuery2 = _IEFormElementGetObjByName ($oForm, "i0118")
_IEFormElementSetValue ($oQuery1,$Username)
_IEFormElementSetValue ($oQuery2,$PasswordLabel)
$oButton=_IEGetObjById($oIE,"idSIButton9")
_IEAction ($oButton, "click")
_IELoadWait($oIE,0)

 

When your calling $username in your _IEFormElementSetValue, you're actually getting the ControlID of the GUICtrlInput that you created on your GUI. 

You need to use

$somevar = GUICtrlRead($username) 

to actually get the string in the input field.

It's also kind of suspicious to have a 'Number of Searches' field while on a webmail login page. 

Edited by Prime03
Link to comment
Share on other sites

When your calling $username in your _IEFormElementSetValue, you're actually getting the ControlID of the GUICtrlInput that you created on your GUI. 

You need to use

$somevar = GUICtrlRead($username) 

to actually get the string in the input field.

It's also kind of suspicious to have a 'Number of Searches' field while on a webmail login page. 

I'm sorry, I am very new at this, what do you mean?

online.png?theme=dark profile for Tom on Stack Exchange, a network of free, community-driven Q&A sites 

scientia potentia est

Link to comment
Share on other sites

 

Hi, I know that I am missing something obvious but the $Username seems to come up with numbers

#include <ie.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ###
$Form1 = GUICreate("BSG", 285, 313, 192, 124)
$Group1 = GUICtrlCreateGroup("Group1", 0, 0, 281, 305)
$Username = GUICtrlCreateInput("", 20, 72, 249, 21)
;$Username now contains the ControlID used to reference this GUI control, not the contents of the input itself
$Label1 = GUICtrlCreateLabel("Username", 116, 48, 52, 17, $SS_CENTER)
$Password = GUICtrlCreateLabel("Password", 117, 112, 50, 17, $SS_CENTER)
$PasswordLabel = GUICtrlCreateInput("", 20, 144, 249, 21)
$Label2 = GUICtrlCreateLabel("Number of Random Searches", 70, 212, 144, 17, $SS_CENTER)
$NOS = GUICtrlCreateInput("90", 132, 240, 25, 21)
$Label3 = GUICtrlCreateLabel("BSG", 41, 16, 203, 29)
GUICtrlSetFont(-1, 16, 400, 0, "MS Sans Serif")
$Start = GUICtrlCreateButton("Start", 105, 272, 75, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###



While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
         Case $Start
            ExitLoop
    EndSwitch
WEnd
MsgBox(0,'test',$Username)

$YourVariable = GUICtrlRead($Username)

$oIE = _IECreate ("http://login.live.com")
$oForm = _IEFormGetObjByName ($oIE, "f1")
$oQuery1 = _IEFormElementGetObjByName ($oForm, "i0116")
$oQuery2 = _IEFormElementGetObjByName ($oForm, "i0118")
_IEFormElementSetValue ($oQuery1,$YourVariable)
_IEFormElementSetValue ($oQuery2,$PasswordLabel)
$oButton=_IEGetObjById($oIE,"idSIButton9")
_IEAction ($oButton, "click")
_IELoadWait($oIE,0)
Edited by Prime03
Link to comment
Share on other sites

BTW: Could you please use more meaningful thread titles? The better you describe your problem the more people you will attract to your thread :)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

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