I need to resize Google Hangouts app in Win 10. through Autohotkey
Currently it is 260*460, and I need it to be 1150*750.
Here are the Window spy data:
>>>>>>>>>>( Window Title & Class )<<<<<<<<<<<
Hangouts
ahk_class Chrome_WidgetWin_1
>>>>>>>>>>>>( Mouse Position )<<<<<<<<<<<<<
On Screen: 901, 600 (less often used)
In Active Window: -759, 580
>>>>>>>>>( Now Under Mouse Cursor )<<<<<<<<
Color: 0xF0F0F0 (Blue=F0 Green=F0 Red=F0)
>>>>>>>>>>( Active Window Position )<<<<<<<<<<
left: 1660 top: 20 width: 260 height: 460
>>>>>>>>>>>( Status Bar Text )<<<<<<<<<<
>>>>>>>>>>>( Visible Window Text )<<<<<<<<<<<
Chrome Legacy Window
>>>>>>>>>>>( Hidden Window Text )<<<<<<<<<<<
>>>>( TitleMatchMode=slow Visible Text )<<<<
>>>>( TitleMatchMode=slow Hidden Text )<<<<
I tried something like the following, but it didn't work:
[code]
#Persistent
Loop
{
WinWaitActive, ahk_class Chrome_WidgetWin_1
WinMove, ahk_class Chrome_WidgetWin_1, , 1150, 750
}
Return
[/code]
The WinMove command requires those arguments:
WinMove, WinTitle, WinText, X, Y [, Width, Height, ExcludeTitle, ExcludeText]
The arguments WinText, X and Y can be ommited in which case you leave them empty, but you still have to use the commas to indicate them.
You only left the argument WinText empty and the arguments with value 1150 and 750 got interpreted as arguments X and Y.
The solution is to add those two unused arguments X and Y:
WinMove, ahk_class Chrome_WidgetWin_1, , , , 1150, 750
If for example you want to also move the window to the positions 200, 100, then use the X and Y arguments as well:
WinMove, ahk_class Chrome_WidgetWin_1, , 200, 100, 1150, 750
; WinMove, WinTitle (or) ahk_class WinClass, WinText, X, Y , Width, Height, ExcludeTitle, ExcludeText
WinMove, ahk_class Chrome_WidgetWin_1, , , , 1150, 750
Related
I have simple script that looks for specified color pixel in restricted area then performs move mouse of this pixel to specified x,y coordinates it looks like this(control hold is added, because it needs to be pressed while moving stock):
#ifwinactive
F10::
PixelSearch, ItemX, ItemY, 1800, 600, 1700, 500, 0xFFE047, 1 , RGB FAST
if ErrorLevel = 0
Mousemove, ItemX, ItemY, 0
Send, {lbutton down}
sleep, 20
Send, {lctrl down}
Random x, 1600, 1700
Random y, 590, 655
Mousemove, x, y, 0
Send, {lbutton up}
Send, {lctrl up}
return
It works great but takes control over my MOUSE which I don't want, so I am trying to modify it to perform action without taking control over my mouse. I have tried to search, using controlclick but this couldn't handle dragging, then I have read about PostMessage which I don't clearly understand but I have come with this kind of script(not fully understand dll calls that's why most likely it doesn't work like intented):
#ifwinactive
x := 1650
y := 620
F10::
PixelSearch, ItemX, ItemY, 1900, 600, 1750, 500, 0xFFC661, 1, RGB Fast
CoordMode, Pixel, Screen
if !hWnd := DllCall("WindowFromPoint", Int,ItemX, Int,ItemY, Ptr)
if !hWnd := DllCall("WindowFromPoint", UInt64,(ItemX&0xFFC661)|(ItemY<<32), Ptr)
if !hWnd := DllCall("WindowFromPoint", UInt64, x|(y << 32), Ptr)
return
VarSetCapacity(POINT, 8, 0)
NumPut(ItemX, POINT, 0, "Int"), NumPut(ItemY, POINT, 4, "Int")
DllCall("user32\ScreenToClient", Ptr,hWnd, Ptr,&POINT)
ItemX := NumGet(POINT, 0, "Int"), ItemY := NumGet(POINT, 4, "Int")
if ErrorLevel
PostMessage, 0x0200, 0, ItemX&0xFFC661|ItemY<<16,, % "ahk_id " hWnd ;WM_MOUSEMOVE
sleep, 5
PostMessage, 0x0201, 0, ItemX&0xFFC661|ItemY<<16,, % "ahk_id " hWnd ;WM_LBUTTONDOWN
sleep, 5
PostMessage, 0x0200, 0, x|y<<16,, % "ahk_id " hWnd ;WM_MOUSEMOVE
sleep, 5
PostMessage, 0x0202, 0, x|y<<16,, % "ahk_id " hWnd ;WM_LBUTTONUP
sleep, 5
return
There is problem with this scirpt it actually act like this: Search for pixel>if it's there>perform post messages under my cursor(actually taking things under my mouse to specified x,y.
While what I want is to look for pixel, pick this pixel and move it. Is it even possible without taking control over my mouse?
EDIT!
NEW CODE
#ifwinactive
CoordMode, Pixel , Screen
x := 1650
y := 620
lparam := pX | (pY << 16)
lparam2 := x | (y << 16)
f10::
PixelSearch, pX, pY, 1900, 1000, 1750, 500, 0xFFE047, 1, Fast
if Errorlevel
{
PostMessage, 0x0200, 0, %lparam%,, ahk_exe something.exe ;WM_MOUSEMOVE
sleep, 10
PostMessage, 0x0201, 0x0001, %lparam%,, ahk_exe something.exe ;WM_LBUTTONDOWN
sleep, 10
PostMessage, 0x0200, 0x0001, %lparam2%,, ahk_exe something.exe ;WM_MOUSEMOVE
sleep, 10
PostMessage, 0x0202, 0, %lparam2%,, ahk_exe something.exe ;WM_LBUTTONUP
}
return
I have 2 scripts I want to merge in one file, however when I put them together, only the first one gets executed:
Script 1:
#if WinActive("ahk_exe program.EXE")
#Persistent
Loop
{
WinWaitActive, Wizard
Send, !{F4}
}
Return
Script 2:
#if WinActive("ahk_exe program2.EXE")
#Persistent
Loop
{
WinWait, ahk_class bosa_sdm_Mso96
; IfWinNotActive, ahk_class bosa_sdm_Mso96, ,WinActivate, ahk_class bosa_sdm_Mso96
; WinWaitActive, ahk_class bosa_sdm_Mso96
; Sleep, 0
ControlMove, RichEdit20W6, 20, 850, 750, 25 ;Adress box
ControlMove, SysTreeView321, , , 800, 700
ControlMove, TreeViewCFParent1, , , 1000, 700
ControlMove, SysTreeView322, , , 800, 700
ControlMove, TreeViewParent1, , , 760, 940
WinMove, ahk_class bosa_sdm_Mso96, , 600, 50, 1000, 900 ; 900 width
}
Return
I tried removing or changing the location of "#Persistent", "Loop", "Return".. or adding #if at the end of each script.. still only the first one gets executed.. Even when trying to #Include the first script in the second, the first only gets executed. Maybe it needs "else" or something.. not sure..
The #If directive is only used for creating context-sensitive hotkeys and hotstrings.
If you use WinWait or WinWaitActive the script waits until the (first) window exists or becomes active and doesn't go any further to move the second window.
Without WinWait the CPU usage of the script is high.
The better solution in this case is SetTimer:
#Persistent
SetTimer, Close_Move_Windows, 500
return
Close_Move_Windows:
IfWinActive, Wizard
WinClose
IfWinExist, ahk_class bosa_sdm_Mso96
{
WinGetPos, X, Y, Width, Height, ahk_class bosa_sdm_Mso96
If (X != 600 || Y != 50 || Width != 900 || Height != 1000) ; "!" means "NOT" and "||" means "OR"
{
ControlMove, RichEdit20W6, 20, 850, 750, 25 ;Adress box
ControlMove, SysTreeView321, , , 800, 700
ControlMove, TreeViewCFParent1, , , 1000, 700
ControlMove, SysTreeView322, , , 800, 700
ControlMove, TreeViewParent1, , , 760, 940
WinMove, ahk_class bosa_sdm_Mso96,, 600, 50, 900, 1000 ; 900 width
}
}
Return
I have 2 repeating actions that I want constantly waiting. Specifically, there are a couple of windows that, when they appear, I want AutoHotkey to perform an action on. For example, I want to move and resize the window with title "Window 1", and send a y keypress to "Window 2". So I have this:
win1.ahk
While, 1
{
WinWaitActive, Window 1
WinMove, Window 1, , 100, 100, 800, 600
}
win2.ahk
While, 1
{
WinWaitActive, Window 2
send y
}
My question is whether it is possible to put multiple such actions in the same AutoHotkey script. If I have 30 different windows that I want to wait on, do I need 30 individual .ahk scripts with this format, or is it possible to register several actions all in a single script?
No, just one script with a timer and a switch (a switch per action if you're sending keystrokes so they don't repeatedly send). Example, take out the notepadSentKey variable and see what happens when you open a new notepad.
#Persistent
SetTimer, DoStuff, 100
notepadSentKey := false
return
DoStuff:
{
IfWinActive, % "Untitled - Notepad"
{
WinMove, A,, 0, 0, 500, 200
if (!notepadSentKey) {
Send, Hello there{!}
notepadSentKey := true
}
}
IfWinActive, % "Calculator"
{
WinGetPos, x, y, w, h
WinMove, A,, % (A_ScreenWidth/2)-(w/2), % (A_ScreenHeight/2)-(h/2)
}
return
}
I am using two monitors and the message boxes always appear in the middle of the primary screen, regardless of where the active window is.
How can I specify the position of a Splash Text box or Message box so that it shows in the middle of the active window, not in the middle of the primary monitor?
You can try this:
#Persistent
AppName=Move
Menu, Tray, Tip, %AppName%
Menu, Tray, Icon , Shell32.dll, 26, 1 ; 45, 28, 113, 74, 134
^w::
WinGetPos, X, Y, Width, Height, A
Mx:=X + (Width/2) -100
My:=Y + (Height/2) -100
SetTimer, MoveMsgBox, -50
MsgBox, ,%AppName%, %X% %Y% OK
Return
MoveMsgBox:
WinMove, %AppName%, , %Mx% , %My%
Return
In a specific program, I want to assign a hotkey to the action of right clicking at the cursor's current position, then moving the cursor to choose an item on that menu, then moving the cursor again to choose an item on the sub-menu. I've gotten as far as the first two commands. When I get to the mousemove, no matter what coordinates I put in, the cursor shoots to the upper left corner of the screen, when what I would like it to do is first move 100 pixels to the right and 60 pixels up, then 100 pixels to the right, zero pixels on the y-axis. Clearly I am misunderstanding something. Please advise.
Thanks,
Ellen
s::
MouseGetPos
Click right
sleep, 100
MouseMove, 60, -60, 5, R
Sleep, 100
MouseMove, 200, 0, 5, R
MouseClick, L
return
Ellen, first of all, if at all possible try if you could use keyboard shortcuts.
Please check: Control Panel\Ease of Access Center\Make the keyboard easier to use\Underline keyboard shortcuts and access keys. This will show the shortcuts that you can use. This way you might even find the keyboard shortcut for the menu, instead of using the mouse location.
^+b:: ; Record the location of the menu at the beginnin with [Shift]+[Ctrl]+b
SoundBeep, 500, 500
ToolTip, Click on the "XYZ" Link
KeyWait, LButton, D
MouseGetPos, xPos, yPos
Send, {Esc}
ToolTip
Return
^b::
MouseClick, Right, xPos, yPos
;Mousemove, 100, 60 R
Send, e : OR WHATEVER Shortcut letter OR.....
Send, {Down 3}{Enter} ; IF you want to use down arrow 3 times to get to the item.
Return
Modified, where YOU have to position the mouse on the always changing menu position.
^b::
MouseClick, Right ; presses where the mouse is located
;Mousemove, 100, 60 R
Send, e : OR WHATEVER Shortcut letter OR.....
Send, {Down 3}{Enter} ; IF you want to use down arrow 3 times to get to the item.
Return
If you can identify the menu ID (with AHK Windows Spy, place the mouse over the menu and look at "under the mouse"), you could use controlsend. This would be location independent since controlsend will use the menu ID to send a signal. If you tell me which application you try to control, I could see if controlSend could be used....
Oh b.t.w. I did not know you used XP, the enable shortcut instructions were for Windows 7.
Shouldn't Mousemove be MouseMove instead? It's like that in the docs.
This AutoHotkey script, including a user-created AutoHotkey function should do what you require.
It automates right-clicking a program, and then selecting 3 items on subsequent menus.
The script has been written to work on Media Player Classic,
but certain lines just need to be edited to make it work for your program, TypeTool 3. You specify a comma-separated list with one or more items, i.e. the name of the item to choose in the first menu, and in the second menu item etc.
The vast majority of programs use standard context menus,
so it should work on your program; this is in contrast
to menu bars and other types of controls/resources that vary more between programs.
-
;note: requires Acc.ahk library in AutoHotkey\Lib folder
;https://github.com/Drugoy/Autohotkey-scripts-.ahk/blob/master/Libraries/Acc.ahk
;on right of screen right-click Raw, Save target as...
;the currently assigned hotkey is ctrl+q
;e.g. Media Player Classic, open right-click menu, click items
#IfWinActive, ahk_class MediaPlayerClassicW
^q::
WinGet, hWnd, ID, A
WinGetClass, vWinClass, ahk_id %hWnd%
if vWinClass not in MediaPlayerClassicW
Return
CoordMode, Mouse, Screen
MouseGetPos, vPosX2, vPosY2
WinGetPos, vPosX, vPosY, vPosW, vPosH, ahk_id %hWnd%
vPosX := Round(vPosX + vPosW/2)
vPosY := Round(vPosY + vPosH/2)
MouseMove, %vPosX%, %vPosY%
vList = View,On Top,Default
MenuRCSelectItem(vList)
MouseMove, %vPosX2%, %vPosY2%
Return
#IfWinActive
;===============
MenuRCSelectItem(vList, vDelim=",", vPosX="", vPosY="", vDelay=0)
{
DetectHiddenWindows, Off
CoordMode, Mouse, Screen
MouseGetPos, vPosX2, vPosY2
(vPosX = "") ? (vPosX := vPosX2)
(vPosY = "") ? (vPosY := vPosY2)
if !(vPosX = vPosX2) OR !(vPosY = vPosY2)
MouseMove, %vPosX%, %vPosY%
Click right
Loop, Parse, vList, %vDelim%
{
vTemp := A_LoopField
WinGet, hWnd, ID, ahk_class #32768
if !hWnd
{
MsgBox error
Return
}
oAcc := Acc_Get("Object", "1", 0, "ahk_id " hWnd)
Loop, % oAcc.accChildCount
if (Acc_Role(oAcc, A_Index) = "menu item")
if (oAcc.accName(A_Index) = vTemp)
if (1, oRect := Acc_Location(oAcc, A_Index), vIndex := A_Index)
break
vPosX := Round(oRect.x + oRect.w/2)
vPosY := Round(oRect.y + oRect.h/2)
MouseMove, %vPosX%, %vPosY%
Sleep %vDelay% ;optional delay
oAcc.accDoDefaultAction(vIndex)
WinWaitNotActive, ahk_id %hWnd%, , 6
if ErrorLevel
{
MsgBox error
Return
}
}
MouseMove, %vPosX2%, %vPosY2%
Return
}
;==================================================