I can run all of my programs with AutoHotkey, but I'm trying to open them all in specific locations on my 3 monitors. I played with some code but couldn't get it to change at all. This is what I have so far for one of my folders that I'm trying to open with this hotkey:
Run, C:\Python\LPTHW
WinActivate
WinMove A,, 10, 10, A_ScreenWidth-20, A_ScreenHeight-20
I got this code partially from another forum and I only kind of understand what it does, but modifying the numbers doesn't change anything about how it opens, and every once in a while it makes all my desktop icons disappear when I run it.
Couple things you should probably know. The A tells WinMove to move the active window. It's best to call out specifically what you're trying to move. And, the Width and Height parameters need to be forced as expressions. Take a look and see if you can alter your code to work based on the notepad example below.
Run, notepad
WinWaitActive, Untitled - Notepad
WinMove, Untitled - Notepad,, 0, 0, % A_ScreenWidth/2, % A_ScreenHeight/2
Related
I'm trying to automate a many clicking process, just to narrow it to the user input.
I encountered problems in controlClicking interface elements, which seems not to be standard Windows GUI elements.
When pointing them with WinSpy they don't appear as separate buttons, but I can point the whole child Window which is drawn in the main program window.
As on pic1, I pointed the whole window and I can find each tab/button by it's text inside and on pic2 I can inspect the ClassNN of that element and it's ID.
As far as clicking other buttons in the main menu bar of the program works, a simple:
ControlClick, ClaTab_01000000H26, WindowName
doesn't work. I think during the day, and many possibilities I tried, I could ControlClick the above button by pointing it with its ID, but that ID changes every instance. I could confirm that tomorrow if it works by ID.
Of course I tried SetControlDelay -1 and ,NN option. But don't take that for granted, I can try any of your suggestions tomorrow.
Both tabs marked with purple color, are to find in the Windows->SiblingWindows tab. I really don't want using x,yCoords (that actually work), but I need the script to be as reliable as possible.
So my questions are:
Am I missing something or you have any suggestions how to click that elements?
Is it correct, that no matter how deep the child windows get (one has buttons to open another on top of it), all the time the WinName stays the same pointing to the main program ***.exe?
Could you provide an example from the web or yours, to find an element's ID by providing the text attached to the button (pic1-red line and also pic2 in "text")?
I also cannot maximize the child window. Double clicking it works, but I can't find the appropriate ClassNN of the window to call.
Could you provide an example, how to use the Messages tab? I assume, if I find the button as on the pictures, I could send a message with controlClick and see if there's a reaction?
1.Ugh. I found the solution, which is awesome, but a little frustrating that with a bit of luck I tried another aproach that's not that logical for a newbie like me:
instead:
ControlClick, ClaTab_01000000H6, ahk_class ClaWin01000000H_2,,,, NA
it's just
ControlFocus, ClaTab_01000000H6, ahk_class ClaWin01000000H_2,,,, NA
2._Yep. One child window creates another and another and another, but winTitle stays the same. In my case:
ahk_class ClaWin01000000H_2
3._Code below returns the handle/ID of the element you specify. Change ClaTab and ClaWin to your chouice.
ControlGet, OutputVar, hwnd,, ClaTab_01000000H1, ahk_class ClaWin01000000H_2
MsgBox, %OutputVar%`
Probably to be continued.
I highly recomend to both use
WinSpy https://www.autohotkey.com/boards/viewtopic.php?t=28220
SimpleSpy https://www.the-automator.com/downloads/simple-spy/
First one has lots of useful information and the window tab provides information of hidden buttons/windows. Second one in a more clear way indicates the parent window and its class.
I have an AHK script which saves window positions.
At the moment I save Title, X, Y, Width, Height, Class, FullPath etc.
I also want to save on which Virtual Desktop they are located on.
I dont know how Windows 10 handles Virtual Desktops:
Do they have a UID?
Do these UIDs change after a reboot?
Is there any way to actually number them?
I would like to do it in a way which has a low chance of breaking in case of a Windows update, but obviously that's mostly a dream.
Thanks for any help!
I've made an ahk function library,
to get the desktop (number) a window is on, use VD_getDesktopOfWindow(wintitle), where wintitle can be combination of
WinTitle, ahk_class, ahk_exe, ahk_id, etc.
https://github.com/FuPeiJiang/VD.ahk
I've just made a script "list VD of all windows.ahk" in folder "other examples" to do what you need
It gets every window in every VD, and tells you, in order of VD, which windows are inside it.
Desktop 1: program.exe
Desktop 1: otherProgram.exe
Desktop 2: foobar.exe
Desktop 3: youGetThePoint.exe
the actual format is different
https://github.com/FuPeiJiang/VD.ahk/blob/master/other%20examples/list%20VD%20of%20all%20windows.ahk
I have to use a software which list my clients processes. I need a sound alert program if something change on 50x10 pixel region. I try to write a program on autohotkey but i can't succeed in. Anybody have this program?
Here is an example that you can use.
^Launch_Media:: ; Make a reference screenshot with NirSoft NIRCMD by pressing Ctrl+Media or any other program...
run, "C:\Program Files\1 My Programs\nircmd.exe" savescreenshot "c:\Temp\Screenshot.bmp" 33 40 17 20 ; Location of "Save As" Icon in SciTE4AutoHotKey Editor
Return
Launch_Media:: ; Launch this test manually with Media Button
CoordMode Pixel ; Interprets the coordinates below as relative to the screen rather than the active window.
ImageSearch, FoundX, FoundY, 0, 0, 200, 200, C:\Temp\Screenshot.bmp ; search for image in area staring at 0,0 to 200,200
if ErrorLevel = 2
MsgBox Could not conduct the search.
else if ErrorLevel = 1
MsgBox Image could not be found on the screen.
else
SoundBeep, 1000, 1000
MsgBox The Image was found at %FoundX% %FoundY%.
ClickX:=FoundX + 5 ; Move the mouse click away from the edge of the icon
ClickY:=FoundY + 5 ; Move the mouse click away from the edge of the icon
Click, %ClickX%, %ClickY% ; Click on the Save As icon.
Return
When we know more about what you want to test (I think that an area of 50x10 might be too small), and what you want to do in case the area has changed, we might be able to help you with a more suited script.
In this example I used NirSoft's nircmd.exe, but you can create a reference image by other means as well. If You only need an audible alarm, you can comment all the other commands under if, then, else out with ;.
Did you check this post from 2 years ago in the AutoHotKey community?
http://www.autohotkey.com/board/topic/56219-fast-screen-change-check-using-histograms/
The above script might be a little overwhelming, but you can also create a screenshot of a fixed area and do an image comparison in AutoHotKey as others have done before you.
My program needs to arbitrarily maximize any window on the current desktop. I achieve this by calling ShowWindow(hWnd, SW_MAXIMIZE), where hWnd is the HWND of the window I want to maximize. When that line of code executes, the window in question (here, Notepad) looks like this:
Everything seems fine, except for the fact that the window has not been positioned correctly, i.e. the window seems to be a few pixels to low, and the title bar does not look "squashed" like it should. Compared to how it should look when the maximize button is clicked, the problem is clearly visible:
Does anyone know why this behaviour occurs, and what I can do to fix it?
Telling the window to maximize itself might bypass some internal adjustments that the program makes when it maximizes via a system menu command. To emulate clicking on the maximize button, send it a SC_MAXIMIZE command:
SendMessage(hwnd, WM_SYSCOMMAND, SC_MAXIMIZE, 0);
Antoher way to use SetWindowPos(); For example you got HWND handleWnd;
RECT rcWnd;
GetWindowRect(handleWnd,&rcWnd);
SetWindowPos(handleWnd,WHND_TOP,rcWnd.left,rcWnd.top,(rcWnd.right-rcWnd.left),(rcWnd.bottom-rcWnd.top),SWP_SHOWWINDOW);
So you got your previous position, place window on top of Z and show
I am facing a little annoying design problem. Not easy to give a title of my question.
I must display two windows, one over another one. The first one is a Cocoa window, the second is made with Qt. In the second window, an action is performed, but the user can choose to close this window. He must fall back on the first window.
To display my first window, which is actually a SFAuthorizationPluginView, I do:
[myview displayView];
then, to display the window made with Qt on top of first window:
QWidget* w = openMyScreen();
NSView* v = (NSView*)w->winId();
[[v window] setLevel:2003];
This works well, however there is a small delay before the second window is displayed. We can thus see for a very short time the first window.
I need that the second window stays on top of the first window, because the user can close the second window and must have access to the first window.
Any ideas on a trick how to hide the first window, just the time, the second window appears?
Thanks in advance
NSDisableScreenUpdates and NSEnableScreenUpdates (link) might be useful in this situation. The documentation says:
You typically call this function so that operations on multiple windows appear atomic to the user.
which seems to describe your situation.
A word of unrelated advice though: Don't go setting window levels willy-nilly. A window level of 2003 will likely cause the window to appear over things like the dock or even the menu bar, which would definitely be strange. You should stick to the standard levels declared in NSWindow.h unless you have good reason. NSFloatingWindowLevel might be appropriate (although I'm not sure what level the SFAuthorizationPluginView window is displayed at).
Starting with MacOS 10.4, you can use :
[NSWindow disableScreenUpdatesUntilFlush];