Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

small Gui with hotstring


  • Please log in to reply
4 replies to this topic
AdamWeiss
  • Members
  • 2 posts
  • Last active: Jul 17 2015 03:11 PM
  • Joined: 08 Jul 2015

Hi I'm new to AHK but I like it a lot so far.

I have studied hotstrings and gui for day now and I coud do this which I need

::\46::
{
Gosub No
 send, †Covill, Roesler and Shaw, 2010 {u+0023}46@%p%‡
return
}

This is a part of a code in a script with tons of such hatstrings gosub No contains mouse clicks that are required before the send, But I also need a GUI to fill in what %p% is. I need the GUI is soon as I hatstring and preferably it should go way with enter or ok and have a default walue if left blank

Can anyone help please? I have been trying hard

  

 

 



space
  • Members
  • 520 posts
  • Last active:
  • Joined: 12 Aug 2014
I think http://ahkscript.org...ds/InputBox.htmis what you want, it is only one line of code so the easiest to implement. If you have it set the same variable you can make it a Label and use Gosub to get the input from the user instead of having to use the InputBox command for each hotstrings. That way if something changes you only have to update one InputBox not many.

AdamWeiss
  • Members
  • 2 posts
  • Last active: Jul 17 2015 03:11 PM
  • Joined: 08 Jul 2015

I managed to do just that with InputBox thank you! But still is there a (quite simple way to do this with a GUI that is put it in a label, and go to it evert time I need to? I want that in case I need to input more than one parameter. What I mean is I want a form GUI that pops up with a label I almost manged to do that but after the GUI label ran it wouldn't continue with the rest of the commands assigned  to the hotstring

I know I'm a bit unclear but thanks anyway any guideline will be much appreciated



space
  • Members
  • 520 posts
  • Last active:
  • Joined: 12 Aug 2014
It is not as easy as it sounds.

Because of the way Gui works you need multiple steps:
create the Gui,
Show the Gui,
Wait for user input,
Return to hotstring.

The problem is The Wait For User Input.
The way it usually works is that after Showing the Gui you use a "Return" to wait for user input, if you do that here it will return to the Hotstring and not wait for the User Input.

So you have to use a trick to keep on waiting for the user to enter the data before actually returning to the hotstring, like a loop or while. This is one way (there are others)

Active:=1

; Setup GUI
Gui, Add, Text, ,Variable 1:
Gui, Add, Edit, vVariable1
Gui, Add, Text, ,Variable 2:
Gui, Add, Edit, vVariable2
Gui, Add, Button, gOK, OK
Gui, Add, Button, gCancel, Cancel

F12::Reload

::btw::
Gosub, UserInput
If Active
	Send Hello this is %variable1% and %variable2%
Return

UserInput:
Gui, Show, w200 h150, Get user Input
Active:=1
While (WinExist("Get user Input"))
	{
	 Sleep 100
	}

Return

OK:
Gui, Submit, Hide
Return

Cancel:
Gui, Hide
Active:=0
Return
If you need more flexibility in the form you could check something like EntryForm() by coco http://ahkscript.org...opic.php?t=4559 or another method entirely something like http://www.autohotke...opy-paste-text/

MaryJackson
  • Members
  • 3 posts
  • Last active: Dec 23 2015 06:18 AM
  • Joined: 23 Dec 2015

One of the strengths of an app like this is that it works great for repetitive writing tasks like phone numbers, email addresses and signatures. Instead of having to repeat essentially the same phrase several times a day you just write a simple keyword and it’ll automatically transform into the right thing. Since it’s as just a script it works universally across all of your apps too, which is another thing that’s great. I can use the same abbreviations whether I’m surfing the web in Chrome or writing a blog post in Focus Writer or ResophNotes.