Jump to content
Sign in to follow this  
mrgy05

Creating a custom search result

Recommended Posts

mrgy05

Firstly, please accept my apology in advance regarding how novice I am with AutoIT, I am trying the best I can :)

I am attempting to create a custom search engine for an eBay search. All of the criteria has been set and parsed in URL (see $URL1 + $URL2). The end result of this that I am aiming for is to open a new browser with the search term put into $Search inserted into the middle of $URL1 and $URL2.

I thought maybe I should be using an array instead? But I am still unsure on how to combine the variables put into the new browser.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3> 

SearchEbay()

Func SearchEbay()
    Local $msg

   $URL1 = "http://www.ebay.com/sch/i.html?_nkw="
   $URL2 = "&_in_kw=1&_ex_kw=&_sacat=0&_mPrRngCbx=1&_udlo=0.01&_udhi=0.01&LH_Auction=1&LH_Time=1&_ftrt=901&_ftrv=5&LH_NOB=1&_sabdlo=0&_sabdhi=1&_samilow=&_samihi=&LH_FS=1&_sadis=200&_fpos=&_fsct=&LH_SALE_CURRENCY=0&_sop=12&_dmd=1&_ipg=200"

    GUICreate("Cheap eBay Searching", 300, 100) ; will create a dialog box that when displayed is centered
    $Search = GUICtrlCreateInput ( "" ,10, 50)
    $Submit = GUICtrlCreateButton( "Submit", 220, 47)   
    GUISetState(@SW_SHOW) ; will display an empty dialog box

    ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()

                Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
             Case $msg = $Submit
                
                _IECreate($URL1 & $Search & $URL2, 1, 1, 0)
            EndSelect


        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
    GUIDelete()
EndFunc

Share this post


Link to post
Share on other sites
Sori

Where exactly are you having an issue?

(If I'm reading correctly, you don't know how to open a new window with the URL created)


If you need help with your stuff, feel free to get me on my Skype.

I often get bored and enjoy helping with projects.

Share this post


Link to post
Share on other sites
mrgy05

Where exactly are you having an issue?

(If I'm reading correctly, you don't know how to open a new window with the URL created)

 

Exactly, I am not getting the middle result from $Search when opening the URL. If the current code is ran the resulting URL will get a "3" searched which is acting as if $Search = "" (blank)

Share this post


Link to post
Share on other sites
mrgy05

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3> 

SearchEbay()

Func SearchEbay()
    Local $msg

   $URL1 = "http://www.ebay.com/sch/i.html?_nkw="
   $URL2 = "&_in_kw=1&_ex_kw=&_sacat=0&_mPrRngCbx=1&_udlo=0.01&_udhi=0.01&LH_Auction=1&LH_Time=1&_ftrt=901&_ftrv=5&LH_NOB=1&_sabdlo=0&_sabdhi=1&_samilow=&_samihi=&LH_FS=1&_sadis=200&_fpos=&_fsct=&LH_SALE_CURRENCY=0&_sop=12&_dmd=1&_ipg=200"

    GUICreate("Cheap eBay Searching", 300, 100) ; will create a dialog box that when displayed is centered
    $Search = GUICtrlCreateInput ( "" ,10, 50)
    $Submit = GUICtrlCreateButton( "Submit", 220, 47)   
    GUISetState(@SW_SHOW) ; will display an empty dialog box

    ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()

                Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
             Case $msg = $Submit
                
                $ReadSearch = GUICtrlRead ($Search)
                
                _IECreate($URL1 & $ReadSearch & $URL2, 1, 1, 0)
            EndSelect


        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
    GUIDelete()
EndFunc

I figured it out, I needed to have the variable read using $GUICtrlRead

Also, does anyone know how to mimic the button push by pressing ENTER as an alternative? (having both options)

Share this post


Link to post
Share on other sites
mrgy05
#include <ButtonConstants.au3>

$Submit = GUICtrlCreateButton( "Submit", 220, 47, -1, -1, $BS_DEFPUSHBUTTON)

Perhaps.

 

Thank you John! This is great :)

Here is the ending result if anyone would like to know. The program is simple searches the keyword with these search values for eBay:

________ your keyword

Criteria

  • 0.01 to 0.01 price (penny)
  • No more than 1 bid (currently)
  • Free Shipping
  • Auction Only
  • Ending within 4 hours.

This way I can quickly scan certain keywords for cheap (nearly free) items ending on eBay.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3> 

SearchEbay() ; All functions must have this

Func SearchEbay() ; Start the function
    Local $msg ; The core of the GUI / Window
   
   $GUI = "EBAY 0.01"
   
   $URL1 = "http://www.ebay.com/sch/i.html?_nkw=" ; First part of URL
   $URL2 = "&_in_kw=1&_ex_kw=&_sacat=0&_mPrRngCbx=1&_udlo=0.01&_udhi=0.01&LH_Auction=1&LH_Time=1&_ftrt=901&_ftrv=5&LH_NOB=1&_sabdlo=0&_sabdhi=1&_samilow=&_samihi=&LH_FS=1&_sadis=200&_fpos=&_fsct=&LH_SALE_CURRENCY=0&_sop=12&_dmd=1&_ipg=200" ; Last part of URL

    GUICreate( $GUI, 220, 130) ; will create a dialog box that when displayed is centered
    GUICtrlCreateLabel ( "Enter one keyword and submit", 10, 10)
    $Search = GUICtrlCreateInput ( "" , 10, 30)
    $Submit = GUICtrlCreateButton( "Submit", 165, 28) ;
    GuiCtrlSetState(-1, 512) ; Allow ENTER to submit the search
    
    GUICtrlCreateLabel ( "Fine-tune search settings", 10, 70)
    $URL2a = GUICtrlCreateInput ( $URL2 , 10, 90)
    $OpenSearchSettings = GUICtrlCreateButton( "Build", 140, 88) 
    
    GUISetState(@SW_SHOW) ; will display an empty dialog box

    ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()

                Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $Submit
                                
                $ReadSearch = GUICtrlRead ($Search)
                $ReadURL2a = GUICtrlRead ($URL2a)
                
                _IECreate($URL1 & $ReadSearch & $ReadURL2a, 1, 1, 0, 0)
                
                WinWaitNotActive ( $GUI )
                sleep (100)
                WinActive ( $GUI )
            
            Case $msg = $OpenSearchSettings
            
            _IECreate( "http://www.ebay.com/sch/ebayadvsearch/" , 1, 1, 0, 0)

            EndSelect


        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
    GUIDelete()
EndFunc

It would be great if I didn't need to use IE, rather Chrome or Firefox (anything really)!

Share this post


Link to post
Share on other sites
BrewManNH

It would be great if I didn't need to use IE, rather Chrome or Firefox (anything really)!

It would be great if those browsers allowed the type of scripting access that IE gives to you without any outside programs/plugins being needed. But frankly the IE hate is unwarranted as it's not a bad browser and probably magnitudes beyond FF these days.

  • Like 1

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.