Sign in to follow this  
Followers 0
TheLandYacht

Q: (Hopefully simple) modification to ClipPut function

6 posts in this topic

So, this script is a floating window that I use to paste specific messages into my SMS Texting program for auto-replying to SMS Messages on my connected Windows Mobile phone. The script works perfectly as is, but I would like to improve it in this fashion. Some of the responses, for instance, go "I WILL ARRIVE IN", which gets pasted into the appropriate window. I would like to change the gui so instead it looks like "I WILL ARRIVE IN" (gui asks for a number) "MINUTES". Here's the code as I currently have it working. First a copy of the relevant line, then the whole script. Thanks in advance for the help and advice!

$aData[14][1] ="PLEASE STEP OUTSIDE.  ARRIVING IN "

#include <GUIConstantsEx.au3>
#include <GUIComboBox.au3>
#include <Misc.au3>

Dim $aData[19][2]

$aData[0][0] ="000 BLANK"
$aData[0][1] ="_"
$aData[1][0] ="READY & NEARBY"
$aData[1][1] ="READY & NEARBY.  TEXT ME TO PULL UP"
$aData[2][0] ="ETA OFFER TIME"
$aData[2][1] ="I CAN BE THERE IN "
$aData[3][0] ="ETA OFFER SPECIFIC "
$aData[3][1] ="I CAN BE THERE AT"
$aData[4][0] ="ON MY WAY"
$aData[4][1] ="ENROUTE.  ETA IS "
$aData[5][0] ="TOO LOUD, STEP OUT"
$aData[5][1] ="I CAN’T HEAR YOU, STEP OUT OF THE BAR OR RESTAURANT & CALL ME BACK"
$aData[6][0] ="YES"
$aData[6][1] ="ANSWER IS YES"
$aData[7][0] ="NO"
$aData[7][1] ="SORRY, ANSWER IS NO"
$aData[8][0] ="WHERE ARE YOU?"
$aData[8][1] ="WHERE ARE YOU?"
$aData[9][0] ="WHEN READY?"
$aData[9][1] ="WHEN WILL YOU BE READY?"
$aData[10][0] ="DESTINATION?"
$aData[10][1] ="WHERE ARE YOU GOING?"
$aData[11][0] ="CALL ME"
$aData[11][1] ="PLEASE CALL ME"
$aData[12][0] ="LEAVE A MESSAGE"
$aData[12][1] ="I CAN’T TALK, PLEASE LEAVE A MESSAGE"
$aData[13][0] ="MEET ME AT "
$aData[13][1] ="PLEASE MEET ME AT"
$aData[14][0] ="ARRIVING"
$aData[14][1] ="PLEASE STEP OUTSIDE.  ARRIVING IN "
$aData[15][0] ="PASSWORD"
$aData[15][1] ="IF THERE'S A CROWD, I'LL ASK FOR A PASSWORD.  YOUR PASSWORD IS "
$aData[16][0] ="Pre-Trip Confirmation"
$aData[16][1] ="PRE-TRIP CONFIRMATION.  PLEASE RESPOND WITHIN TWO MINUTES TO CONFIRM"
$aData[17][0] ="Pre-Pre-Trip Confirmation"
$aData[17][1] ="I WILL CALL OR TEXT BEFORE COMING.  RESPONSE IS REQUIRED SO I KNOW YOU'RE READY.  NO RESPONSE=NO SHOW."
$aData[18][0] ="No Timecalls"
$aData[18][1] ="PLEASE NOTE, I SHOOT FOR A 20 MINUTE WINDOW, I MAY BE UP TO 10 MINUTES EARLY OR LATE.  PLEASE PLAN ACCORDINGLY. DO YOU PREFER EARLY OR LATE?"



$hGUI = GUICreate("CANNED MESSAGES",300,100,724,1)  ; will create a dialog box that when displayed is centered

