2 problems with gui Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
duzymichal
Posts: 16
Joined: 31 Mar 2017, 04:11

2 problems with gui

15 May 2017, 05:43

Hi

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
User avatar
jmeneses
Posts: 524
Joined: 28 Oct 2014, 11:09
Location: Catalan Republic

Re: 2 problems with gui  Topic is solved

15 May 2017, 06:47

Hi duzymichal you need to specify -WantReturn in the EDIT control

Code: Select all

Gui, Add, Edit, -WantReturn  vprompt x72 y140 w370 h30
or reduce the height (H)

Code: Select all

Gui, Add, Edit, vprompt x72 y140 w370
or limit it to a one row

Code: Select all

Gui, Add, Edit, vprompt x72 y140 w370 h30 r1
Donec Perficiam
duzymichal
Posts: 16
Joined: 31 Mar 2017, 04:11

Re: 2 problems with gui

15 May 2017, 07:23

Excellent, thank you :D . I had no idea a detail such as the height of an edit box makes that much of a difference.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 247 guests