Sign in to follow this  
Followers 0
NutherNoob

Putting it together

8 posts in this topic

#1 ·  Posted (edited)

This should be real easy but the last parts have realy got me. How do I loop them in order? How do I assign the right values to the right arrays? Can any1 help as I'd like to put this to bed once and for all :)

Description of my ideas is in the script.

Any help much appreciated.

#include <GUIConstants.au3>
#Include <Misc.au3>
#include <Date.au3>

AutoItSetOption("MouseCoordMode", 1)
;Use Mouse Coordinates relative to:
;1-rel to screen

    HotKeySet("{PAUSE}", "Terminate")
    HotKeySet("{ENTER}", "Paste")
    
;master gui vars
$master_gui_width = 285
$master_gui_hight = 270

; variables group
$default_group_width = 200
$x_var_group = 5
$y_var_group = 10
$var_group_width = $default_group_width
$var_group_hight = $master_gui_hight - 100
;positions vars group
$pdefault_group_width = ($master_gui_width - $default_group_width)
$px_var_group = 206
$py_var_group = 10
$pvar_group_width = $pdefault_group_width -10
$pvar_group_hight = $master_gui_hight - 100

; = END DEFINE VARIABLES

; ===== START MASTER GUI
GUICreate("=- Test -=", $master_gui_width, $master_gui_hight , -1, -1, -1)
GUISetState ()
WinSetOnTop("=- Test -=", "", 1)


; MENU
GuiCtrlCreateMenu("Menu &One")
GuiCtrlCreateMenu("Menu &Two")


GUICtrlCreateGroup ("Times", $x_var_group , $y_var_group , $var_group_width , $var_group_hight)
GUICtrlCreateGroup ("",-99,-99,1,1) ;close group

GUICtrlCreateGroup ("Positions", $px_var_group , $py_var_group , $pvar_group_width , $pvar_group_hight)
GUICtrlCreateGroup ("",-99,-99,1,1) ;close group

;Hrs, secs title
$widthCell=100
GUICtrlCreateLabel ("Hrs.  Mins.  Secs.", 50 , 30, $widthCell)

Local Const $NumTimeFields = 3 ; can be up to 10
Local $HourFields[$NumTimeFields]
Local $MinuteFields[$NumTimeFields]
Local $SecondFields[$NumTimeFields]
Local $ProgressBar[$NumTimeFields]
Local $CoordsField[$NumTimeFields]
Local $Sec, $Min, $Hour, $Time 

$widthCellb=40
$diff=22

For $I = 0 To $NumTimeFields - 1
    Local $Y = $y_var_group + $diff * ($I + 2) - 3
    Local $Label = 'Eg ' & $I + 1 & '.'
    GUICtrlCreateLabel($Label, $x_var_group + 2, $Y +3, $widthCellb)
    $HourFields[$I]       = GUICtrlCreateInput('', 50, $Y, 18, 17, $ES_NUMBER)
    $MinuteFields[$I]     = GUICtrlCreateInput('', 79, $Y, 18, 17, $ES_NUMBER)
    $SecondFields[$I]     = GUICtrlCreateInput('', 108, $Y, 18, 17, $ES_NUMBER)
    $ProgressBar[$I]      = GuiCtrlcreateProgress(130, $Y+2, 70, 13)
    $CoordsField[$I]      = GUICtrlCreateinput("", 213, $Y, 60, 17)
Next
$start=GUICtrlCreateButton("START", 228, $Y + 100, 45, 30) 
GUICtrlSetOnEvent($start,"Start")
GuiSetState(@SW_SHOW)

;When Start button clicked.....
;Checks for any x,y coords in coords fields, if none, Error msg
;Loop.....Right Clicks coords from 1st coords box and waits the specified time showing tooltip countdown
;When countdown reaches 0, clicks 2nd coords box and countsdown until all finished ......endloop


