What I'm trying to do is make a gui where I input a keyword or keyphrase and a corresponding webpage would open in a new IE tab (whether IE is open or not).
There are 2 problems with what I've come up so far.
1. I want the gui to react to "enter" key as if "OK" button was clicked, but it doesn't seem to work.
2. The script is whimsical. At some times it works fine, opens a new tab whether IE was previously opened or not. At other times it simply doesn't react to clikcing "OK" button.
Any help will be greatly apprceciated.
Code: Select all
Gui, Add, Tab, x22 y110 w440 h90 , 1
Gui, Add, Edit, vprompt x72 y140 w370 h30
Gui, Add, button, default x32 y140 w30 h30 gOK, OK
Gui, Show, x225 y130 h379 w479, type element
Return
ok:
Gui, submit,
if prompt = goo
{
CreateNewIeObject := 0
if CreateNewIeObject = 1 ;create new IE windows
WB := ComObjCreate("InternetExplorer.Application")
else ;use Existing IE window
{
For WB in ComObjCreate("Shell.Application").Windows ; for each open window
If InStr(WB.FullName, "iexplore.exe") ; check if it's an ie window
break ; keep that window's handle
}
wb.Visible := true
wb.Navigate("www.google.com", 2048)
WinMaximize, % "ahk_id " wb.HWND
while wb.busy
Sleep 10
}
GuiControl,,prompt,
Gui Minimize
return
GuiClose:
ExitApp
GuiEscape:
ExitApp