A_ScreenWidth & Variable not set confusion

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
kjustice
Posts: 2
Joined: 29 Apr 2024, 08:58

A_ScreenWidth & Variable not set confusion

Post by kjustice » 29 Apr 2024, 09:18

I get the following Warning:
Warning: This variable appears to never be assigned a value.

Specifically: local MoveWindow

031: }
033: {
▶ 034: MoveWindow(0, 0, (A_ScreenWidth * 0.5), A_ScreenHeight)
035: }
037: {

For more details, read the documentation for #Warn.

on the following code. Note: I have a lot more code but have commented it all out to try to figure this out. So the 1 key macro works and tells me the screen dimensions. Why would the MoveWindow fail with that error? I've dug around and can't find any reason...

Code: Select all

#SingleInstance Force
#Requires AutoHotkey >=2.0
/* Warn VarUnset, Off  */

; variable declarations
 global mon_count := 0
 global mon_pri := 0
 global arr_mon_top := []
 global arr_mon_right := []
 global arr_mon_bottom := []
 global arr_mon_left := []
 global win_count := 0
 global arr_win_id := []
 global arr_win_mon := []
 global arr_win_x := []
 global arr_win_y := []
 global arr_win_width := []
 global arr_win_height := []
 global arr_win_xpct := []
 global arr_win_ypct := []
 global arr_win_widthpct := []
 global arr_win_heightpct := []
 global arr_win_minmax := []

; shortcodes
;Symbol Description 
;# Win (Windows logo key). 
;! Alt 
;^ Control 
;+ Shift 
^!1:: msgbox A_ScreenHeight . " height " . A_ScreenWidth . " width "
^+4::
{
	MoveWindow(0, 0, (A_ScreenWidth * 0.5), A_ScreenHeight)
}
^!5::
{
MoveWindow(Random(A_ScreenWidth * 0.02, A_ScreenWidth * 0.15), Random(A_ScreenWidth * 0.02, A_ScreenWidth * 0.3), (A_ScreenWidth * 0.5), (A_ScreenHeight * 0.5))
}

User avatar
boiler
Posts: 17146
Joined: 21 Dec 2014, 02:44

Re: A_ScreenWidth & Variable not set confusion

Post by boiler » 29 Apr 2024, 09:51

kjustice wrote:
29 Apr 2024, 09:18
I get the following Warning:
Warning: This variable appears to never be assigned a value.

Specifically: local MoveWindow
...
Why would the MoveWindow fail with that error? I've dug around and can't find any reason...
Dig more carefully. There's no such function as MoveWindow. There is WinMove.

kjustice
Posts: 2
Joined: 29 Apr 2024, 08:58

Re: A_ScreenWidth & Variable not set confusion

Post by kjustice » 29 Apr 2024, 09:54

Yep I goofed. I needed to understand reading the error's more carefully...

Post Reply

Return to “Ask for Help (v2)”