Jump to content

Odd flashing and locking up


Recommended Posts

Hi, working on making hotkeys from several chunks of code and I keep getting lockups where I can highlight text with my mouse, but I cannot get rid of it by Backspace or Delete Key. It just highlights the text and then lets me move it around in an email. It seems to have started with the very bottom lines of code. See picture for flashing lines and code snippet for, we,, the code. Appreciate any enlightening on this.

; *******************************
; --------The HotKeys------------
; *******************************
; Individual Paper Printing
HotKeySet ("^!+{1}", "Cover")
HotKeySet ("^!+{2}", "LegalCopies")
HotKeySet ("^!+{3}", "OfficeCopy")
HotKeySet ("^!+{4}", "BidNumbers")
; All Paper Printing
HotKeySet ("^!+{f1}", "PrintDocs1")

HotKeySet ("^!+{f2}", "PDFCover")
HotKeySet ("^!+{f3}", "GoogleEarth")
HotKeySet ("^!+{f4}", "PrintDiagrams")
HotKeySet ("^!+{f5}", "ContractPDF")
HotKeySet ("^!+{f6}", "Terms")
HotKeySet ("^!+{f7}", "Bookmarks")


HotKeySet ("^!+{f8}", "Letter")

; *******************************
; -----------Includes------------
; *******************************
#include <Excel.au3>
#include <MsgBoxConstants.au3>


While 1
   Sleep (50)

WEnd


Func Cover()
      ; *****************************************************************************
      ; Create application object or connect to an already running Excel instance
      ; *****************************************************************************
      Local $oExcel = _Excel_Open()
      If Not IsObj($oExcel) Then
          Exit MsgBox(0, "Error", "_Excel_Open()")
      EndIf
      ; *****************************************************************************
      ; print out 1 copy of cover sheet for mailing on plain paper
      ; *****************************************************************************
      _Excel_Print($oExcel,$oExcel.Worksheets("Cover").Range("A1:K51"), 1, "Xerox WorkCentre 7556 PS Plain Paper")
      Sleep (500)
   EndFunc



Func LegalCopies()
      ; *****************************************************************************
      ; Create application object or connect to an already running Excel instance
      ; *****************************************************************************
      Local $oExcel = _Excel_Open()
      If Not IsObj($oExcel) Then
          Exit MsgBox(0, "Error", "_Excel_Open()")
      EndIf
      ; *****************************************************************************
      ; print 2 copies of contracts on contract paper for mailing
      ; *****************************************************************************
      _Excel_Print($oExcel, "A1:M55", 2, "Xerox WorkCentre 7556 PS Contract Paper")
      Sleep (500)
EndFunc


Func OfficeCopy()
      ; *****************************************************************************
      ; Create application object or connect to an already running Excel instance
      ; *****************************************************************************
      Local $oExcel = _Excel_Open()
      If Not IsObj($oExcel) Then
          Exit MsgBox(0, "Error", "_Excel_Open()")
      EndIf
      ; *****************************************************************************
      ; print 1 copy of conttract for office on plain paper
      ; *****************************************************************************
      _Excel_Print($oExcel, "A1:M55", 1, "Xerox WorkCentre 7556 PS Plain Paper")
      Sleep (500)
EndFunc



Func BidNumbers()
      ; *****************************************************************************
      ; Create application object or connect to an already running Excel instance
      ; *****************************************************************************
      Local $oExcel = _Excel_Open()
      If Not IsObj($oExcel) Then
          Exit MsgBox(0, "Error", "_Excel_Open()")
      EndIf
      ; *****************************************************************************
      ; print out 1 copy of numbers on plain paper
      ; *****************************************************************************
      _Excel_Print($oExcel,$oExcel.Worksheets("Bid Number").Range("A1:H30"), 1, "Xerox WorkCentre 7556 PS Plain Paper")
      Sleep (500)
EndFunc


