Jump to content

WinMove Problem


James
 Share

Recommended Posts

Hey,

Some of you may of seen my other post "GUI Questions". I have so far made a script which will create an input box on your screen. You can then type in commands and it will do something, currently on a MsgBox for some random tests. But I have one problem with moving the GUI so that its always in the same place:

Posted Image

Here is the current script that will work only on 1024x768 or higher (if higher it wont be in the right place)

#include <GuiConstants.au3>
#NoTrayIcon

$sGUI = GuiCreate("WinBar App", 100, 20, @DesktopWidth / 2 + 320, @DesktopHeight / 170, BitOR($WS_POPUP, $WS_EX_TOPMOST),$WS_EX_TOOLWINDOW)
$sInput = GUICtrlCreateInput("", -1, -1, 102, 22)

GuiSetState()
WinSetOnTop($sGUI, "", 1)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $sInput
            $sRead = GuiCtrlRead($sInput)
            ToDo()
    EndSwitch
Wend

Func ToDo()
    If $sRead = "help" Then MsgBox(0, "Help", "You need help?")
    If $sRead = "lol" Then MsgBox(0, "Lol?", "Why are you laughing")
EndFunc

Thanks,

Secure

Link to comment
Share on other sites

  • Moderators

You'll need to run a seperate script if it's an actual InputBox or MsgBox, your script pauses waiting for the input of those 2 functions. You could look at AutoIt3ExecuteScript or AutoIt3ExecuteLine for this.

I've (as well as others) have given some examples of how to implement similar things.

Here's one example:

http://www.autoitscript.com/forum/index.ph...st&p=187268

And this may help as well (same thread):

http://www.autoitscript.com/forum/index.ph...st&p=187372

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

Smoke, I cant seem to work it out...

I did however try before you showed me that to do it like:

#include <GuiConstants.au3>
#NoTrayIcon

$sGUI = GuiCreate("WinBar App", 100, 20, @DesktopWidth / 2 + 320, @DesktopHeight / 170, BitOR($WS_POPUP, $WS_EX_TOPMOST),$WS_EX_TOOLWINDOW)
$sInput = GUICtrlCreateInput("", -1, -1, 102, 22)
GUICtrlSetLimit($sInput, 20)

GuiSetState()
WinSetOnTop($sGUI, "", 1)
_WinMove()

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $sInput
            $sRead = GuiCtrlRead($sInput)
            ToDo()
    EndSwitch
Wend

Func ToDo()
    If $sRead = "help" Then MsgBox(0, "Help", "You need help?")
    If $sRead = "lol" Then MsgBox(0, "Lol?", "Why are you laughing")
EndFunc
    
Func _WinMove()
    If @DesktopHeight = 1024 Then WinMove($sGUI, "", @DesktopHeight / 2 + 320, @DesktopWidth / 170)
    If @DesktopHeight = 800 Then WinMove($sGUI, "", @DesktopHeight / 2 + 170, @DesktopWidth / 85)
EndFunc

But that didn't work. It makes perfect sense how I did it, to me.

Link to comment
Share on other sites

  • Moderators

Can you tell me exactly what you want to do (I think I understand but don't want to waste my time writing the wrong option), and where in the script should what you want be executed (not just where, but under what circumstance)?

P.S.... the snippet above doesn't show where you tried in the 8 minutes (between replying to what I said, replying to Jon's remark in the 300k post thread) where you actually tried to implement /AutoIt3ExecuteScript.

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

I want the program to basically sit next to the buttons on the top right of any window. It doesn't have to sit on a titlebar but it can sit on the desktop in the same place.

I have looked at that post before. While I was searching for WinMove help, but I couldn't get it working.

Edit: Yeah, the snippet doesn't have any code in because I couldn't figure out which bit goes where.

Edited by Secure_ICT
Link to comment
Share on other sites

  • Moderators

I want the program to basically sit next to the buttons on the top right of any window. It doesn't have to sit on a titlebar but it can sit on the desktop in the same place.

I have looked at that post before. While I was searching for WinMove help, but I couldn't get it working.

Edit: Yeah, the snippet doesn't have any code in because I couldn't figure out which bit goes where.

What program?

I understand why you're having issues if you can't explain it. Pretend I'm 5 and I understand nothing (last part may not be far from the truth). You leave bits and pieces out and add new ones every post.

Now the above description you gave, makes absolutely no sense from the first post you have asking the original question.

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

Yeah, thats because I forgot to add it... My bad.

Right lets start again. Basically, I want to make my script auto move to around about the same distance from the buttons on the top right of a window. Its always in the top right even if its a small window. Its always in the same place. Now when you minimize all of your windows and you see your desktop, its still in the same place.

But, I am having problems making the script move to the right place if the screen resolution is different to 1024x768.

Better?

Link to comment
Share on other sites

Yes, I know those Macro's and I have tried using them, but it doesn't set it all correctly.

Notice?

Func _WinMove()
    If @DesktopHeight = 1024 Then WinMove($sGUI, "", @DesktopHeight / 2 + 320, @DesktopWidth / 170)
    If @DesktopHeight = 800 Then WinMove($sGUI, "", @DesktopHeight / 2 + 170, @DesktopWidth / 85)
EndFunc
Link to comment
Share on other sites

  • Moderators

WinGetPos() x ([0]) and y ([1])

WinMove(gui, '', x, y)

If I'm understanding you right, should be all you need.

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

  • Moderators

Hmm.. So this goes in my function. And then.. Nope.. I don't get it. Sorry Smoke. I bet it is really easy, but I dont do things like this normally.

This is where my "attempting" to help stops completely for this and any project.

You spent less than 2 minutes even trying to figure it out.... you have 800+ posts wtf! :whistle:

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...