sandin Posted September 20, 2007 Share Posted September 20, 2007 this is script example: expandcollapse popup#include <GUIConstants.au3> Global $i = 0, $j = 0, $k = 0 $Form1 = GUICreate("Title", 633, 447, 193, 115) $Button1 = GUICtrlCreateButton("AButton1", 184, 240, 225, 49, 0) GUICtrlSetResizing(-1,$GUI_DOCKTOP+$GUI_DOCKSIZE) $Button2 = GUICtrlCreateButton("AButton2", 184, 300, 225, 49, 0) GUICtrlSetResizing(-1,$GUI_DOCKTOP+$GUI_DOCKSIZE) $Label1 = GUICtrlCreateLabel("ALabel1", 64, 80, 43, 17) GUICtrlSetResizing(-1,$GUI_DOCKTOP+$GUI_DOCKSIZE) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 call("Func1") case $Button2 call("Func2") EndSwitch WEnd func adlib1 () $pos = ControlGetPos("Title", "", $Label1) if $j = 0 then call("right") $pos = ControlGetPos("Title", "", $Label1) if $pos[0] > 400 then $j = 1 Else call("left") $pos = ControlGetPos("Title", "", $Label1) if $pos[0] < 64 then $j = 0 EndIf EndFunc func right() $pos = ControlGetPos("Title", "", $Label1) ControlMove("Title", "", $Label1, $pos[0]+1, $pos[1]) EndFunc func left () $pos = ControlGetPos("Title", "", $Label1) ControlMove("Title", "", $Label1, $pos[0]-1, $pos[1]) EndFunc func func1 () if $i = 0 Then AdlibEnable("adlib1", 10) $i = 1 Else AdlibDisable() $i = 0 EndIf EndFunc func func2() if $k = 0 Then $pos = WinGetPos("Title") WinMove("Title", "", $pos[0], $pos[1], $pos[2], $pos[3]-50) $k = 1 Else $pos = WinGetPos("Title") WinMove("Title", "", $pos[0], $pos[1], $pos[2], $pos[3]+50) $k = 0 EndIf EndFunc my problem is following: if I launch adlib func with first button, the label will go right-left-right, etc... but if I try to change the size of the GUI (with second button), the label resets it's position on the beginning one (the one it had at the launching of the script). Can any1 help me change this so it will continue to work without reseting it's position if I change GUI's size? Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll Link to comment Share on other sites More sharing options...
wolf9228 Posted September 20, 2007 Share Posted September 20, 2007 this is script example: expandcollapse popup#include <GUIConstants.au3> Global $i = 0, $j = 0, $k = 0 $Form1 = GUICreate("Title", 633, 447, 193, 115) $Button1 = GUICtrlCreateButton("AButton1", 184, 240, 225, 49, 0) GUICtrlSetResizing(-1,$GUI_DOCKTOP+$GUI_DOCKSIZE) $Button2 = GUICtrlCreateButton("AButton2", 184, 300, 225, 49, 0) GUICtrlSetResizing(-1,$GUI_DOCKTOP+$GUI_DOCKSIZE) $Label1 = GUICtrlCreateLabel("ALabel1", 64, 80, 43, 17) GUICtrlSetResizing(-1,$GUI_DOCKTOP+$GUI_DOCKSIZE) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 call("Func1") case $Button2 call("Func2") EndSwitch WEnd func adlib1 () $pos = ControlGetPos("Title", "", $Label1) if $j = 0 then call("right") $pos = ControlGetPos("Title", "", $Label1) if $pos[0] > 400 then $j = 1 Else call("left") $pos = ControlGetPos("Title", "", $Label1) if $pos[0] < 64 then $j = 0 EndIf EndFunc func right() $pos = ControlGetPos("Title", "", $Label1) ControlMove("Title", "", $Label1, $pos[0]+1, $pos[1]) EndFunc func left () $pos = ControlGetPos("Title", "", $Label1) ControlMove("Title", "", $Label1, $pos[0]-1, $pos[1]) EndFunc func func1 () if $i = 0 Then AdlibEnable("adlib1", 10) $i = 1 Else AdlibDisable() $i = 0 EndIf EndFunc func func2() if $k = 0 Then $pos = WinGetPos("Title") WinMove("Title", "", $pos[0], $pos[1], $pos[2], $pos[3]-50) $k = 1 Else $pos = WinGetPos("Title") WinMove("Title", "", $pos[0], $pos[1], $pos[2], $pos[3]+50) $k = 0 EndIf EndFunc my problem is following: if I launch adlib func with first button, the label will go right-left-right, etc... but if I try to change the size of the GUI (with second button), the label resets it's position on the beginning one (the one it had at the launching of the script). Can any1 help me change this so it will continue to work without reseting it's position if I change GUI's size? expandcollapse popup#include <GUIConstants.au3> Global $i = 0, $j = 0, $k = 0 $Form1 = GUICreate("Title", 633, 447, 193, 115) $Button1 = GUICtrlCreateButton("AButton1", 184, 240, 225, 49, 0) GUICtrlSetResizing(-1,$GUI_DOCKTOP+$GUI_DOCKSIZE) $Button2 = GUICtrlCreateButton("AButton2", 184, 300, 225, 49, 0) GUICtrlSetResizing(-1,$GUI_DOCKTOP+$GUI_DOCKSIZE) $Label1 = GUICtrlCreateLabel("ALabel1", 64, 80, 43, 17) GUICtrlSetResizing(-1,$GUI_DOCKTOP+$GUI_DOCKSIZE) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 call("Func1") case $Button2 call("Func2") EndSwitch WEnd func adlib1 () $pos = ControlGetPos("Title", "", $Label1) if $j = 0 then call("right") $pos = ControlGetPos("Title", "", $Label1) if $pos[0] > 400 then $j = 1 Else call("left") $pos = ControlGetPos("Title", "", $Label1) if $pos[0] < 64 then $j = 0 EndIf EndFunc func right() $pos = ControlGetPos("Title", "", $Label1) ControlMove("Title", "", $Label1, $pos[0]+1, $pos[1]) EndFunc func left () $pos = ControlGetPos("Title", "", $Label1) ControlMove("Title", "", $Label1, $pos[0]-1, $pos[1]) EndFunc func func1 () if $i = 0 Then AdlibEnable("adlib1", 10) $i = 1 Else AdlibDisable() $i = 0 EndIf EndFunc func func2() if $k = 0 Then $posX = ControlGetPos("Title", "", $Label1) $pos = WinGetPos("Title") WinMove("Title", "", $pos[0], $pos[1], $pos[2], $pos[3]-50) $k = 1 ControlMove("Title", "", $Label1, $posX[0], $posX[1], $posX[2], $posX[3]) Else $posX = ControlGetPos("Title", "", $Label1) $pos = WinGetPos("Title") WinMove("Title", "", $pos[0], $pos[1], $pos[2], $pos[3]+50) $k = 0 ControlMove("Title", "", $Label1, $posX[0], $posX[1], $posX[2], $posX[3]) EndIf EndFunc ØµØ±Ø Ø§Ù„Ø³Ù…Ø§Ø¡ كان هنا  Link to comment Share on other sites More sharing options...
sandin Posted September 20, 2007 Author Share Posted September 20, 2007 heh, clever, thank you Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted September 20, 2007 Moderators Share Posted September 20, 2007 The code is full of Errors really... I was confused on what exactly you were trying to do, so I took a guess (added some error checking too because it was throwing errors)expandcollapse popup#include <GUIConstants.au3> Opt("GUIResizeMode", 802) Global $pos Global $i = 0, $j = 0, $k = 0 $Form1 = GUICreate("Title", 633, 447, 193, 115) $Button1 = GUICtrlCreateButton("AButton1", 184, 240, 225, 49, 0) GUICtrlSetResizing(-1,$GUI_DOCKTOP+$GUI_DOCKSIZE) $Button2 = GUICtrlCreateButton("AButton2", 184, 300, 225, 49, 0) GUICtrlSetResizing(-1,$GUI_DOCKTOP+$GUI_DOCKSIZE) $Label1 = GUICtrlCreateLabel("ALabel1", 64, 80, 43, 17) GUICtrlSetResizing(-1,$GUI_DOCKTOP+$GUI_DOCKSIZE) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 call("Func1") case $Button2 call("Func2") EndSwitch WEnd func adlib1 () $pos = ControlGetPos($Form1, "", $Label1) If IsArray($pos) Then if $j = 0 then call("right") $pos = ControlGetPos($Form1, "", $Label1) If IsArray($pos) And $pos[0] > 400 then $j = 1 Else call("left") $pos = ControlGetPos($Form1, "", $Label1) If IsArray($pos) And $pos[0] < 64 then $j = 0 EndIf EndIf EndFunc func right() $pos = ControlGetPos($Form1, "", $Label1) If IsArray($pos) Then ControlMove($Form1, "", $Label1, $pos[0]+1, $pos[1]) EndFunc func left () $pos = ControlGetPos($Form1, "", $Label1) If IsArray($pos) Then ControlMove($Form1, "", $Label1, $pos[0]-1, $pos[1]) EndFunc func func1 () if $i = 0 Then AdlibEnable("adlib1", 10) $i = 1 Else AdlibDisable() $i = 0 EndIf EndFunc func func2() if $k = 0 Then $pos = WinGetPos($Form1) If IsArray($pos) Then WinMove($Form1, "", $pos[0], $pos[1], $pos[2], $pos[3]-50) $k = 1 EndIf Else $pos = WinGetPos($Form1) If IsArray($pos) Then WinMove($Form1, "", $pos[0], $pos[1], $pos[2], $pos[3]+50) $k = 0 EndIf EndIf EndFuncI don't like the way you have everything named $pos though, and I changed the title "Title" you were using to the GUI's HWND Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
sandin Posted September 20, 2007 Author Share Posted September 20, 2007 thank you smoken, but in your script example 2nd button resets label's position, and in woolves scrip it does exaclty what I need. Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted September 20, 2007 Moderators Share Posted September 20, 2007 thank you smoken, but in your script example 2nd button resets label's position, and in woolves scrip it does exaclty what I need.Ok, I see what you wanted from his code... but I still suggest you do error checking, because I got GPF'd on both of your scripts because at some point, there wasn't an array. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now