Jump to content

Recommended Posts

Posted (edited)

Hi 

 

This ouestion might have landed somewhat of target.

Using  Windows 10, version 1803

My problem it that I used version v3.3.12.0 to do a simple script  to simplify my work i genaology.

It have worked very well compiled sins (about ) 2014.

Now when I try to edit the script it kind of corrupt my computer so I have to restart it, both as script and compiled. 
( For example: selecting one Icon on the desk will select many other ikons, and many other strange behaviors.)

I have read that there are done some script breaking changes sins my version
But  before I install the latest version and try to edit the script I would like some opinion about the script.
So I do not have done something stupid error that will corrupt my computer even more with the new version.
Or, are there som better way to do the job?

the script simply should ad some text to the clipboard content -  depending on hotkey - to the selected editor I work with. 
It was a long time sins I got it working so I do not remember why some lines are there. 
for example warning above the line : GUIRegisterMsg($WM_CLIPBOARDUPDATE, 'WM_CLIPBOARDUPDATE') is for me not so easy to understand and how to avoid.

thanks for any respond.
Here is the script: 


 

   #include <EditConstants.au3>
   #include <GUIConstantsEx.au3>
   #include <MsgBoxConstants.au3>
   #include <WinAPISys.au3>
   #include <WindowsConstants.au3>
   #include <StringConstants.au3>
   #Include <GUIConstants.au3>
   #Include <HotKey.au3>
   #include <Clipboard.au3>
   #include <Date.au3>

; test windows version, is this really nessesary? 
        If _WinAPI_GetVersion() < '6.0' Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows Vista or later.')
    Exit
EndIf

; set up the GUI
local $sFont = ""
Local $hForm = GUICreate('Urklippet =>> ' & StringReplace(@ScriptName, '.au3', '()'), 800, 300, 10, 10, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX), $WS_EX_TOPMOST)
Global $g_idEdit = GUICtrlCreateEdit('', 0, 0, 800, 300, BitOR($GUI_SS_DEFAULT_EDIT, $ES_READONLY))
GUICtrlSetFont($g_idEdit, 11, 700, 2, $sFont) ; set fonts and size aso.

; Warning: blocking of running user functions which executes window messages with commands such as "MsgBox()" can
; lead to unexpected behavior, the return to the system should be as fast as possible !!!
GUIRegisterMsg($WM_CLIPBOARDUPDATE, 'WM_CLIPBOARDUPDATE')
GUISetState(@SW_SHOW)


; Some constats
        Global Const $VK_ESCAPE = 0x1B
        Global Const $VK_F11 = 0x7a
        Global Const $VK_F10 = 0x79
        Global Const $VK_F9 = 0x78
        Global Const $VK_F8 = 0x77
        Global Const $VK_F7 = 0x76
        Global Const $VK_F6 = 0x75
        Global Const $VK_F5 = 0x74
        Global Const $VK_F4 = 0x73

        ; Assign "F11" and "F12"  hotkeys with Typnotes()
        _HotKey_Assign($VK_F4, 'Svedb')
        _HotKey_Assign($VK_F5, 'Svebef1950')
        _HotKey_Assign($VK_F6, 'Svebef1960')
        _HotKey_Assign($VK_F7, 'Svebef1970')
        _HotKey_Assign($VK_F8, 'Svebef1980')
        _HotKey_Assign($VK_F9, 'Svebef1990')
        _HotKey_Assign($VK_F10, 'Birthday')
    ;    _HotKey_Assign($VK_F11, 'Svedb')      ; reassign Svedb to F4 as Avast browser use F11 to Full-screen

        ; Assign "CTRL-ESC" with Quit()
        _HotKey_Assign(BitOR($CK_CONTROL, $VK_ESCAPE), 'Quit')

; setup listening to clipboard
_WinAPI_AddClipboardFormatListener($hForm) 
_SendMessage($hForm, $WM_CLIPBOARDUPDATE)

; the run-loop
        While 1
            Sleep(10)

            Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                Quit()
            EndSwitch

        WEnd
; end of the run-loop

Func WM_CLIPBOARDUPDATE($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam, $lParam

    _ClipBoard_Open(0)
    GUICtrlSetData($g_idEdit, _ClipBoard_GetData($CF_TEXT))
    _ClipBoard_Close()
    Return 0
EndFunc   ;==>WM_CLIPBOARDUPDATE


; the hotkeys

Func Svebef1950()
    Send("* SVEBEF 1950")
    send("{ENTER}** {ENTER}")
    send("^V")
    send("{ENTER} ")
    send("{ENTER} ")
 EndFunc

Func Svebef1960()
    Send("* SVEBEF 1960")
    send("{ENTER}** ")
    send("^V")
    send("{ENTER} ")
    send("{ENTER} ")
 EndFunc


 Func Svebef1970()
    Send("* SVEBEF 1970")
    send("{ENTER}** {ENTER}")
    send("^V")
    send(" {ENTER}")
    send(" ")
 EndFunc

 Func Svebef1980()
    Send("* SVEBEF 1980")
    send("{ENTER}** {ENTER}")
    send("^V")
    send(" {ENTER}")
    send("{ENTER} ")
 EndFunc

 Func Svebef1990()
    Send("* SVEBEF 1990")
    send("{ENTER}** {ENTER}")
    send("^V")
    send(" {ENTER}")
    send("{ENTER} ")
 EndFunc

  Func Birthday()
    Send("* birthday.se " & _NowDate())
    send("{ENTER}** ")
    send("^V")
    send("{ENTER}")
 EndFunc

 Func Svedb()
    Send("* SVEDB")
    send("{ENTER}** ")
    ; cleanup() ; i framtidan kanske man ids göra så att data fixas automatiskt?!
    send("^V")
    send(" {ENTER}")
    send(" ")
 EndFunc

   Func Quit()
            Exit
   EndFunc   ;==>Quit

 

Edited by Jos
added CODEBOX <>
  • 2 weeks later...

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...