Iam developing an ahk-Script that checks the battery of the current device in time intervals.
Besides two text-lines that show the ac-status and the batterylife in percent, I am showing a Button to close the gui. Otherwise the gui closes itself in 10 seconds.
But:
When I click on the button, nothing happens... can someone show me the mistake?
Thx a lot
Gui, +AlwaysOnTop +Disabled -SysMenu +Owner
Gui +LastFound
WinSet, Transparent, 240
Gui, -Caption
Gui, Font, s11 cD0D0D0 Bold
Gui, Add, Text,, %acStatus%
Gui, Add, Text,, %batteryLifePercent% Prozent
Gui, Add, Button, x10 y+5 w90 gsub1, Ok
Gui, Show, x1750 y1000
Gui, Show, NoActivate, Akkustatus
Return
Sleep, 10000
Gui Destroy
Return
sub1:
{
Gui Destroy
}
Return
Remove +Disabled from the gui:
Gui, +AlwaysOnTop +Disabled -SysMenu +Owner
This option will prevent the user from interacting with the window, thus preventing you from clicking on the button.
Related
I can't seem to get this message box to work using variables. It should be simple so I am missing something. Please help.
Gui +alwaysontop
Gui, add, button, gChoice vA w50, A
Gui, add, button, gChoice vB w50, B
gui, show, y200 w70
return
Choice:
msgbox % v
gui submit, nohide
if A
MsgBox A
if B
MsgBox B
return
Issues with your code:
Ordinary buttons do not store anything in associated variables. So, specifying vA or vB is meaningless. On the other hand, checkboxes and radio buttons do, as stated here.
I have no idea what you're trying to do with MsgBox % v since there's no other reference to the variable v.
The following's tested to work:
Gui +AlwaysOnTop
Gui Add, Button, gChoiceA w50, A
Gui Add, Button, gChoiceB w50, B
Gui Show, y200 w70
Return
ChoiceA:
MsgBox A
Return
ChoiceB:
MsgBox B
Return
I have the AutoHotKey EnterPad Keyboard/Pad with 120 Programmable Keys
It works by sending a Hotkey press for each key to an AutoHotKey script which has a Label function for each key named 001 through 120
Below is my AHK Label function called when key 115 is pressed.
My code allows me to select rows in any Windows Listview component and it will show a popup GUI window with a textbox filled in with the data from the selected rows with each column separated with a TAB space. I can then copy or save it or view it whatever I like.
;---------------------------------------------------------------------115-----
; Copy Selected Windows Listview Items to Tab Spaced Text - Show popup Window Gui
; https://superuser.com/questions/814831/copy-to-clipboard-from-table-list-in-a-program-on-windows
115:
Gui, SelectedListRowsTextGui:Destroy
MouseGetPos, , , , ListView_hwnd, 2 ;2 means return HWND
ControlGet, selected_row_text, List, Selected, , ahk_id %ListView_hwnd%
Gui, SelectedListRowsTextGui: +ToolWindow +AlwaysOnTop -Caption
Gui, SelectedListRowsTextGui:Add, Edit, vUnused_variable x11 y15 w950 h66, %selected_row_text%
Gui, SelectedListRowsTextGui:Add, Button, x62 y84 w140 h30 +Center, Close
Gui, SelectedListRowsTextGui:Show, ,
return
ButtonClose:
Gui, SelectedListRowsTextGui:Destroy
return
Return
Problem
My issue is that once the popup window is opened from my AHK GUI, my CloseButton label dose not get called when I click the close button.
I realize it likely has something to do with it being nested under the key 115s label function. How can I best achieve the desired result?
I tried moving the CloseButton label outside of the 115 label however it still is not called from the GUI's Close button click.
You can see I have named the GUI SelectedListRowsTextGui this is to allow this Enterpad.ahk script to contain many GUI windows for different actions it will perform.
Preview of the GUI window this script creates when listview items are selected and this Label function is called:
I got it now....
Since my GUI is named SelectedListRowsTextGui I had to add that name in front of my CloseButton label name so it is now SelectedListRowsTextGuiButtonClose and works great
I have successfully used to following autohotkey script to achieve what I want (remove title bar and window frame from a windowed game):
;-Caption
LWIN & LButton::
WinSet, Style, -0xC00000, A
return
;
;+Caption
LWIN & RButton::
WinSet, Style, +0xC00000, A
return
;
What I want is for "WinSet, Style, -0xC00000, A" to be executed automatically when a specific application is launched.
Any feedback would be greatly appreciated!
Altough wOxxOm's answer is perfectly acceptable. You can also do this in a persistent script by using Settimer and WinExist .
#persistent
SetTimer, isItRunning, 1000
isItRunning:
if winexist("yourprogram")
WinSet, Style, -0xC00000
Return
Simply make an AHK launcher for the game and use it instead of the shortcut icon or taskbar icon or whatever else you're using to launch the game.
Run, d:\somepath\game.exe
WinWait Game window title goes here
WinSet, Style, -0xC00000
ExitApp
I am trying to obtain the Seamless windows effect with TightVNC Viewer.
Basically I set the client visible area to an application with
"C:\Program Files\TightVNC\tvnserver.exe" -controlapp -shareapp <app PID>
then I use the following AutoHotkey script to hack TightVNC Viewer window (where I hide the toolbar):
^!h::
IfWinExist, antonio - TightVNC Viewer
{
WinSet, Style, ^0xC00000 ; title bar, without you can move only with win-key
WinSet, Style, ^0x800000 ; thin-line border
WinSet, Style, ^0x400000 ; dialog frame
WinSet, Style, ^0x40000 ; sizing border, without you cannot resize
WinSet, Style, ^0x200000 ; vertical scroll bar
WinSet, Style, ^0x100000 ; horizont scroll bar
}
return
; http://www.autohotkey.com/docs/misc/Styles.htm
The script toogles the border and other window elements.
I am still working with the styles, but the main problem is that scrollbars don't go away.
How can I get rid of them?
Side note
An interesting side effect of sharing windows in VNC locally, that is with the loopback connection, is that you can obtain kinda of X Server in Windows, appealing for multi-monitors systems.
I found a "semi-general" solution for scrollbars. They are not a property of the window, but of some edit child control. Getting the control name via Window Spy, you can remove the bars from some app, with:
Control, Style, -0x100000, <control name>, <app window name>
Control, Style, -0x200000, <control name>, <app window name>
For example it works for for Notepad, where <control name> is Edit1.
Unfortunately TightVNC uses a non standard Window class, TvnWindowClass1, and I am unable to affect its scrollbars.
Anyway, replacing the server option -shareapp <app PID> with -sharewindow <app window name>, there are no-scrollbars.
The following is a local working sample assuming you want to share calc.exe, whose window name is Calculator.
Press Ctrl+Alt+h once and you will locally start a client-server VNC sharing the Calculator window. Press again and you get the seamless effect. Press again and you get back to standard view (and you can move, size again).
If toggling window style with Ctrl+Alt+h, TightVNC toolbar doesn't toggle too, set it on or off manually in normal view from the window control menu or with
Shift+Ctrl+Alt+t.
If you want to use the script in two distinct systems, you have to split it in two parts where server commands are run on the server side and client ones on the client system.
Note that, for a more general use, regexp are used in naming the target application window.
Note
The script is useful as is to duplicate a window. Window mirroring is something trivial in Linux X Window (for the server nature of the display), which instead require tools paid money in Windows. Mirroring turns useful when you have a multi-monitor system or a projector and you want to duplicate, not the whole desktop, but only some particular windows on the second monitor (projector).
^!h::
SetTitleMatchMode RegEx
IfWinExist, TightVNC Viewer$
{
WinGet, Style, Style
if(Style & 0x800000) {
WinGetPos, X, Y
Sleep, 6000
WinSet, Style, -0xC00000 ; title bar, without you can move only with win-key
WinSet, Style, -0x800000 ; thin-line border
WinSet, Style, -0x400000 ; dialog frame
WinSet, Style, -0x40000 ; sizing border, without you can't resize
Send !+^t ; no toolbar
WinMinimize
Sleep, 500
WinRestore
WinMove, X, Y
} else {
WinSet, Style, +0xC00000 ; title bar, without you can move only with win-key
WinSet, Style, +0x800000 ; thin-line border
WinSet, Style, +0x400000 ; dialog frame
WinSet, Style, +0x40000 ; sizing border, without you can't resize
Send !+^t ; no toolbar
}
}
IfWinNotExist, TightVNC Viewer$
{
Run, calc
Run, "C:\Program Files\TightVNC\tvnserver.exe" -run
Sleep, 1000
Run, "C:\Program Files\TightVNC\tvnserver.exe" -controlapp -sharewindow Calculator
Run, "C:\Program Files\TightVNC\tvnviewer" 127.0.0.1
}
return
I've been learning to use GUI's with Autohotkey, and I'm creating a small script so when I press the insert button it allows me to quick search Google. I can't figure out how to use Radio Buttons, so say for example, I can choose to search Google or Bing. I don't know any of the code for "If Google is selected, search the query on Google".
^Insert::
MsgBox,4,, Would you like to reload?, 3
IfMsgBox, no
Return
IfMsgBox, Timeout
Return
Reload
Insert::
Gui, Add, Text,, Search Google:
Gui, Add, Edit, vSearchQuery ym ;
Gui, Add, Button, default, Search
Gui, Show,, Quick Search
return
GuiClose:
ButtonSearch:
Gui, Submit
Run, http://www.google.com/search?hl=en&q=%searchQuery%
Reload
Here is a simple example:
Gui Add, Radio, vEngine, Google
Gui Add, Radio,, Bing
Gui Add, Button, h25 w126 Default,OK
Gui Show
Return
ButtonOK:
Gui Submit
if Engine = 1
msgbox % "You chose Google!"
else if Engine = 2
msgbox % "You chose Bing!"
ExitApp