I'm facing a conditional test problem I can't figure out ... It's certainly obvious to more trained eyes than mine so this might be a quick fix from anyone who'd fancy help me
When I click on my button Send_to_Next_Monitor, it sends my GUI to monitor 2. When I click it again, it should send it back to monitor 1. And I can't make it work ...
Here's the complete code for my tests :
Code: Select all
#NoEnv
#SingleInstance force
#Warn
; ===============================================
; Variables
; ===============================================
; Main UI settings
; ===============================================
Gui_Number := 1
OffsetX := 50, OffsetY := 25
Xpos := 1000, Ypos := 100
MarginY := 10
Font_Face := "Verdana" ; main font name
; ===============================================
; Main Gui layout
; ===============================================
Gosub, Create_Window ; Jumps to the 'Create_Window' label and continues execution until Return is encountered
Gui, 1:Add, Button, -Tabstop ys wp hp gButton_Settings, Settings
Gui, 1:Show, AutoSize
Return
; ===============================================
;Labels
; ===============================================
;New popup
; ===============================================
Button_NewWindow:
WinGetPos, Xpos, Ypos
Xpos += OffsetX, Ypos += OffsetY
; GUI generation code
; ===============================================
Create_Window:
Gui, Margin,, 10
Gui, %Gui_Number%:Default
Gui, -Caption +Border +AlwaysOnTop
Gui, Color, cFFFFFF
Gui, Font, , %Font_Face%
Gui, Add, Text, xm ym +BackgroundTrans, SCH - [Instance%Gui_Number%]
Gui, Add, Edit, xm y+10 Uppercase limit10 w80 h25 vIM, IM
Gui, Add, Button, Section xs w100 h25 gButton_NewWindow, New Window
Gui, Font,s15, Wingdings 3
Gui, Add, Button, -Tabstop ys wp hp gSend_to_Next_Monitor, D
Gui, Font, ,
Gui, Font, , %Font_Face%
Gui, Add, Button, ys wp hp gGuiClose, &Close
Gui, Show, x%Xpos% y%Ypos% AutoSize, Test
Gui_Number++
return
GuiClose:
if (A_GUI = 1)
ExitApp
PostMessage, 0x112, 0xF060
return
Button_Settings:
Return
; Move Windows - switch monitor
; ===============================================
Send_to_Next_Monitor:
Gui, Submit, NoHide
Monitor_pos := 1
If(Monitor_pos = 2)
{
WinGetPos, Xpos
Xpos := Xpos - 1000
WinMove, % Xpos
Monitor_pos := 1
; Tooltip, Xpos = %Xpos% -- Monitor = %Monitor_pos% --
; Sleep 5000
; Tooltip,
}
Else
{
WinGetPos, Xpos
Xpos := Xpos + 1000
WinMove, % Xpos
Monitor_pos := 2
; Tooltip, Xpos = %Xpos% -- Monitor = %Monitor_pos% --
; Sleep 5000
; Tooltip,
}
Return
; ===============================================
;Functions
; ===============================================
; ===============================================
; Hotkeys
; ===============================================
f11::listvars
Thank you very much for your help!