Sign in to follow this  
Followers 0
litlmike

Is this an Improper Calling?

14 posts in this topic

#1 ·  Posted (edited)

I finished a script, then tried to simplify it...Now it only does about half of the things it used to. I have the original saved, don't worry...haha. It doesn't do any Calls after Call ("EmailCat_Date"), and Call ("GUI_Assistant_Me").

My thinking was that I could make a Function that I can set to a hot key, "Func BasicEmail()" and then it would call the other Functions in order. I must be wrong. I think I have narrowed it down to knowing the problem lies in the functions : EmailCat_Date(), and GUI_Assistant_Me().

I will paste the Full Code in the following post.

************EDIT**************

I understand the problem now, see the post at "Posted Today, 03:50 PM". But I don't know how to fix it.

******************************

Edited by litlmike

Share this post


Link to post
Share on other sites



AHHH, why would you us Call? why not just

GUI_Assist_me() rather than

Call("Gui_Assist_Me")


AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

;*****************UPDATED CODE**************** 3:54 P.M.

#cs

;;;Left to Do:

Make sure it can change category in email

#ce

; Press Esc to terminate script, Pause/Break to "pause"

#include <IE.au3>

#include <Date.au3>

#include <GUIConstants.au3>t

Global $Paused, $email, $contact, $company

HotKeySet("{PAUSE}", "TogglePause")

HotKeySet("{ESC}", "Terminate")

HotKeySet("+!d", "ShowMessage") ;Shift-Alt-d

HotKeySet("^1","BasicEmail")

HotKeySet("^2","AssistantEmail")

;HotKeySet("^2","JustInf")

Opt("WinWaitDelay",100)

Opt("WinTitleMatchMode",4)

Opt("WinDetectHiddenText",1)

Opt("MouseCoordMode",0)

;;;; Body of program would go here ;;;;

While 1

Sleep(100)

WEnd

;;;;;;;;

; Pause and Escape Functions

Func TogglePause()

$Paused = NOT $Paused

While $Paused

sleep(100)

ToolTip('Script is "Paused"',0,0)

WEnd

ToolTip("")

EndFunc

Func Terminate()

Exit 0

EndFunc

Func ShowMessage()

MsgBox(4096,"","This is a message.")

EndFunc

;****************************************HOT KEY 1*****************************************

Func BasicEmail() ;Func to add in basic info for emails

EmailCat_Date ()

GUI_Assistant_Me ()

ACT ()

ACT_Copy ()

Eudora ()

Eudora_Change ()

EndFunc

;*****************************************For Hotkey 2*************************************

Func AssistantEmail()

;;; Copy & Paste Email from ACT 'email address' field to 'email' field

Call("ACT")

Call("ACT_Copy")

Call("Eudora")

EndFunc

Func ACT()

;Activate ACT

WinWait("ACT!","")

If Not WinActive("ACT!","") Then WinActivate("ACT!","")

WinWaitActive("ACT!","")

EndFunc

Func ACT_Copy()

;Copy Company

MouseMove(351,236)

MouseDown("left")

MouseUp("left")

Sleep(500)

Send("{END}{SHIFTDOWN}{HOME}{SHIFTUP}{CTRLDOWN}c{CTRLUP}")

$company = ClipGet ()

Sleep(200)

;Copy Name

Send("{TAB}")

Send("{END}{SHIFTDOWN}{HOME}{SHIFTUP}{CTRLDOWN}c{CTRLUP}")

$contact = ClipGet ()

Sleep(200)

;Copy Email

Send("{TAB}{TAB}{TAB}")

Send("{END}{SHIFTDOWN}{HOME}{SHIFTUP}{CTRLDOWN}c{CTRLUP}")

$email = ClipGet ()

EndFunc

;;; Paste Contact Info from ACT into Stationary Email

Func Eudora() ;Goto Eudora

WinWait("Eudora","")

If Not WinActive("Eudora","") Then WinActivate("Eudora","")

WinWaitActive("Eudora","")

EndFunc

Func Eudora_Change()

