Is there a better way of doing this ?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
WalkerOfTheDay
Posts: 710
Joined: 24 Mar 2016, 03:01

Is there a better way of doing this ?

22 Apr 2016, 08:52

Hi,

Is there a better way of doing this ?

When I have Sap Business One started, and fire below code, the Send {F2} and Send {F5} only
works when I use WinActivate, otherwise the focus is on the gui.

Just curious, it works like I want but I was just wondering if there was another way.

Code: Select all

SetTitleMatchMode, 2 ; 

Gui, +AlwaysOnTop
Gui, Add, Button, x86 y67 w100 h30 , F2
Gui, Add, Button, x196 y67 w100 h30 , F5
; Generated using SmartGUI Creator for SciTE
Gui, Show, w477 h377, Toetsenbord
return

ButtonF2:
{
	WinActivate,  - SRT International BV, , 3
	Send {F2}
	return
}

ButtonF5:
{
	WinActivate,  - SRT International BV, , 3
	Send {F5}
	return
}
GuiClose:

ExitApp
User avatar
kczx3
Posts: 1648
Joined: 06 Oct 2015, 21:39

Re: Is there a better way of doing this ?

22 Apr 2016, 09:25

The other way you could do it is just using hotkeys or hotstrings. If you use a gui and have to click a button to send the keystrokes, then yes WinActivate would be required. Hotkey/Hotstring seems like the better way to go.
User avatar
WalkerOfTheDay
Posts: 710
Joined: 24 Mar 2016, 03:01

Re: Is there a better way of doing this ?

22 Apr 2016, 11:22

Thank you for your answer.

I do need this GUI in my script, so I'll stick with what I have so far.
SifJar
Posts: 398
Joined: 11 Jan 2016, 17:52

Re: Is there a better way of doing this ?

22 Apr 2016, 11:56

You could also use ControlSend e.g.

Code: Select all

ButtonF2:
; curly brackets not required for label
ControlSend,,{F2},  - SRT International BV, , 3
return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], norot41087, Rohwedder and 122 guests