How to: get a search to refresh already open windows and activate search by pressing return

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
kriswoj
Posts: 2
Joined: 30 Nov 2021, 05:02

How to: get a search to refresh already open windows and activate search by pressing return

Post by kriswoj » 30 Nov 2021, 05:16

Ok, I am very new to this, first post here. I have a little script that I copied from someone else and made some simple adaptions for my purposes.

Basically it is a little script to search the same thing on multiple websites simultaneously. The person I copied the script from was using it to search part numbers, I'm using it to search words.

So things I don't know how to change for my purposes are:
1) When I run it, a new tab opens for each website, searching for the query. When I then search another query, new tabs open again. Is there a way to make the respective tabs for each website just refresh, if they are already open, with the new query rather than opening new ones, but open new ones if they don't have a tab open?
DONE - 2) When I search for multiple words, the query is passed with a '_' between the words. This affects the search results on various websites. Is it possible for the words to be passes without the '_'? I imagine if something has to be used as a word separator, then a '+' would probably be more suitable. DONE
3) In the search term box how do I make the script run just by pressing return in that box rather than having to click start? I still want the start box there and for it to function normally, but for ease being able to press return in the box to activate the script as well would be good.

My script (updated to reflect having done #2 above) is the following, but again as I'm new to this, I don't understand what a lot of the commands are doing, I've just left most things as they were from fear of breaking the script!

Code: Select all

SplitPath,a_scriptname, name, dir, ext, name_no_ext, drive
F1=%a_scriptdir%\%name_no_ext%.ini
I=7               ;- total checkboxes

;src=Chris ;- search for preselect
src=


Gui,2: Color, ControlColor, Black
Gui,2: Font, CDefault, Lucida Console


Loop,%i%
  {
  IniRead, Ch%A_Index%, %f1%, ss, Cb%A_Index% , 0
    If (Ch%A_Index% = 1)
      Cb%A_Index% = Checked
    Else
      Cb%A_Index% =
  }


Gui,2: Show, x100 y5 w300 h460, %name_no_ext%

Gui,2: Add, Edit,     x20 y5 w265 h20 cWhite vSearch,%src%

Gui,2: Add, CheckBox, x20 y40 vCh1 %cb1% cYellow, Pure Cards
Gui,2: Add, CheckBox, x20 y65 vCh2 %cb2% cYellow, Magic Shop
Gui,2: Add, CheckBox, x20 y90 vCh3 %cb3% cYellow, JPG Games
Gui,2: Add, CheckBox, x20 y115 vCh4 %cb4% cYellow, King of Cards
Gui,2: Add, CheckBox, x20 y140 vCh5 %cb5% cYellow, Magic Box
Gui,2: Add, CheckBox, x20 y165 vCh6 %cb6% cYellow, Magic World
Gui,2: Add, CheckBox, x20 y190 vCh7 %cb7% cYellow, Saturn Magic


Gui,2: Add, CheckBox, x20 y215 vCh98 gCheckAll cYellow, Select All
Gui,2: Add, CheckBox, x20 y240 vCh99 gUnCheckAll cYellow, De-Select All

Gui,2: Add, Button, x10 y300 w100 h26 gAA ,Start
GuiControl,2:Focus,search
return


CheckAll:
Loop, %i%
    GuiControl,2:, Ch%A_Index%, 1
GuiControl,2:, Ch99, 0
Return

UnCheckAll:
Loop, %i%
    GuiControl,2:, Ch%A_Index%, 0
GuiControl,2:, Ch98, 0
Return


AA:
Gui,2: submit, nohide
StringReplace,Search, Search, %A_space%, +, All
search=`%22%search%`%22
{
    StringReplace,search,search,+,%A_space%, All
    StringUpper,search,search,T
    StringReplace,Search,Search,`%22, , All
    StringReplace,Search,Search,`", , All
          }

  if Ch1
    run,https://www.pure-cards.com/#/dfclassic/query=%search%
  if Ch2
    run,https://magicshop.co.uk/pages/search-results-page?q=%search%
  if Ch3
    run,https://jpgamesltd.co.uk/index.php?route=product/search&search=%search%
  if Ch4
    run,https://www.kingofcards.com/search?type=product&q=%search%
  if Ch5
    run,https://www.magicbox.uk.com/?s=%search%&post_type=product&type_aws=true
  if Ch6
    run,https://www.magicworld.co.uk/?s=%search%
  if Ch7
    run,https://www.saturnmagic.co.uk/search/for/%search%/


return


2GuiClose:
Gui,2: Submit
Loop,%i%
  {
  e= % ch%a_index%
  IniWrite, %e%, %f1%, ss, Cb%a_index%
  }
ExitApp
;===========================================================================
Last edited by kriswoj on 01 Dec 2021, 08:28, edited 1 time in total.

kriswoj
Posts: 2
Joined: 30 Nov 2021, 05:02

Re: How to: get a search to refresh already open windows; remove a '_' between words; and activate search by pressing re

Post by kriswoj » 01 Dec 2021, 08:26

I've figured out the second part. Was actually quite easy, I just needed to look more closely at the code I've used!

Still trying to figure out the first and third things above though.

Post Reply

Return to “Ask for Help (v1)”