;Focus on ComboBox with <none>, Assistant, Gordon's Guide-Signature I think

ControlCommand ("Eudora","","ComboBox3", "SetCurrentSelection", 0)

;ControlFocus ( "Eudora", "", "ComboBox3")

;Send("{UP}{UP}{UP}") ;, set it to none

ControlSetText("Eudora", "", "Edit1", $email)

ControlSetText("Eudora", "", "Edit3", "ATTN: " & $contact)

ControlFocus("Eudora", "", "EudoraEdit1")

$email_body = ControlGetText ( "Eudora", "","EudoraEdit1" )

$AddNotes_New = StringReplace ( $email_body, "NNNNN", $contact)

$AddNotes_NewA = StringReplace ( $AddNotes_New, "XXXXX", $company)

;$AddNotes_NewB = StringReplace ( $AddNotes_NewA, "ZZZZZ", $cat_1A) ;Put Category in Add Notes

ControlSetText ( "Eudora", "", "EudoraEdit1", $AddNotes_NewA )

EndFunc

Func GUI_Assistant_Me()

;Make GUI to choose if Email is from Me or Assistant

GUICreate("Email From?", 150, 55)

GUISetState(@SW_SHOW) ; will display an empty dialog box

$email_assistant = GUICtrlCreateButton("Assistant", 15, 10,50,35)

$email_me = GUICtrlCreateButton("Me", 75, 10,50,35)

Do

$msg = GUIGetMsg()

If $msg = $email_assistant Then PickAssistant()

If $msg = $email_me Then PickMe()

Until $msg = $GUI_EVENT_CLOSE

EndFunc

Func PickAssistant()

GUISetState(@SW_HIDE)

ControlFocus ( "Eudora", "", "ComboBox3"); do not remove, u need this

ControlCommand ("Eudora","","ComboBox3", "SetCurrentSelection", 1)

;Send("{DOWN}") ; do not remove, u need this

ControlClick ( "Eudora", "", "Static2")

Send("{DOWN}")

Send("{DOWN}")

Send("{ENTER}")

ControlFocus("Eudora", "", "EudoraEdit1"); So that you don't accidentally scroll

EndFunc

Func PickMe()

GUISetState(@SW_HIDE)

ControlFocus ( "Eudora", "", "ComboBox3") ; do not remove, u need this

ControlCommand ("Eudora","","ComboBox3", "SetCurrentSelection", 2)

Send("{DOWN}{DOWN}") ; do not remove, u need this

ControlClick ( "Eudora", "", "Static2")

Send("{DOWN}")

Send("{ENTER}")

ControlFocus("Eudora", "", "EudoraEdit1"); So that you don't accidentally scroll

EndFunc

Func ClickEmail() ;Open 'Just Wants Info Stationary'

MouseMove(55,684)

MouseDown("left")

MouseUp("left")

MouseClick("left",39,285,2)

sleep(500)

EndFunc

Call("Eudora_Change")

Func Assitant_Or_Me()

;Make GUI to choose if Email is from Me or Assistant

GUICreate("Email Sender Options", 150, 55)

GUISetState(@SW_SHOW) ; will display an empty dialog box

$email_assistant = GUICtrlCreateButton("Assistant", 15, 10,50,35)

$email_me = GUICtrlCreateButton("Me", 75, 10,50,35)

Do

$msg = GUIGetMsg()

If $msg = $email_assistant Then PickAssistant()

If $msg = $email_me Then PickMe()

Until $msg = $GUI_EVENT_CLOSE

EndFunc

Func EmailCat_Date()

;Make GUI

GUICreate("Input Email Info", 225, 350)

GUISetState(@SW_SHOW) ; will display an empty dialog box

;Make first Combo Box

$cat_1 = GUICtrlCreateCombo("Deleted To Save Room", 10, 35)

GUICtrlSetData(-1, "Deleted To Save Room"); Set data in Combo Box

;Second Combo Box

$cat_2 = GUICtrlCreateCombo("Deleted To Save Room", 10, 75)

GUICtrlSetData(-1, "Deleted To Save Room"); Set data in Combo Box

