Jump to content

Why doesn't this code work?


 Share

Recommended Posts

Please tell me why this code isn't working, it's supposed to move the window left by 1 each time left arrow is pushed...

HotKeySet("{LEFT}","left")

SplashImageOn("", $destination, 53, 34, 318, 224, 1)
$image = WinGetPos("")

Func left()
    WinMove("", -1, $image[0] - 1, $image[1])
EndFunc

Thanks in advance!

Link to comment
Share on other sites

  • Developers

Please tell me why this code isn't working, it's supposed to move the window left by 1 each time left arrow is pushed...

HotKeySet("{LEFT}","left")

SplashImageOn("", $destination, 53, 34, 318, 224, 1)
$image = WinGetPos("")

Func left()
    WinMove("", -1, $image[0] - 1, $image[1])
EndFunc

Thanks in advance!

Your script ends after the 3rd line.

add A while-wend loop with a sleep(10) to keep the script running...

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

I think I already have that at the bottom? That was just a sliver of my code, I thought we could work it out from that... here is my whole code.

$g_szVersion = "Test"
If WinExists($g_szVersion) Then Exit
AutoItWinSetTitle($g_szVersion)

$destination = @TempDir & "\x.bmp"
FileInstall("C:\x.bmp", $destination)

#include <GUIConstants.au3>
Global $Start

GUICreate ( "Test", 500, 153 )
GUISetState (@SW_SHOW)

$exitbutton = GUICtrlCreateButton( "Exit", 270, 102, 100, 22 )
HotKeySet("{HOME}","start")
HotKeySet("{LEFT}","left")
;HotKeySet("{RIGHT}","right")
;HotKeySet("{UP}","up")
;HotKeySet("{DOWN}","down")

SplashImageOn("", $destination, 53, 34, 318, 224, 1)
$image = WinGetPos("")

Func start()
    $Start = NOT $Start
    While $Start
        $coord = PixelSearch( $image[0] - 52, $image[1] - 33, $image[0] + 52, $image[1] + 33, 0xFF0000, 2, 2 )
        If not @error Then
            mouseclick( "left", $coord[0], $coord[1], 1, 0 )
            sleep(2000)
            mousemove( 710, 370, 3 )
            sleep(200)
            mouseclick( "right", 710, 370, 1, 1 )
            mousemove ( 710, 430, 3 )
            sleep(200)
            mouseclick( "left", 710, 430, 1, 1 )
            sleep(50)
            mousemove( $coord[0], $coord[1], 3 )
        Else
            sleep(50)
        EndIf
    WEnd
EndFunc

Func left()
    WinMove("", -1, $image[0] - 1, $image[1])
EndFunc

While 1
  $msg = GUIGetMsg()
  
  Select
  Case $msg = $GUI_EVENT_CLOSE
      Exitloop
      
  Case $msg = $exitbutton
      Exitloop
  EndSelect
WEnd
Link to comment
Share on other sites

Copy this line "$image = WinGetPos("")" to inside your loop and give your SplashImage a title and use it in the WinGetPos and WinMove commands. It worked for me.

Edit

Here is a copy that worked for me modified to remove fileinstall as I do not have your bitmap.

$g_szVersion = "Test"
If WinExists($g_szVersion) Then Exit
AutoItWinSetTitle($g_szVersion)

$destination = @Systemdir & "\oobe\images\mslogo.jpg"
;FileInstall("C:\x.bmp", $destination)

#include <GUIConstants.au3>
Global $Start

GUICreate ( "Test", 500, 153 )
GUISetState (@SW_SHOW)

$exitbutton = GUICtrlCreateButton( "Exit", 270, 102, 100, 22 )
HotKeySet("{HOME}","start")
HotKeySet("{LEFT}","left")
;HotKeySet("{RIGHT}","right")
;HotKeySet("{UP}","up")
;HotKeySet("{DOWN}","down")

SplashImageOn("Splash", $destination, 53, 34, 318, 224, 1)
$image = WinGetPos("Splash")

Func start()
    $Start = NOT $Start
    While $Start
        $coord = PixelSearch( $image[0] - 52, $image[1] - 33, $image[0] + 52, $image[1] + 33, 0xFF0000, 2, 2 )
        If not @error Then
            mouseclick( "left", $coord[0], $coord[1], 1, 0 )
            sleep(2000)
            mousemove( 710, 370, 3 )
            sleep(200)
            mouseclick( "right", 710, 370, 1, 1 )
            mousemove ( 710, 430, 3 )
            sleep(200)
            mouseclick( "left", 710, 430, 1, 1 )
            sleep(50)
            mousemove( $coord[0], $coord[1], 3 )
        Else
            sleep(50)
        EndIf
    WEnd
EndFunc

Func left()
    WinMove("Splash", "", $image[0] - 1, $image[1])
EndFunc

While 1
    $image = WinGetPos("Splash")
  $msg = GUIGetMsg()
  
  Select
  Case $msg = $GUI_EVENT_CLOSE
      Exitloop
      
  Case $msg = $exitbutton
      Exitloop
  EndSelect
WEnd
Edited by BigDod


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

  • Moderators

give the splashimage a title.

Edit:

BigDod beat me to it!

Edited by SmOke_N

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

That was just a sliver of my code, I thought we could work it out from that...

:P

Yes yes yes, there it was. Youth must go, ah yes. But youth is only being in a way like it might be an animal. No, it is not just being an animal so much as being like one of these malenky toys you viddy being sold in the streets, like little chellovecks made out of tin and with a spring inside and then a winding handle on the outside and you wind it up grrr grrr grrr and off it itties, like walking, O my brothers. But it itties in a straight line and bangs straight into things bang bang and it cannot help what it is doing. Being young is like being like one of these malenky machines.

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...