$hCombo = GUICtrlCreateCombo("", 10, 10,"","",$CBS_DROPDOWNLIST)
;$hCombo = _GUICtrlComboBox_Create($hGUI, "", 2, 2, 296, 20,$CBS_DROPDOWNLIST )

;Populate
For $X = 0 to Ubound($aData)-1
    GUICtrlSetData($hCombo,$aData[$X][0])
    ;_GUICtrlComboBox_AddString($hCombo,$aData[$X][0])
Next

$hButton = GUICtrlCreateButton("SMS Message",100,40,100)

GUISetState()

; Run the GUI until the dialog is closed
While 1

    SendKeepActive("New SMS")


    If _IsPressed("0D")  And WinActive($hGui) Then
        Opt("WinTitleMatchMode", 2)
        WinActivate ( "New SMS" )
        ClipPut ($aData[_GUICtrlComboBox_GetCurSel($hCombo)][1])
        Opt("WinTitleMatchMode", 2)
        WinActivate ( "New SMS" )
        Send("^v")
    EndIf

Opt("WinTitleMatchMode", 2)
    If _IsPressed( "C0" )  And WinActive( "New SMS" ) Then
        Opt("WinTitleMatchMode", 2)
        WinActivate ( "New SMS" )
        Send( "{BS}" )
        Sleep(1000)
        Opt("MouseCoordMode", 0)
        Send("!s")
    EndIf

    If _IsPressed( "BA" )  And WinActive( "New SMS" ) Then
        Opt("WinTitleMatchMode", 2)
        WinActivate ( "New SMS" )
        Send( "{BS}" )
        Send( "{SPACE}" )
        Send( "MINUTES" )
        Sleep(1000)
        Opt("MouseCoordMode", 0)
        Send("!s")
    EndIf

    Switch GUIGetMsg()

        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $hButton
            MsgBox(0,"",$aData[_GUICtrlComboBox_GetCurSel($hCombo)][1])

    EndSwitch
WEnd

Share this post


Link to post
Share on other sites



#include <GUIConstantsEx.au3>
#include <GUIComboBox.au3>
#include <Misc.au3>

Dim $aData[19][3]

$aData[0][0] ="000 BLANK"
$aData[0][1] ="_"
$aData[0][2] =""
$aData[1][0] ="READY & NEARBY"
$aData[1][1] ="READY & NEARBY.  TEXT ME TO PULL UP"
$aData[1][2] =""
$aData[2][0] ="ETA OFFER TIME"
$aData[2][1] ="I CAN BE THERE IN %s Minutes"
$aData[2][2] ="InputBox('Minutes', 'I CAN BE THERE IN how many Minutes?')"  ;this is the clue (part 1)
$aData[3][0] ="ETA OFFER SPECIFIC "
$aData[3][1] ="I CAN BE THERE AT"
$aData[3][2] =""
$aData[4][0] ="ON MY WAY"
$aData[4][1] ="ENROUTE.  ETA IS "
$aData[4][2] =""
$aData[5][0] ="TOO LOUD, STEP OUT"
$aData[5][1] ="I CAN’T HEAR YOU, STEP OUT OF THE BAR OR RESTAURANT & CALL ME BACK"
$aData[5][2] =""
$aData[6][0] ="YES"
$aData[6][1] ="ANSWER IS YES"
$aData[6][2] =""
$aData[7][0] ="NO"
$aData[7][1] ="SORRY, ANSWER IS NO"
$aData[7][2] =""
$aData[8][0] ="WHERE ARE YOU?"
$aData[8][1] ="WHERE ARE YOU?"
$aData[8][2] =""
$aData[9][0] ="WHEN READY?"
$aData[9][1] ="WHEN WILL YOU BE READY?"
$aData[9][2] =""
$aData[10][0] ="DESTINATION?"
$aData[10][1] ="WHERE ARE YOU GOING?"
$aData[10][2] =""
$aData[11][0] ="CALL ME"
$aData[11][1] ="PLEASE CALL ME"
$aData[11][2] =""
$aData[12][0] ="LEAVE A MESSAGE"
$aData[12][1] ="I CAN’T TALK, PLEASE LEAVE A MESSAGE"
$aData[12][2] =""
$aData[13][0] ="MEET ME AT "
$aData[13][1] ="PLEASE MEET ME AT"
$aData[13][2] =""
$aData[14][0] ="ARRIVING"
$aData[14][1] ="PLEASE STEP OUTSIDE.  ARRIVING IN "
$aData[14][2] =""
$aData[15][0] ="PASSWORD"
$aData[15][1] ="IF THERE'S A CROWD, I'LL ASK FOR A PASSWORD.  YOUR PASSWORD IS "
$aData[15][2] =""
$aData[16][0] ="Pre-Trip Confirmation"
$aData[16][1] ="PRE-TRIP CONFIRMATION.  PLEASE RESPOND WITHIN TWO MINUTES TO CONFIRM"
$aData[16][2] =""
$aData[17][0] ="Pre-Pre-Trip Confirmation"
$aData[17][1] ="I WILL CALL OR TEXT BEFORE COMING.  RESPONSE IS REQUIRED SO I KNOW YOU'RE READY.  NO RESPONSE=NO SHOW."
$aData[17][2] =""
$aData[18][0] ="No Timecalls"
$aData[18][1] ="PLEASE NOTE, I SHOOT FOR A 20 MINUTE WINDOW, I MAY BE UP TO 10 MINUTES EARLY OR LATE.  PLEASE PLAN ACCORDINGLY. DO YOU PREFER EARLY OR LATE?"
$aData[18][2] =""

 

