Sign in to follow this  
Followers 0
remin

Can not redeclare a constant

11 posts in this topic

#1 ·  Posted (edited)

This is my script to move a window to the left or right side of my screen:

 
HotKeySet("^3", "movemenu")


While 1
    Sleep(10000)
WEnd


Func movemenu()
$Form1 = ''
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>


Local $ActiefVenster = WinGetTitle("[ACTIVE]", "")
$Form1 = GUICreate("Form1", 125, 100, 265, 142)
$Left =        GUICtrlCreateButton("Left", 16, 8, 89, 25)
$Right =       GUICtrlCreateButton("Right", 16, 32, 89, 25)
$LeftBig =     GUICtrlCreateButton("LeftBig", 16, 64, 89, 25)


GUISetState(@SW_SHOW)


While 1
$nMsg = GUIGetMsg()
Switch $nMsg
 Case $GUI_EVENT_CLOSE
    GuiDelete($Form1)
    Return


Case $Left
  WinMove($ActiefVenster, "",0,0,@DesktopWidth/2,@DesktopHeight-41)
Case $Right
  WinMove($ActiefVenster, "",@DesktopWidth/2,0,@DesktopWidth/2,@DesktopHeight-41)
Case $LeftBig
  WinMove($ActiefVenster, "",0,0,@DesktopWidth*0.65,@DesktopHeight-41)


EndSwitch
WEnd
EndFunc

 

However..

When I use the shortcut, close the GUI and reuse the shortcut for another window movement it gives an error:

File "C:\Program Files (x86)\AutoIt3\Include\ButtonConstants.au3"):

Global Const $BS_GROUPBOX = 0x0007

Global Const ^ ERROR

Error: Can not redeclare a constant

------------------------------------

How can I resolve this error?

Whats wrong in my script?

Edited by remin

Share this post


Link to post
Share on other sites



Move the #include directives to the top of your script. They shouldn't be placed in a function!


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Oh.. thank you very much.

Hope you don't mind if I ask you a few more questions...

(or if you prefer that I open new topics please tell it to me)

I'm converting my scripts from autohotkey to autoit.

I noted a few problems.

1) Does autotit has this menu feature ?

    http://www.autohotkey.com/docs/commands/Menu.htm

2) WinGetClientSize gives the size of the client area.

    I need the size of the entire active window.

    Is there no keyword in autoit to do this?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

  • Autoit offers a few commands to work with menus. The function to use depends on what you want to do (tray menu etc.)
  • WinGetPos returns the position, with and height of a window
Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Thank you very much  :thumbsup:

Share this post


Link to post
Share on other sites

:D


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

 

  • Autoit offers a few commands to work with menus. The function to use depends on what you want to do (tray menu etc.)

 

A little update:

Please see attachment what I wanted to create in autoit

(not a right click menu but a menu like this one which pop-up (where the mouse is) after using a hotkey)

post-48231-0-34033400-1381835976_thumb.j

Share this post


Link to post
Share on other sites

Is this a menu you want to "attach" to an application? If yes, which application?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Is this a menu you want to "attach" to an application? If yes, which application?

 

No, it is not attched to an application.

I created this menu in autohotkey.

Its activated by an hotkey. The hotkey pops-up this menu.

I click on it to change case of text.

After clicking on an item, the menu is deleted.

Share this post


Link to post
Share on other sites

Can you post the AHK code?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Sure 

^8::       ;; Convert Case MENU
KeyWait, Ctrl


Menu,convert2,Add
Menu,convert2,Delete
menu,convert2,Add,&Upper Case,dcUpper
menu,convert2,Add,&Lower Case,dcLower
menu,convert2,Add,&Title Case,dcTitle
menu,convert2,Add,&Title Case >1,dcTitle>1
menu,convert2,Add,&Sentence Case,dcSentence
Menu,convert2,Show
Return


;---------------------
dcStart:  ;SUB Start
Send, ^x
KeyWait, Ctrl
ClipWait
Return
;---------------------
dcEnd:    ;SUB End
Sleep, 200
Send, ^v
KeyWait, Ctrl
sleep, 200
Return
;---------------------  


dcUpper:
GoSub, dcStart
StringUpper, Clipboard, Clipboard
GoSub, dcEnd
return


dcLower:
GoSub, dcStart
StringLower, Clipboard, Clipboard
GoSub, dcEnd
return


dcTitle:
GoSub, dcStart
StringLower, Clipboard, Clipboard
Clipboard := RegExReplace(Clipboard, "(^|\s|\n^)(\w)", "$1$U2")
GoSub, dcEnd
return


dcTitle>1:
GoSub, dcStart
StringLower, Clipboard, Clipboard
Clipboard := RegExReplace(Clipboard, "(^|\s|\n^)(\w)(\w+)", "$1$U2$3")
GoSub, dcEnd
return


dcSentence:
GoSub, dcStart
StringLower, Clipboard, Clipboard
Clipboard := RegExReplace(Clipboard, "(((^|([.!?]+\s+))[a-z])| i | i')", "$u1")
GoSub, dcEnd
return

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