Func PrintDocs1()
      ; *****************************************************************************
      ; Create application object or connect to an already running Excel instance
      ; *****************************************************************************
      Local $oExcel = _Excel_Open()
      If Not IsObj($oExcel) Then
          Exit MsgBox(0, "Error", "_Excel_Open()")
      EndIf
      ; *****************************************************************************
      ; print out 1 copy of cover sheet for mailing on plain paper
      ; *****************************************************************************
      _Excel_Print($oExcel,$oExcel.Worksheets("Cover").Range("A1:K51"), 1, "Xerox WorkCentre 7556 PS Plain Paper")
      Sleep (500)

      ; *****************************************************************************
      ; print 2 copies of contracts on contract paper for mailing
      ; *****************************************************************************
      _Excel_Print($oExcel, "A1:M55", 2, "Xerox WorkCentre 7556 PS Contract Paper")
      Sleep (500)

      ; *****************************************************************************
      ; print 1 copy of conttract for office on plain paper
      ; *****************************************************************************
      _Excel_Print($oExcel, "A1:M55", 1, "Xerox WorkCentre 7556 PS Plain Paper")
      Sleep (500)

      ; *****************************************************************************
      ; print out 1 copy of numbers on plain paper
      ; *****************************************************************************
      _Excel_Print($oExcel,$oExcel.Worksheets("Bid Number").Range("A1:H30"), 1, "Xerox WorkCentre 7556 PS Plain Paper")
      Sleep (500)
EndFunc



Func Bookmarks()
   ; *****************************************************************************
   ; Now creating bookmarks for all pages correctly ordered in PDF Converter Professional
   ; *****************************************************************************
   WinActivate ("AsphaltEstimating - PDF Converter Professional 7.2")
   WinWaitActive ("AsphaltEstimating - PDF Converter Professional 7.2", "", 5)
   WinSetState("AsphaltEstimating - PDF Converter Professional 7.2", "", @SW_MAXIMIZE)
   Sleep (75)
   ; *****************************************************************************
   ; ensure 1st page is in front
   ; *****************************************************************************
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^{HOME}")
   Sleep (75)
   ; *****************************************************************************
   ; initiate bookmark panel
   ; *****************************************************************************
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^{b}")
   Sleep (75)
   ; *****************************************************************************
   ; finalise created bookmark and start cleaning any existing bookmarks
   ; *****************************************************************************
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{ENTER}")
   Sleep (75)
   ; *****************************************************************************
   ; now delete remnant bookmarks to ensure properly assigned once done
   ; *****************************************************************************
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{Del 20}")
   Sleep (75)
   ; *****************************************************************************
   ; ensure again page one is to begining by flipping back
   ; *****************************************************************************
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^{HOME}")
   Sleep (75)
   ; *****************************************************************************
   ; now start creating real bookmarks
   ; *****************************************************************************
   ; initiate bookmark process
   ; *****************************************************************************
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^{b}")
   Sleep (75)
   ; *****************************************************************************
   ; enter bookmark name & confirm
   ; *****************************************************************************
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "Cover")
   Sleep (75)
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{ENTER}")
   Sleep (75)
   ; *****************************************************************************
   ; proceed to next page to bookmark
   ; *****************************************************************************
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^+{RIGHT}")
   ; *****************************************************************************
   ; initiate bookmark process
   ; *****************************************************************************
   Sleep (75)
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^{b}")
   Sleep (75)
   ; *****************************************************************************
   ; enter bookmark name & confirm
   ; *****************************************************************************
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "Diagram")
   Sleep (75)
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{ENTER}")
   Sleep (75)
   ; *****************************************************************************
   ; proceed to next page to bookmark
   ; *****************************************************************************
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^+{RIGHT}")
   ; *****************************************************************************
   ; initiate bookmark process
   ; *****************************************************************************
   Sleep (75)
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^{b}")
   Sleep (75)
   ; *****************************************************************************
   ; enter bookmark name & confirm
   ; *****************************************************************************
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "Proposal")
   Sleep (75)
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{ENTER}")
   Sleep (75)
   ; *****************************************************************************
   ; proceed to next page to bookmark
   ; *****************************************************************************
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^+{RIGHT}")
   ; *****************************************************************************
   ; initiate bookmark process
   ; *****************************************************************************
   Sleep (75)
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^{b}")
   Sleep (75)
   ; *****************************************************************************
   ; enter bookmark name & confirm
   ; *****************************************************************************
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "Terms")
   Sleep (75)
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{ENTER}")
   Sleep (75)
   ; *****************************************************************************
   ; go to 1st bookmark
   ; *****************************************************************************
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^{HOME}")
   Sleep (75)
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{UP 5}")
   Sleep (75)
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{ENTER}")
   Sleep (75)
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^s")
   Sleep (250)
   WinClose ("AsphaltEstimating - PDF Converter Professional 7.2")
   WinWaitClose ("AsphaltEstimating - PDF Converter Professional 7.2", "", 500)