$hGUI = GUICreate("CANNED MESSAGES",300,100,724,1)  ; will create a dialog box that when displayed is centered

$hCombo = GUICtrlCreateCombo("", 10, 10,"","",$CBS_DROPDOWNLIST)
;$hCombo = _GUICtrlComboBox_Create($hGUI, "", 2, 2, 296, 20,$CBS_DROPDOWNLIST )

;Populate
For $X = 0 to Ubound($aData)-1
    GUICtrlSetData($hCombo,$aData[$X][0])
    ;_GUICtrlComboBox_AddString($hCombo,$aData[$X][0])
Next

$hButton = GUICtrlCreateButton("SMS Message",100,40,100)

Local $Selected

GUISetState()

; Run the GUI until the dialog is closed
While 1

    SendKeepActive("New SMS")


    If _IsPressed("0D")  And WinActive($hGui) Then ;Enter
        Opt("WinTitleMatchMode", 2)
        WinActivate ( "New SMS" )
  $Selected = _GUICtrlComboBox_GetCurSel($hCombo)
        ClipPut (StringFormat($aData[$Selected][1], Execute($aData[$Selected][2])))  ;this is the clue (part 2)
        Opt("WinTitleMatchMode", 2)
  ConsoleWrite(ClipGet() & @CR)
;~      WinActivate ( "New SMS" )
;~      Send("^v")
    EndIf