While 1
    $pos = MouseGetPos()
    ToolTip("" & $pos[0] & ", " & "" & $pos[1] & " Pause2exit")
    Sleep(10)
    If _Ispressed(10) then ; if SHIFT is pressed
$pos = MouseGetPos()    
ClipPut($pos[0] & "," & $pos[1])
Endif
WEnd

Func Start()
    Local $AllFieldEmpty = True
       For $I = 0 To UBound($CoordsField) - 1
        If GUICtrlRead($CoordsField[$I]) <> "" then $AllFieldEmpty = False 
        Next
    If $AllFieldEmpty Then 
        MsgBox(16, "Error" , "Please enter Coordinates")
        Return
    EndIf
EndFunc
; Tooltip Countdown
For $I = 0 To $NumTimeFields - 1
          
          ToolTip("Now running number " & $I &  "....Waiting " & $HourFields[$I] & " hours, " & $MinuteFields[$I] & " minutes, " & $SecondFields[$I] & " seconds.", 210, 3) ;
          sleep((_TimeToTicks($HourFields[$I], $MinuteFields[$I], $SecondFields[$I]))) ; countdown
Next
  

;Paste coords   
Func Paste()
    Send(ClipGet())
EndFunc

   

 
Func Terminate()
       Exit
EndFunc   ;==>Terminate
Edited by NutherNoob

Share this post


Link to post
Share on other sites



Hello everyone. I've got some code that I'd like to get finished but the last parts are all just fragments of ideas that I want in the macro. I've searched here and there to gather code for ideas and try and put it all together but am now so confused its..... err, like this :)

Description of my ideas is in the script.

Any help much appreciated.

#include <GUIConstants.au3>
#Include <Misc.au3>
#include <Date.au3>

AutoItSetOption("MouseCoordMode", 1)
;Use Mouse Coordinates relative to:
;1-rel to screen

    HotKeySet("{PAUSE}", "Terminate")
    HotKeySet("{ENTER}", "Paste")
    
;master gui vars
$master_gui_width = 285
$master_gui_hight = 270

; variables group
$default_group_width = 200
$x_var_group = 5
$y_var_group = 10
$var_group_width = $default_group_width
$var_group_hight = $master_gui_hight - 100
;positions vars group
$pdefault_group_width = ($master_gui_width - $default_group_width)
$px_var_group = 206
$py_var_group = 10
$pvar_group_width = $pdefault_group_width -10
$pvar_group_hight = $master_gui_hight - 100

; = END DEFINE VARIABLES

; ===== START MASTER GUI
GUICreate("=- Test -=", $master_gui_width, $master_gui_hight , -1, -1, -1)
GUISetState ()
WinSetOnTop("=- Test -=", "", 1)
; MENU
GuiCtrlCreateMenu("Menu &One")
GuiCtrlCreateMenu("Menu &Two")
GUICtrlCreateGroup ("Times", $x_var_group , $y_var_group , $var_group_width , $var_group_hight)
GUICtrlCreateGroup ("",-99,-99,1,1) ;close group

GUICtrlCreateGroup ("Positions", $px_var_group , $py_var_group , $pvar_group_width , $pvar_group_hight)
GUICtrlCreateGroup ("",-99,-99,1,1) ;close group

;Hrs, secs title
$widthCell=100
GUICtrlCreateLabel ("Hrs.  Mins.  Secs.", 50 , 30, $widthCell)

Local Const $NumTimeFields = 3 ; can be up to 10
Local $HourFields[$NumTimeFields]
Local $MinuteFields[$NumTimeFields]
Local $SecondFields[$NumTimeFields]
Local $ProgressBar[$NumTimeFields]
Local $CoordsField[$NumTimeFields]
Local $Sec, $Min, $Hour, $Time 

$widthCellb=40
$diff=22

