Jump to content
Sign in to follow this  
onlineth

Script not working

Recommended Posts

onlineth

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

Share this post


Link to post
Share on other sites
Prime03

 

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
  • Like 1

Share this post


Link to post
Share on other sites
onlineth

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

Share this post


Link to post
Share on other sites
Prime03

 

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
  • Like 1

Share this post


Link to post
Share on other sites
onlineth

 

 

ok, i get it, thank you so much for your help!!!


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

scientia potentia est

Share this post


Link to post
Share on other sites
Prime03

No problem, my best advice is to keep the Function reference open while you're coding (hit F1 in Scite), you will get a lot farther a lot faster!

Every time you need to do something, read the reference.

Edited by Prime03

Share this post


Link to post
Share on other sites
water

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 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - 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
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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
Sign in to follow this  

×