Opt("WinTitleMatchMode", 2)
    If _IsPressed( "C0" )  And WinActive( "New SMS" ) Then ;`
        Opt("WinTitleMatchMode", 2)
        WinActivate ( "New SMS" )
        Send( "{BS}" )
        Sleep(1000)
        Opt("MouseCoordMode", 0)
        Send("!s")
    EndIf

    If _IsPressed( "BA" )  And WinActive( "New SMS" ) Then ;;
        Opt("WinTitleMatchMode", 2)
        WinActivate ( "New SMS" )
        Send( "{BS}" )
        Send( "{SPACE}" )
        Send( "MINUTES" )
        Sleep(1000)
        Opt("MouseCoordMode", 0)
        Send("!s")
    EndIf

    Switch GUIGetMsg()

        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $hButton
            MsgBox(0,"",$aData[_GUICtrlComboBox_GetCurSel($hCombo)][1])

    EndSwitch
WEnd


Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Share this post


Link to post
Share on other sites

OK. I built a script & just pasted in your script into it.

Used the first ETA thing in the dropdown, which looks like the one you modified. I select that & hit enter (or click the button) and it pops up a new window that says "How many minutes". But when I enter (or click OK) in the new window, instead of pasting the results into the window whose title is "New SMS", I get nothing...the new (minutes) window just goes away. Also, none of the rest of the items in the original menu paste into "New SMS" anymore either. So something in the new content broke the ClipPut function on line 72 of the original script, line 94 of yours.

Share this post


Link to post
Share on other sites

As a test, I took my original script, replaced all instances of "New SMS" with "Untitled - Notepad". Doing this gives me a script that will paste to an open document in Notepad named Untitled. Tested & working. Did the same with yours and nothing...correction, it doesn't do "nothing", it does bring the notepad window to the front, but doesn't paste the contents of the dropdown menu into it as mine does. Again, the ETA Offer item in the dropdown produces a new window asking for "number of minutes", but when you provide that it does nothing but bring the Notepad window to the front.

I made this alteration so it's simple to test the results on both ends of this conversation.

Thanks for helpin.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Did you activate line 97 and 98? Line 96 writes the result to the console for testing. For me it works.

Edit: Sample code for notepad

#include <GUIConstantsEx.au3>
#include <GUIComboBox.au3>
#include <Misc.au3>

Opt("WinTitleMatchMode", 2)
Opt("MouseCoordMode", 0)

Global $WindowTitle = "Untitled"

Global $aData[19][3]

Run('notepad.exe')
WinWait($WindowTitle)

$aData[0][0] ="000 BLANK"
$aData[0][1] ="_"
$aData[0][2] =""
$aData[1][0] ="READY & NEARBY"
$aData[1][1] ="READY & NEARBY.  TEXT ME TO PULL UP"
$aData[1][2] =""
$aData[2][0] ="ETA OFFER TIME"
$aData[2][1] ="I CAN BE THERE IN %s MINUTES"
$aData[2][2] ="InputBox('Minutes', 'I CAN BE THERE IN how many MINUTES?', '', ' M')"  ;this is the clue (part 1)
$aData[3][0] ="ETA OFFER SPECIFIC "
$aData[3][1] ="I CAN BE THERE AT"
$aData[3][2] =""
$aData[4][0] ="ON MY WAY"
$aData[4][1] ="ENROUTE.  ETA IS "
$aData[4][2] =""
$aData[5][0] ="TOO LOUD, STEP OUT"
$aData[5][1] ="I CAN’T HEAR YOU, STEP OUT OF THE BAR OR RESTAURANT & CALL ME BACK"
$aData[5][2] =""
$aData[6][0] ="YES"
$aData[6][1] ="ANSWER IS YES"
$aData[6][2] =""
$aData[7][0] ="NO"
$aData[7][1] ="SORRY, ANSWER IS NO"
$aData[7][2] =""
$aData[8][0] ="WHERE ARE YOU?"
$aData[8][1] ="WHERE ARE YOU?"
$aData[8][2] =""
$aData[9][0] ="WHEN READY?"
$aData[9][1] ="WHEN WILL YOU BE READY?"
$aData[9][2] =""
$aData[10][0] ="DESTINATION?"
$aData[10][1] ="WHERE ARE YOU GOING?"
$aData[10][2] =""
$aData[11][0] ="CALL ME"
$aData[11][1] ="PLEASE CALL ME"
$aData[11][2] =""
$aData[12][0] ="LEAVE A MESSAGE"
$aData[12][1] ="I CAN’T TALK, PLEASE LEAVE A MESSAGE"
$aData[12][2] =""
$aData[13][0] ="MEET ME AT "
$aData[13][1] ="PLEASE MEET ME AT"
$aData[13][2] =""
$aData[14][0] ="ARRIVING"
$aData[14][1] ="PLEASE STEP OUTSIDE.  ARRIVING IN "
$aData[14][2] =""
$aData[15][0] ="PASSWORD"
$aData[15][1] ="IF THERE'S A CROWD, I'LL ASK FOR A PASSWORD.  YOUR PASSWORD IS "
$aData[15][2] =""
$aData[16][0] ="Pre-Trip Confirmation"
$aData[16][1] ="PRE-TRIP CONFIRMATION.  PLEASE RESPOND WITHIN TWO MINUTES TO CONFIRM"
$aData[16][2] =""
$aData[17][0] ="Pre-Pre-Trip Confirmation"
$aData[17][1] ="I WILL CALL OR TEXT BEFORE COMING.  RESPONSE IS REQUIRED SO I KNOW YOU'RE READY.  NO RESPONSE=NO SHOW."
$aData[17][2] =""
$aData[18][0] ="No Timecalls"
$aData[18][1] ="PLEASE NOTE, I SHOOT FOR A 20 MINUTE WINDOW, I MAY BE UP TO 10 MINUTES EARLY OR LATE.  PLEASE PLAN ACCORDINGLY. DO YOU PREFER EARLY OR LATE?"
$aData[18][2] =""

 

$hGUI = GUICreate("CANNED MESSAGES",300,100,724,1)  ; will create a dialog box that when displayed is centered

$hCombo = GUICtrlCreateCombo("", 10, 10,"","",$CBS_DROPDOWNLIST)

;Populate
For $X = 0 to Ubound($aData)-1
    GUICtrlSetData($hCombo,$aData[$X][0])
Next

$hButton = GUICtrlCreateButton("SMS Message",100,40,100)

Local $Selected

GUISetState()

SendKeepActive($WindowTitle)

; Run the GUI until the dialog is closed
While WinExists( $WindowTitle )

    If _IsPressed("0D")  And WinActive($hGui) Then ;Enter
;~      WinActivate ( $WindowTitle )
  $Selected = _GUICtrlComboBox_GetCurSel($hCombo)
        ClipPut (StringFormat($aData[$Selected][1], Execute($aData[$Selected][2])) & @CRLF)  ;this is the clue (part 2)  delete '& @CRLF' for your app.
        WinActivate ( $WindowTitle )
        Send("^v")
  Sleep(1000)
    EndIf

    If _IsPressed( "C0" )  And WinActive( $WindowTitle ) Then ;`
