AasimPathan Posted February 21, 2019 Share Posted February 21, 2019 Hi, I am creating a script that displays user names and once its select it would copy the email address to whatever window that's open be it word or notepad or outlook etc. But the below is not working for me can someone help me get it working please? expandcollapse popup#include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> AddUsers() Func AddUsers() Local $hGUI = GUICreate("AddUsers", 300, 200) Opt("GUICoordMode", 0) Local $idCheckbox1 = GUICtrlCreateCheckbox("FirstName1, LastName", 10, 10) Local $idCheckbox2 = GUICtrlCreateCheckbox("FirstName2, LastName", -1, 25) Local $idCheckbox3 = GUICtrlCreateCheckbox("FirstName3, LastName", -1, 25) Local $idButton_Close = GUICtrlCreateButton("Close", 200, 10) GUISetState(@SW_SHOW, $hGUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idButton_Close ExitLoop Case $idCheckbox1 If _IsChecked($idCheckbox1) Then Send ("FirstName1@domain.com") Else ;I want it do nothing here - MsgBox($MB_SYSTEMMODAL, "", "The checkbox is not checked.", 0, $hGUI) EndIf Case $idCheckbox2 If _IsChecked($idCheckbox2) Then Send ("FirstName2@domain.com") Else ;I want it do nothing here - MsgBox($MB_SYSTEMMODAL, "", "The checkbox is not checked.", 0, $hGUI) EndIf Case $idCheckbox3 If _IsChecked($idCheckbox3) Then Send ("FirstName3@domain.com") Else ;I want it do nothing here - MsgBox($MB_SYSTEMMODAL, "", "The checkbox is not checked.", 0, $hGUI) EndIf EndSwitch WEnd GUIDelete($hGUI) EndFunc Func _IsChecked($idControlID) Return BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED EndFunc Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted February 21, 2019 Share Posted February 21, 2019 @AasimPathan Send command is working on your GUI, so the target GUI is yours. You should use Control* functions to send/set some text in a Window. If you replace Send() with ConsoleWrite(), you can see that the command it's executed Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
AasimPathan Posted February 21, 2019 Author Share Posted February 21, 2019 1 hour ago, FrancescoDiMuro said: @AasimPathan Send command is working on your GUI, so the target GUI is yours. You should use Control* functions to send/set some text in a Window. If you replace Send() with ConsoleWrite(), you can see that the command it's executed sorry i tried ConsoleWrite() instead of Send() still didn't do anything? can you tell me how to use Control* function?? One place that i am planning to apply these email address are in protecting a workbook or document. so i am not sure if i can use ControlSend here. Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted February 21, 2019 Share Posted February 21, 2019 @AasimPathan Instead of using Control* functions, you could use VBA to access and set permissions to the document Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
AasimPathan Posted February 22, 2019 Author Share Posted February 22, 2019 nah i'd like to do this in AutoIt because we already developed Add-Ins etc for Office so if I add VBA code for adding permissions my boss will tell me to do this through our Office Add-In Plugin instead which would require more steps to be configured. The method i am thinking is this. 1. A Checkbox pops up with the list of users 2. The person applying permissions will select any or all users they want. 3. They press on Insert / copy button, after they are done selecting. 4. The selections are copied in clipboard 5. Then i just add Send ("{^v}") as the next line and we are done. I have infact been able to configure it to copy text by using ClipPut but am not able to do it for multiple users. e.g. if i select FirstName1 its copied to clipboard but if I select FirstName1, FirstName2, FirstName3 only FirstName3 is copied to clipboard so i need a way for it to Parse text from clipboard or something. Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted February 22, 2019 Share Posted February 22, 2019 @AasimPathan The suggestion was to do the VBA code in AutoIt, but if that's not the approach you want to take, then do it how do you want. 2 hours ago, AasimPathan said: I have infact been able to configure it to copy text by using ClipPut but am not able to do it for multiple users. e.g. if i select FirstName1 its copied to clipboard but if I select FirstName1, FirstName2, FirstName3 only FirstName3 is copied to clipboard so i need a way for it to Parse text from clipboard or something. This should help you a little bit Spoiler #include <MsgBoxConstants.au3> Global $strClipContent = "" ClipPut("1") MsgBox($MB_ICONINFORMATION, "Clip Content (single data):", ClipGet()) For $i = 1 To 10 Step 1 $strClipContent &= ($i < 10) ? $i & "," : $i Next ClipPut($strClipContent) MsgBox($MB_ICONINFORMATION, "Clip Content (multiple data):", ClipGet()) Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
AasimPathan Posted March 13, 2019 Author Share Posted March 13, 2019 On 2/22/2019 at 6:47 PM, FrancescoDiMuro said: @AasimPathan The suggestion was to do the VBA code in AutoIt, but if that's not the approach you want to take, then do it how do you want. This should help you a little bit Hide contents #include <MsgBoxConstants.au3> Global $strClipContent = "" ClipPut("1") MsgBox($MB_ICONINFORMATION, "Clip Content (single data):", ClipGet()) For $i = 1 To 10 Step 1 $strClipContent &= ($i < 10) ? $i & "," : $i Next ClipPut($strClipContent) MsgBox($MB_ICONINFORMATION, "Clip Content (multiple data):", ClipGet()) Can you help code that into my existing script as mentioned in the first post? I didn't understand your script at all to use it in my code. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now