For $I = 0 To $NumTimeFields - 1
    Local $Y = $y_var_group + $diff * ($I + 2) - 3
    Local $Label = 'Eg ' & $I + 1 & '.'
    GUICtrlCreateLabel($Label, $x_var_group + 2, $Y +3, $widthCellb)
    $HourFields[$I]       = GUICtrlCreateInput('', 50, $Y, 18, 17, $ES_NUMBER)
    $MinuteFields[$I]     = GUICtrlCreateInput('', 79, $Y, 18, 17, $ES_NUMBER)
    $SecondFields[$I]     = GUICtrlCreateInput('', 108, $Y, 18, 17, $ES_NUMBER)
    $ProgressBar[$I]      = GuiCtrlcreateProgress(130, $Y+2, 70, 13)
    $CoordsField[$I]      = GUICtrlCreateinput("", 213, $Y, 60, 17)
Next
$start=GUICtrlCreateButton("START", 228, $Y + 100, 45, 30) 
GUICtrlSetOnEvent($start,"Start")
GuiSetState(@SW_SHOW)

;When Start button clicked.....
;Checks for any x,y coords in coords fields, if none, Error msg
;Loop.....Right Clicks coords from 1st coords box and waits the specified time showing tooltip countdown
;When countdown reaches 0, clicks 2nd coords box and countsdown until all finished ......endloop
While 1
    $pos = MouseGetPos()
    ToolTip("" & $pos[0] & ", " & "" & $pos[1] & " Pause2exit")
    Sleep(10)
    If _Ispressed(10) then ; if SHIFT is pressed
$pos = MouseGetPos()    
ClipPut($pos[0] & "," & $pos[1])
Endif
WEnd

Func Start()
    Local $AllFieldEmpty = True
       For $I = 0 To UBound($CoordsField) - 1
        If GUICtrlRead($CoordsField[$I]) <> "" then $AllFieldEmpty = False 
        Next
    If $AllFieldEmpty Then 
        MsgBox(16, "Error" , "Please enter Coordinates")
        Return
    EndIf
EndFunc
; Tooltip Countdown
For $I = 0 To $NumTimeFields - 1
          
          ToolTip("Now running number " & $I &  "....Waiting " & $HourFields[$I] & " hours, " & $MinuteFields[$I] & " minutes, " & $SecondFields[$I] & " seconds.", 210, 3) ;
          sleep((_TimeToTicks($HourFields[$I], $MinuteFields[$I], $SecondFields[$I]))) ; countdown
Next
  

;Paste coords   
Func Paste()
    Send(ClipGet())
EndFunc

   

 
Func Terminate()
       Exit
EndFunc   ;==>Terminate
I know the code isnt in the right order atm, but I'm unsure where to put the loop exactly for what I want done. I've tried messing with the code (well yeah its already a mess) to allow user to put in input first before it checks for empty fields but I always get the popup window appearing after I run it......

Share this post


Link to post
Share on other sites

Can anyone help me plz?

Share this post


Link to post
Share on other sites

Is this really that hard??

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

you need to put this code at the beginning of your script

AutoItSetOption("GUIOnEventMode", 1)

Other than that, I am still looking. I'll let you know

Edited by improbability_paradox

Share this post


Link to post
Share on other sites

you are also going to want to put this inside the function

Func Start()
    Local $AllFieldEmpty = True
       For $I = 0 To UBound($CoordsField) - 1
        If GUICtrlRead($CoordsField[$I]) <> "" then $AllFieldEmpty = False
        Next
    If $AllFieldEmpty Then
        MsgBox(16, "Error" , "Please enter Coordinates")
        Return
    EndIf
