Page 1 of 1

A_ScreenWidth & Variable not set confusion

Posted: 29 Apr 2024, 09:18
by kjustice
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))
}

Re: A_ScreenWidth & Variable not set confusion

Posted: 29 Apr 2024, 09:51
by boiler
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.

Re: A_ScreenWidth & Variable not set confusion

Posted: 29 Apr 2024, 09:54
by kjustice
Yep I goofed. I needed to understand reading the error's more carefully...