EndFunc


Func PDFCover()
   ; *****************************************************************************
   ; begin by ensuring no previous PDF is on desktop
   ; *****************************************************************************
   FileDelete("C:\Users\Rick\Desktop\AsphaltEstimating.pdf")
   ; *****************************************************************************
   ; Create application object or connect to an already running Excel instance
   ; *****************************************************************************
   Local $oExcel = _Excel_Open()
   If Not IsObj($oExcel) Then
    Exit MsgBox(0, "Error", "_Excel_Open()")
   EndIf
   ; *****************************************************************************
   ; print "Cover" to PDF Converter Professional 7.2
   ; *****************************************************************************
   _Excel_Print($oExcel,$oExcel.Worksheets("Cover").Range("A1:K51"), 1, "DocuCom PDF Driver")
   WinWaitActive ("AsphaltEstimating - PDF Converter Professional 7.2")
   ; Below line added 6_6_2016
   WinWaitActive ("AsphaltEstimating - PDF Converter Professional 7.2")
   WinClose ("AsphaltEstimating - PDF Converter Professional 7.2")
EndFunc


Func GoogleEarth()
   ; *****************************************************************************
   ; switch to Google Earth Pro which should be pre aligned and maxamized
   ; to take Google Earth Snapshot via PDF Converter Professional 7.2
   ; *****************************************************************************
   WinActivate ("Google Earth Pro")
   WinWait ("Google Earth Pro")
   WinWaitActive ("Google Earth Pro")
   WinSetState("Google Earth Pro", "", @SW_MAXIMIZE)
   Sleep (500)
   ; *****************************************************************************
   ; verify that PDF pro is not open by saving & closing it now
   ; *****************************************************************************
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^s")
   Sleep (250)
   WinClose ("AsphaltEstimating - PDF Converter Professional 7.2")
   Sleep (250)
   ; *****************************************************************************
   ; activate SnagIt pre defined PDF hotkeys to capture diagram
   ; *****************************************************************************
   send ("^+{F12}")
   WinWaitActive ("AsphaltEstimating - PDF Converter Professional 7.2", "", 1)
   Sleep (5000)
   ; *****************************************************************************
   ; crop newly created PDF Converter Professional diagram and print 2 copies
   ; 1 for mailing & 1 for office copy
   ; *****************************************************************************
   WinSetState("AsphaltEstimating - PDF Converter Professional 7.2", "", @SW_MAXIMIZE)
   Sleep (750)
   Send ("^{END}") ; switch to last page
   Sleep (250)
   Send ("^+{C}") ; crop out white
   Sleep (250)
   Send ("!{W}")
   Sleep (250)
   Send ("!{C}")
   Sleep (250)
   Send ("{ENTER}")
   Sleep (250)
   Send ("^{END}")
   Sleep (500)
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^s")
   Sleep (250)
   WinClose ("AsphaltEstimating - PDF Converter Professional 7.2")
  EndFunc