; Tooltip Countdown
For $I = 0 To $NumTimeFields - 1
         If GUICtrlRead($CoordsField[$I])="" Then ContinueLoop
          ToolTip("Now running number " & $I &  "....Waiting " & GUICtrlRead($HourFields[$I]) & " hours, " & GUICtrlRead($MinuteFields[$I]) & " minutes, " & GUICtrlRead($SecondFields[$I]) & " seconds.", 210, 3) ;
          sleep((_TimeToTicks(GUICtrlRead($HourFields[$I]), GUICtrlRead($MinuteFields[$I]), GUICtrlRead($SecondFields[$I])))) ; countdown
          MouseClick("right",StringLeft(GUICtrlRead($CoordsField[$i]),StringInStr(GUICtrlRead($CoordsField[$i]),",")-1),StringTrimLeft(GUICtrlRead($CoordsField[$i]),StringInStr(GUICtrlRead($CoordsField[$i]),",")))
    
Next
EndFunc

At least, from what I understand about what you want it to do. I inserted a few lines of code that seemed most appropriate to the for-next loop. Once again, I don't understand 100% what it is you want, but I think this is along the right lines.

I Would also recommend a few other changes to your code. For example, don't just check that the coordinates field is not empty, but look at the other fields as well. Also, adding something like GUISetOnEvent($GUI_EVENT_CLOSE, "ExitScript"), where func exitscript() is a function which closes the script, is advisable.

remember that you need to use GUICtrlRead on the GUI handles... for example, $HourFileds[1] does not return the data from that control, just its handle.

I would also suggest pulling the values from the control prior to entering the for-next loop and putting them into new variable. That would make your code a little easier to understand, and eliminate the need to continually check the Gui controls for the data. (what if the user changes the data after they click start, for example?)

anyway, good luck!

Share this post


Link to post
Share on other sites

Thanx improbability_paradox, will try it out.

Share this post


Link to post
Share on other sites

K, that has helped somewhat but I cant get the hours and mins fields to work. The secs work perfectly. I cant figure out why when I put in input for hrs and mins it wont wait that amount of time though.

Also how can I get the tooltip to countdown "live"?

And yeah, its starting to look messy :)

Thanx

#include <GUIConstants.au3>
#Include <Misc.au3>
#include <Date.au3>

AutoItSetOption("GUIOnEventMode", 1)
AutoItSetOption("MouseCoordMode", 1)
;Use Mouse Coordinates relative to:
;1-rel to screen

HotKeySet("{ENTER}", "Paste")
    
;master gui vars
$master_gui_width = 285
$master_gui_hight = 270

; variables group
$default_group_width = 200
$x_var_group = 5
$y_var_group = 10
$var_group_width = $default_group_width
$var_group_hight = $master_gui_hight - 100
;positions vars group
$pdefault_group_width = ($master_gui_width - $default_group_width)
$px_var_group = 206
$py_var_group = 10
$pvar_group_width = $pdefault_group_width -10
$pvar_group_hight = $master_gui_hight - 100

; = END DEFINE VARIABLES

; ===== START MASTER GUI
GUICreate("=- Test -=", $master_gui_width, $master_gui_hight , -1, -1, -1)
GUISetState ()
WinSetOnTop("=- Test -=", "", 1)


; MENU
GuiCtrlCreateMenu("Menu &One")
GuiCtrlCreateMenu("Menu &Two")


GUICtrlCreateGroup ("Times", $x_var_group , $y_var_group , $var_group_width , $var_group_hight)
GUICtrlCreateGroup ("",-99,-99,1,1) ;close group

GUICtrlCreateGroup ("Positions", $px_var_group , $py_var_group , $pvar_group_width , $pvar_group_hight)
GUICtrlCreateGroup ("",-99,-99,1,1) ;close group

;Hrs, secs title
$widthCell=100
GUICtrlCreateLabel ("Hrs.  Mins.  Secs.", 50 , 30, $widthCell)

Local Const $NumTimeFields = 3 ; can be up to 10
Local $HourFields[$NumTimeFields]
Local $MinuteFields[$NumTimeFields]
Local $SecondFields[$NumTimeFields]
Local $ProgressBar[$NumTimeFields]
Local $CoordsField[$NumTimeFields]
Local $Sec, $Min, $Hour, $Time, $XSpot, $YSpot