;Third Combo Box

$cat_3 = GUICtrlCreateCombo("Deleted To Save Room", 10, 115)

GUICtrlSetData(-1, "Deleted To Save Room"); Set data in Combo Box

;Label for Category

GUICtrlCreateLabel ("Does Email Need A Category?", 10, 10,200,20)

;Make Buttons

$done = GUICtrlCreateButton("Create Email", 35, 275, 150, 50)

;Creates a date control for the GUI

; Also, sets the incentive date/expiration date for the last day of the current week, and last day of current month.

$date1 = _DateToDayOfWeek (@YEAR, @MON, @MDAY)

$date2 = 6 - $date1

$date3 = _DateAdd ( "d", $date2, _NowCalcDate())

;Label for the Dates

GUICtrlCreateLabel ("Appointment Date", 10, 210,70,12)

$date_a = GUICtrlCreateDate ($date3, 10,225,200,20 )

GUISetState() ; will display an empty dialog box

; Run the GUI until the dialog is closed

Do

$msg = GUIGetMsg()

If $msg = $done Then

GUISetState(@SW_HIDE)

GUI_Assistant_Me()

EndIf

If $msg = $cat_1 Then

GUICtrlRead($cat_1); get the value

$cat_2 = $cat_1

$cat_3 = $cat_1

EndIf

If $msg = $cat_2 Then

GUICtrlRead($cat_2); get the value

$cat_1 = $cat_2

$cat_3 = $cat_2

EndIf

If $msg = $cat_3 Then

GUICtrlRead($cat_3); get the value

$cat_1 = $cat_3

$cat_2 = $cat_3

EndIf

If $msg = $date_a Then

GUICtrlRead($date_a)

EndIf

Until $msg = $GUI_EVENT_CLOSE

EndFunc

Edited by litlmike

Share this post


Link to post
Share on other sites

AHHH, why would you us Call? why not just

GUI_Assist_me() rather than

Call("Gui_Assist_Me")

Because I am an idiot! That's why! Can't you get that straight!

:)

So I will try changing that and see if it works. What is the difference in using Call?

Share this post


Link to post
Share on other sites

I still doesn't work, it looks like it is kinda skipping something. I think the problem is with my If statements in the GUI, should they be different?

EmailCat_Date ; save the data until Eudora Change

GUI_Assistant_M ;; save the data until Eudora Change

ACT ; save the data until Eudora Change

ACT_Copy ; save the data until Eudora Change

Eudora

Eudora_Change

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

add () to the end of your function calls

like

rather than

'Eudora'

use

'Eudaora()'

I dont think there really is a diff between call & just calling a func :)

Edited by cdkid

AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!

Share this post


Link to post
Share on other sites

I see where the problem lies, but don't know how to fix it. So I get the logic of it, but not the solution. After, PickAssistant(), and PickMe(), I need the script to go back to Func BasicEmail() to complete the other 4 functions, ACT (), ACT_Copy (), Eudora (), Eudora_Change ().

Why doesn't that happen?

Func GUI_Assistant_Me()
;Make GUI to choose if Email is from Me or Assistant
GUICreate("Email From?", 150, 55)
GUISetState(@SW_SHOW)   ; will display an empty dialog box

$email_assistant = GUICtrlCreateButton("Assistant", 15, 10,50,35)
$email_me = GUICtrlCreateButton("Me", 75, 10,50,35)

Do
    $msg = GUIGetMsg()

    If $msg = $email_assistant Then PickAssistant()
        
    If $msg = $email_me Then PickMe()

Until $msg = $GUI_EVENT_CLOSE
EndFunc


Func PickAssistant()
GUISetState(@SW_HIDE)
ControlFocus ( "Eudora", "", "ComboBox3"); do not remove, u need this

ControlCommand ("Eudora","","ComboBox3", "SetCurrentSelection", 1)
;Send("{DOWN}"); do not remove, u need this
ControlClick ( "Eudora", "", "Static2")
Send("{DOWN}")
Send("{DOWN}")
Send("{ENTER}")
ControlFocus("Eudora", "", "EudoraEdit1"); So that you don't accidentally scroll
EndFunc