Func PrintDiagrams()
   ; *****************************************************************************
   ; -------------------print 1st diagram copy (current PDF page)-----------------
   ; *****************************************************************************
   WinActivate ("AsphaltEstimating - PDF Converter Professional 7.2")
   Sleep (250)
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^p")
   Sleep (500)
   ControlSend ("Print", "Print Range", "", "!u")
   Sleep (250)
   ControlSend ("Print", "Print Range", "", "{ENTER}")
   Sleep (500)
   ; *****************************************************************************
   ; Print 2nd diagram copy (current PDF page)
   ; *****************************************************************************
   WinActivate ("AsphaltEstimating - PDF Converter Professional 7.2")
   Sleep (250)
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^p")
   Sleep (500)
   ControlSend ("Print", "Print Range", "", "!u")
   Sleep (250)
   ControlSend ("Print", "Print Range", "", "{ENTER}")
   Sleep (250)
   ; *****************************************************************************
   ; save work and exit
   ; *****************************************************************************
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^{s}")
   WinClose ("AsphaltEstimating - PDF Converter Professional 7.2")
   WinWaitClose ("AsphaltEstimating - PDF Converter Professional 7.2", "", 500)
EndFunc


Func ContractPDF()
   ; *****************************************************************************
   ; Create application object or connect to an already running Excel instance
   ; *****************************************************************************
   Local $oExcel = _Excel_Open()
   If Not IsObj($oExcel) Then
    Exit MsgBox(0, "Error", "_Excel_Open()")
   EndIf
   ; *****************************************************************************
   ; print out Contract page to PDF (PDF Converter Professional)
   ; *****************************************************************************
   _Excel_Print($oExcel, "A1:M55", 1, "DocuCom PDF Driver")
   WinWaitActive ("AsphaltEstimating - PDF Converter Professional 7.2")
   Sleep (250)
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^s")
   Sleep (250)
EndFunc


Func Terms()
   ; *****************************************************************************
   ; insert Terms & set to last page, then save
   ; *****************************************************************************
   WinActivate ("AsphaltEstimating - PDF Converter Professional 7.2")
   sleep (125)
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^+{I}")
   Sleep (1000)
   ; *****************************************************************************
   ; enters document location and file name
   ; *****************************************************************************
   Send (@DesktopDir & ".\z-Terms 2016.pdf")
   Sleep (250)
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{ENTER}")
   sleep (250)
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "!g")
   sleep (250)
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{ENTER}")
   sleep (250)
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^s")
   sleep (250)
EndFunc


Func Letter()
   Send ("Hello" & @CRLF & "Attached is our proposal for " & @CRLF & "A hard copy has also been sent to this address so you can simply sign and return should you accept the proposal." & @CRLF & "If you have any questions or concerns, please do not hesitate to email or call me at your convenience.")
EndFunc

locking_up.png

Link to comment
Share on other sites

forgot to mention. The bottom lines of code (Func. Letter) are meant to be inserted into the web interface of the body of an email in GMail but it throws down the 1st line, then tries to send the email.

Link to comment
Share on other sites

Your description is unclear (to me), but the first thing that comes to my mind looking at your image is that something weird is going on with Windows registering ctrl/shift/alt keypresses. Now, your hotkeys have ctrl/shift/alt combinations, but they execute functions that subsequently also sends keystrokes to controls that sometimes also include ctrl/shift/alt, this may be the conflict. Try writing a function that waits for release of the ctrl, the alt and the shift keys before returning, then call that function from the first line of all your hotkey functions.

Something like this:

#include <Misc.au3>

HotKeySet("{esc}", "quitter")
HotKeySet("!a", "beeper")

While True
WEnd

Func beeper()
    waitForSpecialKeyRelease()
    beep(1000,100)
EndFunc   ;==>helloworld

Func waitForSpecialKeyRelease()
    While _IsPressed(10) Or _IsPressed(11) Or _IsPressed(12)
    WEnd
EndFunc   ;==>waitForSpecialKeyRelease

Func quitter()
    Exit
EndFunc   ;==>quitter

/edit to be clear: the idea is to press alt-a to hear a beep. If you hold down the alt key, then press the a and release the a but hold the alt key, nothing will happen, only after you release the alt key the function will continue and sound the beep. At that point it would also be safer to send ctrl/shift/alt keystrokes. Sending those is always fidgety :/

Edited by SadBunny

Roses are FF0000, violets are 0000FF... All my base are belong to you.

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