$widthCellb=40
$diff=22

For $I = 0 To $NumTimeFields - 1
    Local $Y = $y_var_group + $diff * ($I + 2) - 3
    Local $Label = 'Eg ' & $I + 1 & '.'
    GUICtrlCreateLabel($Label, $x_var_group + 2, $Y +3, $widthCellb)
    $HourFields[$I]       = GUICtrlCreateInput('', 50, $Y, 18, 17, $ES_NUMBER)
    $MinuteFields[$I]     = GUICtrlCreateInput('', 79, $Y, 18, 17, $ES_NUMBER)
    $SecondFields[$I]     = GUICtrlCreateInput('', 108, $Y, 18, 17, $ES_NUMBER)
    $ProgressBar[$I]      = GuiCtrlcreateProgress(130, $Y+2, 70, 13)
    $CoordsField[$I]      = GUICtrlCreateinput("", 213, $Y, 60, 17)
Next
$start=GUICtrlCreateButton("START", 228, $Y + 100, 45, 30) 
GUICtrlSetOnEvent($start,"Start")
GuiSetState()

;When Start button clicked.....
;Checks for any x,y coords in coords fields, if none, Error msg
;Loop.....Right Clicks coords from 1st coords box and waits the specified time showing tooltip countdown
;When countdown reaches 0, clicks 2nd coords box and countsdown until all finished ......endloop
$XSpot= Random(25,140)
$YSpot= Random(6,12)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = GUISetOnEvent($GUI_EVENT_CLOSE, "Terminate")
            ExitLoop
        Case $msg = $start
            Start()
    EndSelect       
    $pos = MouseGetPos()
    ToolTip("" & $pos[0] & ", " & "" & $pos[1])
    Sleep(10)
    If _Ispressed(10) then ; if SHIFT is pressed
        $pos = MouseGetPos()    
        ClipPut($pos[0] & "," & $pos[1])
    Endif 
WEnd

Func Start()
    Local $AllFieldEmpty = True
       For $I = 0 To UBound($CoordsField) - 1
        If GUICtrlRead($CoordsField[$I]) <> "" then $AllFieldEmpty = False
        Next
    If $AllFieldEmpty Then
        MsgBox(16, "Error" , "Please enter Coordinates")
        Return
    EndIf
; Tooltip Countdown
For $I = 0 To $NumTimeFields - 1
         If GUICtrlRead($CoordsField[$I])="" Then ContinueLoop
         MouseClick("right",StringLeft(GUICtrlRead($CoordsField[$i]),StringInStr(GUICtrlRead($CoordsField[$i]),",")-1),StringTrimLeft(GUICtrlRead($CoordsField[$i]),StringInStr(GUICtrlRead($CoordsField[$i]),",")))
         Sleep(5000)
         MouseClick("left", (StringLeft(GUICtrlRead($CoordsField[$i]),StringInStr(GUICtrlRead($CoordsField[$i]),",")-1) + $XSpot), (StringTrimLeft(GUICtrlRead($CoordsField[$i]),StringInStr(GUICtrlRead($CoordsField[$i]),",")) + $YSpot))
        ToolTip("Now running number " & ($I+1) &  "....Waiting " & GUICtrlRead($HourFields[$I]) & " hours, " & GUICtrlRead($MinuteFields[$I]) & " minutes, " & GUICtrlRead($SecondFields[$I]) & " seconds.", 210, 3) ;
         sleep(_TimeToTicks(GUICtrlRead($HourFields[$I]*3600), GUICtrlRead($MinuteFields[$I]*60), GUICtrlRead($SecondFields[$I]))) ; countdown
     Next
     EndFunc
;Paste coords   
Func Paste()
    Send(ClipGet())
EndFunc

   

 
Func Terminate()
       Exit
EndFunc   ;==>Terminate

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