Share this post


Link to post
Share on other sites

maybe

Func PickAssistant()
GUISetState(@SW_HIDE)
ControlFocus ( "Eudora", "", "ComboBox3"); do not remove, u need this

ControlCommand ("Eudora","","ComboBox3", "SetCurrentSelection", 1)
;Send("{DOWN}"); do not remove, u need this
ControlClick ( "Eudora", "", "Static2")
Send("{DOWN}")
Send("{DOWN}")
Send("{ENTER}")
ControlFocus("Eudora", "", "EudoraEdit1"); So that you don't accidentally scroll
GUISetState(@SW_SHOW);<--------------
EndFunc

NEWHeader1.png

Share this post


Link to post
Share on other sites

maybe

Func PickAssistant()
GUISetState(@SW_HIDE)
ControlFocus ( "Eudora", "", "ComboBox3"); do not remove, u need this

ControlCommand ("Eudora","","ComboBox3", "SetCurrentSelection", 1)
;Send("{DOWN}"); do not remove, u need this
ControlClick ( "Eudora", "", "Static2")
Send("{DOWN}")
Send("{DOWN}")
Send("{ENTER}")
ControlFocus("Eudora", "", "EudoraEdit1"); So that you don't accidentally scroll
GUISetState(@SW_SHOW);<--------------
EndFunc

Thanks for the response, but I actually want the GUI to disappear.

The Script asks the user for 3 bits of information: Once the user has sent a msg for EmailCat_Date (), then GUI_Assistant_Me (), should occur, then according to the answer for GUI_Assistant_Me (), either PickAssistant() or PickMe() happens. BUT, after either PickAssistant() or PickMe() happens I want the script to finish the Func BasicEmail(). Which would leave: ACT (), ACT_Copy (), Eudora (), Eudora_Change ().

My thinking was that it would complete these functions in order (below). One of the posts above I try to explain the logic that I see is wrong. But don't know how to fix.

Func BasicEmail();Func to add in basic info for emails
EmailCat_Date ()
GUI_Assistant_Me ()
ACT ()
ACT_Copy ()
Eudora ()
Eudora_Change ()
EndFunc

Share this post


Link to post
Share on other sites

Do
    $msg = GUIGetMsg()

    If $msg = $email_assistant Then 
        PickAssistant()
        Return
    EndIf
    If $msg = $email_me Then 
        PickMe()
        Return
    EndIf
Until $msg = $GUI_EVENT_CLOSE
EndFunc

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Do
    $msg = GUIGetMsg()

    If $msg = $email_assistant Then 
        PickAssistant()
        Return
    EndIf
    If $msg = $email_me Then 
        PickMe()
        Return
    EndIf
Until $msg = $GUI_EVENT_CLOSE
EndFunc

8)

It didn't fix it. :)

I really don't know what 'Return' does, but it sounds like the idea. I want the script to 'Return' to finishing the Func BasicEmail() in the order I set it. Where does this 'Return' Make it return to?

Any other ideas?

Edited by litlmike

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

geeze....

Do
    $msg = GUIGetMsg()

    If $msg = $email_assistant Then
        PickAssistant()
        ExitLoop
    EndIf
    If $msg = $email_me Then
        PickMe()
        ExitLoop
    EndIf
Until $msg = $GUI_EVENT_CLOSE
EndFunc

return - returns to the last place the function was called from

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

geeze....

Do
    $msg = GUIGetMsg()

    If $msg = $email_assistant Then
        PickAssistant()
        ExitLoop
    EndIf
    If $msg = $email_me Then
        PickMe()
        ExitLoop
    EndIf
Until $msg = $GUI_EVENT_CLOSE
EndFunc

return - returns to the last place the function was called from

8)

Dang it! Its not working! Oh how I love and hate programming!....... :) .........wait a minute!

Oh wait!!! Nevermind! I got it!! ALL THE FUNCTIONS NEED "Return"!!!! SWEET!! Thanks everyone!

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