Sign in to follow this  
Followers 0
Jilo

Help. how combine two data to one

3 posts in this topic

Hello.

Well I am not really know how to explain this situation that i have. I want to get a data from a insert box and combine it with other text to find a function.

i probably write confuse somehow. here is my code

 

#include <MsgBoxConstants.au3>
#include <GUIConstantsEx.au3>
#include <EditConstants.au3>

GUICreate("HOME",300,500,1011,20)

Local $HouseX = "$HouseX"

Local $HouseY = "$HouseY"
Local $HouseX1= String(100)
Local $HouseY1= String(200)

Local $HouseX2 = String(300)

Local $HouseY2 = String(400)

GUICreate("HOME",300,500,1011,20)


$Design = GUICtrlCreateInput ("",60,95,20,20,$ES_NUMBER)
GUISetState(@SW_sHOW)


Local $mouseclickX, $mouseclickY,$idMsg
 GUICtrlSetData($mouseclickX , "$HouseX"&GUICtrlRead($Design))

 GUICtrlSetData($mouseclickY , "$HouseY"&GUICtrlRead($Design))

   While 1
    $idMsg = GUIGetMsg()
    Select
        Case $idMsg = $GUI_EVENT_CLOSE
            ExitLoop

      Case $idMsg = $Design
      Mouseclick("left",$mouseclickX,$mouseclickY)

      MsgBox($MB_SYSTEMMODAL, "", "You have choose: " & "$HouseX"&GUICtrlRead($Design))
      MsgBox($MB_SYSTEMMODAL, "", "You have choose: " & "$HouseY"&GUICtrlRead($Design))

   EndSelect

    WEnd
GUIDelete()

 

This is my code.... and it not working. i am really have no idea why it not working. if i put "1" in inputbox, i want the mouse to click on x = 100 and y = 200. or put "2" in inputbox, my mouse choose click on (300,400). However in message box it show $HouseX1 and $HouseY1 or $HouseX2 and $HouseY2. but my mouse move to default position (0,0)

Please kinddly tell me why and how to make my code working. i am try for 2 days now but it seem that i can not make it work :(

thank you
 

Share this post


Link to post
Share on other sites



A bit confusing but I think I understand what you're trying to do. You can do this a couple of ways, you could use the functions IsDeclared and Eval to make some really short code, or you could use a switch based on the input

#include <MsgBoxConstants.au3>
#include <GUIConstantsEx.au3>
#include <EditConstants.au3>

GUICreate("HOME",300,500,1011,20)

Local $HouseX = "HouseX"

Local $HouseY = "HouseY"
Local $HouseX1 = 100
Local $HouseY1 = 200

Local $HouseX2 = 300
Local $HouseY2 = 400

$hGui = GUICreate("HOME",300,500,1011,20)


$Design = GUICtrlCreateInput ("",60,95,40,20,$ES_NUMBER)
$btnActivate = GUICtrlCreateButton("Activate", 10, 10, 75, 20)
$lblDebug = GUICtrlCreateLabel("", 10, 35, 280, 40)
GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            GUIDelete($hGui)
            Exit(0)

        Case $btnActivate
            $iCase = GUICtrlRead($Design)
            ; Case 1, using IsDeclared and Eval
            ; IsDeclared checks to see if there is a variable that's been declared
            If (IsDeclared($HouseX & $iCase) and IsDeclared($HouseY & $iCase)) Then
                GUICtrlSetData($lblDebug, "The variables " & $HouseX & $iCase & " and " & $HouseY & $iCase & " are declared" & @CRLF & "Using X " & Eval($HouseX & $iCase) & " and Y " & Eval($HouseY & $iCase))
                ; Eval returns the value from the variable
                MouseClick("Left", Eval($HouseX & $iCase), Eval($HouseY & $iCase))
            Else
                GUICtrlSetData($lblDebug, "The variables $" & $HouseX & $iCase & " and $" & $HouseY & $iCase & " are not declared, thus not valid")
            EndIf
            #cs
            ; Case 2, using a switch
            Switch $iCase
                Case 1
                    GUICtrlSetData($lblDebug, "Using variables $" & $HouseX & $iCase & " and $" & $HouseY & $iCase)
                    MouseClick("Left", $HouseX1, $HouseY1)
                Case 2
                    GUICtrlSetData($lblDebug, "Using variables $" & $HouseX & $iCase & " and $" & $HouseY & $iCase)
                    MouseClick("Left", $HouseX2, $HouseY2)
                Case Else
                    GUICtrlSetData($lblDebug, "The variables $" & $HouseX & $iCase & " and $" & $HouseY & $iCase & " are not valid")
            EndSwitch
            #ce
    EndSwitch
WEnd

 

Share this post


Link to post
Share on other sites

Thank you very much for fast reply. I will go try both of the way you teach me now. but i think Case 1 would be more what i been looking for since i will do it with more data not just 2 choices. 

many thanks :) 

Share this post


Link to post
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
Sign in to follow this  
Followers 0