Make borderless window behaves alwaysontop [Autohotkey] - autohotkey

I want to create a borderless window, but alwaysontop didn't work if the window is borderless, how to make borderless window behave alwaysontop ?
gui, Tool: add, button, x0 y0 h20 w140 gxub, TOOLS
gui, Tool: show, w150, TOOLS
WinGet, id1, ID, A ; GET ahk_id of active window
WinSet, Style, -0xC00000, A ; hide title bar
Winset, Alwaysontop, ON, ahk_id %id1%

Adding one line on the top will satisfy your need
gui, +alwaysontop

Related

How to create an edit controls with transparent background?

While reading the AutoHotkey docs i could find these commands: WinSet, Transparent WinSet, Transcolor
WinSet, Transparent makes the control disappear.
WinSet, Transcolor makes the control background transparent, however if the GUI has any other color than default, it causes glitches in the text.
Example:
Gui, Color, 0
Gui, Add, Edit, w200 h30 hWndTest, Test
Gui, Show, w400 h200
Return
F2::
WinSet, Transparent, , ahk_id %Test%
Return
F3::
WinSet, Transcolor, ffffff, ahk_id %Test%
Return
Would like to ask if someone knows how to create an edit control with background transparent without 'glitches'?

How to enable the maximize button in the gui?

When i create a GUI her maximize button is grayed out/disabled, how can i enable it?
Example:
Gui, Add, Button, w100 h30, Button
Gui, Show, w400 h300
I was reading the docs and found this parameter Maximize: Maximizes and activates the window.
It does maximize the GUI as soon its launched:
Gui, Show, Maximize w400 h300
However, i would like to enable maximizing/restoring upon clicking the maximize button.
You need to add the flag +Resize
From docs:
Resize: Makes the window resizable and enables its maximize button in the title bar. To avoid enabling the maximize button, specify +Resize -MaximizeBox.

Cant move gui after removing her 'caption'

Maybe someone knows if it is possible to move GUI while -caption is enabled?
Since the toolbar is removed with GUI -caption, now I can not move GUI with the mouse.
All that is necessary to add to your scripts is the OnMessage line and the WM_LBUTTON function in the script below to allow you to move the GUI:
OnMessage(0x0201, "WM_LBUTTONDOWN")
Gui, -Caption
Gui, Show, w500 h200
return
WM_LBUTTONDOWN() {
PostMessage, 0xA1, 2,,, A
}
Esc::ExitApp

GUI Buttons creating text 4 times

I am trying to create my 1st GUI. I just started using AHK today and for the most part have found it very simple to use. I am stuck on one thing though. I created this GUI to display buttons and then depending on what is selected certain text will be typed. When I select the button it is typing the correct text, but it is typing it four times. I have taken off one of the buttons, so there were only three, but it would still type it four times. What do I need to do to make sure it only types it once?
MyGUI:
#SingleInstance Force
Gui, +LastFound +AlwaysOnTop
GUI, Add, Button, x10 y10 w75 h25 gClick1, Button &1
GUI, Add, Button, x95 y10 w75 h25 gClick2, Button &2
GUI, Add, Button, x10 y45 w75 h25 gClick3, ButtonS &3
GUI, Add, Button, x95 y45 w75 h25 gClickCancel, &Cancel
GUI, Show, w200 h100,My GUI
Return
Click1:
Send The first button was selected
Gui Hide
Return
Click2:
Send The second button was selected
Gui Hide
Return
Click3:
Send The third button was selected
Gui Hide
Return
ClickCancel:
Send The cancel button was selected
Gui Hide
Return
I have not tested it yet, but it could be that your send is initiating this. remember that you first send a keyboard sequence and then hide the GUI, so in your situation the GUI is still active at the moment you send! Try to first hide the GUI and then send or initially replace send by MsgBox to test. You could also first send an !{Esc} to switch the focus back to the previous application before sending your data, That way you don't need to hide the GUI.
OK just tested my assumptions, add the !{Esc} and it works as expected.
#SingleInstance Force
Gui, +LastFound +AlwaysOnTop
GUI, Add, Button, x10 y10 w75 h25 gClick1, Button &1
GUI, Add, Button, x95 y10 w75 h25 gClick2, Button &2
GUI, Add, Button, x10 y45 w75 h25 gClick3, ButtonS &3
GUI, Add, Button, x95 y45 w75 h25 gClickCancel, &Cancel
GUI, Show, w200 h100,My GUI
Return
Click1:
Send, !{Esc}
Send, The first button was selected
;Gui Hide
Return
Click2:
Send, !{Esc}
MsgBox, The second button was selected
;Gui Hide
Return
Click3:
Send, !{Esc}
MsgBox, The third button was selected
;Gui Hide
Return
ClickCancel:
Send, !{Esc}
MsgBox, The cancel button was selected
;Gui Hide
Return

Press a button with postmessage

There is a way to make a mouse click with postmessage, a solution without moving the mouse (no click x, y)?
For example:
loop{
hotkey,ctrl,pressb
}
pressb:
msgbox a button
PostMessage, 0x0201, , 9765141, ahk_class #32770
PostMessage, 0x0202, , 9765141, ahk_class #32770
; or ControlClick, x95 y115, ahk_class #32770
return
Functions PostMessage and ControlClick don't work, the button is not pressed.
Each of these should work
ControlClick, Button1, ahk_class #32770
ControlClick, OK, ahk_class #32770
I had the same problem (until just recently). Most of the AutoHotKey interactive commands (such as SendMessage, ControlClick, SendRawMessage and so on) does not work within a 32700 window (a dialog) as well as other windows.
Solution: If you're running Windows 7. You need to run your AHK script as an administrator. To do this, right click on your AutoHotKey Script and click on 'Run as administrator'.