;~      WinActivate ( $WindowTitle )
        Send( "{BS}" )
        Sleep(1000)
        Send("!s")
    EndIf

    If _IsPressed( "BA" )  And WinActive( $WindowTitle ) Then ;;
;~      WinActivate ( $WindowTitle )
        Send( "{BS}" )
        Send( "{SPACE}" )
        Send( "MINUTES" )
        Sleep(1000)
        Send("!s")
    EndIf

    Switch GUIGetMsg()

        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $hButton
            MsgBox(0,"",$aData[_GUICtrlComboBox_GetCurSel($hCombo)][1])

    EndSwitch
WEnd
Edited by funkey

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Share this post


Link to post
Share on other sites

That one worked, and worked as needed in the New SMS window once I changed...

Global $WindowTitle = "Untitled"

to

Global $WindowTitle = "New SMS"

After a little fiddling with location & pixelsize amounts, I even got the InputBox to go where I want it (right over the top of the original Gui instead of in the center of the screen). I changed...

$aData[4][2] ="InputBox('Minutes', 'I CAN BE THERE IN how many MINUTES?', '', ' M')"

to

$aData[4][2] ="InputBox('Minutes', 'I CAN BE THERE IN how many MINUTES?', '', '', 0, 0, 768, 0, ' M')"

Had to do that because the New SMS window is an "always on top" application that centers itself, and there's no setting in that program to change either of those things...so when the InputBox popped in the middle of the screen...of course it was hidden because the New SMS window was on top of it.

Hopefully someone else can get some use outta this too & I'm not rambling on for the heck of it.

Thanks again for all the help!

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