IEGet() vs WBGet() Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: IEGet() vs WBGet()

06 Sep 2017, 20:37

A text file that just contains var = string, or var := "string" lines should be fine. Imagine that where you place the #Include line, the text of the included file is literally inserted there.

In your example use (summary), not (%summary%).
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
bballjoe12
Posts: 114
Joined: 20 Aug 2017, 09:11

Re: IEGet() vs WBGet()

06 Sep 2017, 21:25

Works perfectly! Thank you so much! This will save me from having a huge hassle in the future!
User avatar
tank
Posts: 3130
Joined: 28 Sep 2013, 22:15
Location: CarrolltonTX
Contact:

Re: IEGet() vs WBGet()

07 Sep 2017, 07:16

(summary)
We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
Telegram is the best way to reach me
https://t.me/ttnnkkrr
If you have forum suggestions please submit a
Check Out WebWriter
a4u

Re: IEGet() vs WBGet()

07 Sep 2017, 12:07

Who comes up with these function names anyways? Just seems confusing having 2 separate functions like this ... :problem: ;)
User avatar
tank
Posts: 3130
Joined: 28 Sep 2013, 22:15
Location: CarrolltonTX
Contact:

Re: IEGet() vs WBGet()

07 Sep 2017, 12:21

you did
We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
Telegram is the best way to reach me
https://t.me/ttnnkkrr
If you have forum suggestions please submit a
Check Out WebWriter
bballjoe12
Posts: 114
Joined: 20 Aug 2017, 09:11

Re: IEGet() vs WBGet()

07 Sep 2017, 23:32

1 more question!

So I have a GUI that has a list box that contains 10 scripts or so. I figured I could put all the scripts and GUI files into the same folder so I could use #include inside of the GUI file.

All of my scripts start like this, as they are currently in a different folder then my GUI file:

Code: Select all

WBGet(WinTitle="ahk_class IEFrame", Svr#=1) 
{ ; based on ComObjQuery docs
   static   msg := DllCall("RegisterWindowMessage", "str", "WM_HTML_GETOBJECT")
   ,   IID := "{0002DF05-0000-0000-C000-000000000046}" ; IID_IWebBrowserApp
;   ,   IID := "{332C4427-26CB-11D0-B483-00C04FD90119}" ; IID_IHTMLWindow2
   SendMessage msg, 0, 0, Internet Explorer_Server%Svr#%, %WinTitle%
   if (ErrorLevel != "FAIL") {
      lResult:=ErrorLevel, VarSetCapacity(GUID,16,0)
      if DllCall("ole32\CLSIDFromString", "wstr","{332C4425-26CB-11D0-B483-00C04FD90119}", "ptr",&GUID) >= 0 {
         DllCall("oleacc\ObjectFromLresult", "ptr",lResult, "ptr",&GUID, "ptr",0, "ptr*",pdoc)
         return ComObj(9,ComObjQuery(pdoc,IID,IID),1), ObjRelease(pdoc)
      }
   }
}

#f::
	pwb := WBGet()
So I tried the #include within my GUI file and I got the following error:
Error at line 3 in #include file
"C:\users.....hardwarerequest.ahk".

Line Text: WBGet(WinTitle="ahk_class IEFrame", Svr#=1)
Error: Duplicate function definition.

The program will exit.
Now I understand all my scripts start out the same and I think I know why I got that error message, but would there be anyway to edit my above code that it will load that top part IF ONLY it hasn't loaded it already from an already included loaded script?
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: IEGet() vs WBGet()

08 Sep 2017, 01:58

Tricky one that. AHK's a bit tough with functions.

In this scenario I would remove WBGet from all of the scripts. Creating a script called WBGet.ahk, would mean that if a script couldn't find WBGet inside itself, it would check for a script called WBGet.ahk and look there.

Otherwise you could have one master file containing WBGet, with #Include lines to add in the other files.

Before you posted, I had just been wondering if there could be other possibilities for resolving this issue, I make some brief mentions of this at the end of my Wish List 2.0. I didn't mention it there, but an idea would be to just ignore duplicate definitions and use the first one you find.

Wish List 2.0 - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 13&t=36789
[EDIT:] Oh look, 3*6789*, an auspicious number.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
bballjoe12
Posts: 114
Joined: 20 Aug 2017, 09:11

Re: IEGet() vs WBGet()

08 Sep 2017, 06:06

I like the WBGet.ahk idea! I will try that today!
bballjoe12
Posts: 114
Joined: 20 Aug 2017, 09:11

Re: IEGet() vs WBGet()

08 Sep 2017, 11:43

So now I am having another issue. I have a main NOEDITTEST.txt file with the following variables:
notes = arid_WIN_2_1000000151
summary = arid_WIN_2_1000000000
impact = arid_WIN_2_1000000163
urgency = arid_WIN_2_1000000162
incident = arid_WIN_2_1000000099
source = arid_WIN_2_1000000215
assign = WIN_2_303684100
status = arid_WIN_2_7
streason = arid_WIN_2_1000000881
resolution = arid_WIN_2_1000000156
marker = arid_WIN_2_1000005980
ctab = WIN_2_1000000200
button = btn f1
op1 = arid_WIN_2_1000000063
op2 = arid_WIN_2_1000000064
op3 = arid_WIN_2_1000000065
res1 = arid_WIN_2_1000002488
res2 = arid_WIN_2_1000003889
res3 = arid_WIN_2_1000003890
pro1 = arid_WIN_2_200000003
pro2 = arid_WIN_2_200000004
pro3 = arid_WIN_2_200000005
proname = arid_WIN_2_240001002
respro1 = arid_WIN_2_1000003891
respro2 = arid_WIN_2_1000003892
respro3 = arid_WIN_2_1000003893
resproname = arid_WIN_2_1000003894
I also have my script file TESTWITHVARIABLES.ahk with the following code:

Code: Select all

SetWorkingDir, %A_ScriptDir%

#include NOEDITTEST.txt

WBGet(WinTitle="ahk_class IEFrame", Svr#=1) 
{ ; based on ComObjQuery docs
   static   msg := DllCall("RegisterWindowMessage", "str", "WM_HTML_GETOBJECT")
   ,   IID := "{0002DF05-0000-0000-C000-000000000046}" ; IID_IWebBrowserApp
;   ,   IID := "{332C4427-26CB-11D0-B483-00C04FD90119}" ; IID_IHTMLWindow2
   SendMessage msg, 0, 0, Internet Explorer_Server%Svr#%, %WinTitle%
   if (ErrorLevel != "FAIL") {
      lResult:=ErrorLevel, VarSetCapacity(GUID,16,0)
      if DllCall("ole32\CLSIDFromString", "wstr","{332C4425-26CB-11D0-B483-00C04FD90119}", "ptr",&GUID) >= 0 {
         DllCall("oleacc\ObjectFromLresult", "ptr",lResult, "ptr",&GUID, "ptr",0, "ptr*",pdoc)
         return ComObj(9,ComObjQuery(pdoc,IID,IID),1), ObjRelease(pdoc)
      }
   }
}

#f::
	pwb := WBGet()

; Notes
	TextField := pwb.document.getElementById(notes).click()
	Send Hospital:
	Send {Enter}
	Send Floor:
	Send {Enter}
	Send Department:
	Send {Enter}
	Send Room #:
	Send {Enter}
	Send Printer Name:
	Send {Enter}
	Send {Printer IP:
	Send {Enter}
	Send Ricoh ID:
	Send {Enter 2}
	Send Issue:
	Send {Enter}
Sleep 200
	;TextField.Value := "Hospital Floor"	


; Summary
	pwb.Document.getElementById(summary).Focus()
	TextField := pwb.document.getElementById(summary)	
	pwb.Document.getElementById(summary).click()
	Send Printer > 
	;TextField.Value := "Printer >"

Sleep 300

; Impact
	pwb.document.getElementById(impact).Focus()
	pwb.document.getElementById(impact).click()
	Send {Down 4}
	Sleep 200
	Send {Enter}
	; pwb.document.getElementById(impact).value := "4-Minor/Localized"	

Sleep 300

; Urgency
	pwb.document.getElementById(urgency).Focus()
	pwb.document.getElementById(urgency).click()	
	Send {Down 4}
	Sleep 200
	Send {Enter}
	; pwb.document.getElementById(urgency).value :="4-Low"
			
; Incident Type
	pwb.document.getElementById(incident).Focus()
	pwb.document.getElementById(incident).click()	
	Send {Down}
	Sleep 200
	Send {Enter}
	; pwb.document.getElementById(incident).value :="User Service Restoration"

; Reported Source
	pwb.document.getElementById(source).Focus()
	pwb.document.getElementById(source).click()	
	Send {Down 4}
	Sleep 200
	Send {Enter}
	; pwb.document.getElementById(source).value :="Phone"

; Assign to Me
	pwb.document.getElementById(assign).click() 		

; Status
	pwb.document.getElementById(status).Focus()
	pwb.document.getElementById(status).click()	
	Send {Down 6}
	Sleep 200
	Send {Enter}
	; pwb.document.getElementById(status).value :="Closed"

; Status Reason
	pwb.document.getElementById(streason).Focus()
	pwb.document.getElementById(streason).click()	
	Send {Down 2}
	Sleep 200
	Send {Enter}
	pwb.document.getElementById(streason).value :="Transferred"

Sleep 300

; Resolution
	pwb.Document.getElementById(resolution).Focus()
	TextField := pwb.document.getElementById(resolution)	
	pwb.Document.getElementById(resolution).click()
	Send Called to NHD.
	;TextField.Value := "Called to NHD."		

Sleep 300

; Review Marker
	pwb.document.getElementById(marker).Focus()
	pwb.document.getElementById(marker).click()	
	Send {Down}
	Sleep 200
	Send {Enter}
	; pwb.document.getElementById(marker).value :="No"

; Categorization Tab

	Tabs := pwb.document.getElementById(ctab).getElementsByClassName(button)
	Tabs[1].click()

; Operational Categorization
	; Tier 1
		TextField := pwb.document.getElementById(op1).focus()	
		TextField := pwb.document.getElementById(op1).click()
		Send Add
		TextField.Value := "Add"
	
	Sleep 200

	; Tier 2
		TextField := pwb.document.getElementById(op2).focus()	
		TextField := pwb.document.getElementById(op2).click()
		Send Hardware
		TextField.Value := "Hardware"

Sleep 200

; Product Categorization

	; Tier 1
		pwb.Document.getElementById(pro1).Focus()
		TextField := pwb.document.getElementById(pro1)		
		pwb.Document.getElementById(pro1).click()
		Send Hardware End User
		;TextField.Value := "Hardware End User"
	
Sleep 200

	; Tier 2
		pwb.Document.getElementById(pro2).Focus()
		TextField := pwb.document.getElementById(pro2)		
		pwb.Document.getElementById(pro2).click()
		Send Printer
		;TextField.Value := "Printer"
	
Sleep 200

	; Tier 3
		pwb.Document.getElementById(pro3).Focus()
		TextField := pwb.document.getElementById(pro3)		
		pwb.Document.getElementById(pro3).click()
		Send Network
		;TextField.Value := "Network"

Sleep 200

	; Product Name
		pwb.Document.getElementById(proname).Focus()
		TextField := pwb.document.getElementById(proname)		
		pwb.Document.getElementById(proname).click()
		Send Printer
Sleep 130
		Send {Down}
Sleep 250
		Send {Enter}
		;TextField.Value := "Printer"

ExitApp

I click on the notes text field, then activate my hotkey, but it is inputting where the summary text should go into the notes field and not even recognizing the Impact drop down box. I don't understand why because everything after the Urgency fields and after run just fine and they have variables inserted in there. It basically has the same code as the summary, notes and input fields. Why would those 1st 3 fields not being recognized properly but everything else is!? I posted about variables earlier in this thread and all I am trying to do is save some future headache by saving all the text field IDs in 1 main file, rather then having to edit them in every script field they have happen to change.
User avatar
tank
Posts: 3130
Joined: 28 Sep 2013, 22:15
Location: CarrolltonTX
Contact:

Re: IEGet() vs WBGet()

08 Sep 2017, 11:53

pwb.document.getElementById(summary).value := "yourtext here" ?????
We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
Telegram is the best way to reach me
https://t.me/ttnnkkrr
If you have forum suggestions please submit a
Check Out WebWriter
bballjoe12
Posts: 114
Joined: 20 Aug 2017, 09:11

Re: IEGet() vs WBGet()

08 Sep 2017, 14:17

Code: Select all


pwb.document.getElementById(summary).value := "yourtext here" ?????
No luck unfortunately :( Would there be a different way other then using variables to have a main txt file containing all the text field IDs? Unless I am doing something wrong...
bballjoe12
Posts: 114
Joined: 20 Aug 2017, 09:11

Re: IEGet() vs WBGet()

12 Sep 2017, 10:02

So I have a GUI that sends code to notepad based on a certain button that is clicked. I'm trying to send this beginning code to notepad but keep getting this error:
"Error at Line 3. Line Text; Error: The leftmost character above is illegal in an expression.
I've tried using SendInput {Raw} to send the code but I know there is a few odd characters in there. Trying to send the following code to a Notepad document from the GUI:

Code: Select all

WBGet(WinTitle="ahk_class IEFrame", Svr#=1)
{ ; based on ComObjQuery docs
   static   msg := DllCall("RegisterWindowMessage", "str", "WM_HTML_GETOBJECT")
   ,   IID := "{0002DF05-0000-0000-C000-000000000046}" ; IID_IWebBrowserApp
;   ,   IID := "{332C4427-26CB-11D0-B483-00C04FD90119}" ; IID_IHTMLWindow2
   SendMessage msg, 0, 0, Internet Explorer_Server%Svr#%, %WinTitle%
   if (ErrorLevel != "FAIL") {
      lResult:=ErrorLevel, VarSetCapacity(GUID,16,0)
      if DllCall("ole32\CLSIDFromString", "wstr","{332C4425-26CB-11D0-B483-00C04FD90119}", "ptr",&GUID) >= 0 {
         DllCall("oleacc\ObjectFromLresult", "ptr",lResult, "ptr",&GUID, "ptr",0, "ptr*",pdoc)
         return ComObj(9,ComObjQuery(pdoc,IID,IID),1), ObjRelease(pdoc)
      }
   }
}

#f::
	pwb := WBGet()
Is there a better way to send all that code!?
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: IEGet() vs WBGet()

12 Sep 2017, 11:03

There can be problems simply trying to write var = string, or, var := "string", if the string contains special characters. See some examples here:
'ANSI (CP-1252) CHARACTERS (VERBATIM) (WYSIWYG) (CONTINUATION SECTIONS)'
jeeswg's characters tutorial - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=26486

Those examples can handle *any* character.

Notepad uses an Edit control, so you could use the Control command's EditPaste subcommand.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
bballjoe12
Posts: 114
Joined: 20 Aug 2017, 09:11

Re: IEGet() vs WBGet()

12 Sep 2017, 13:47

Holy moly, lol..those look crazy! So how do I input my code into 1 of the examples below? Am I still using 'SendInput'?

Code: Select all

;AHK v1 command style
;ANSI (CP-1252) 32-255 verbatim
vOutput = ;continuation section
(% ` Join`r`n
!"#$%&'()*+,-./0123456789:;<=>?
@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_
`abcdefghijklmnopqrstuvwxyz{|}~
€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ
 ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿
ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞß
àáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ
)

;AHK v1 expression style
;ANSI (CP-1252) 32-255 verbatim except double quote
vOutput := " ;continuation section
(` Join`r`n
!""#$%&'()*+,-./0123456789:;<=>?
@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_
`abcdefghijklmnopqrstuvwxyz{|}~
€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ
 ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿
ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞß
àáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ
)"

;AHK v2
;ANSI (CP-1252) 32-255 verbatim
vOutput := " ;continuation section
(% ` Join`r`n
!"#$%&'()*+,-./0123456789:;<=>?
@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_
`abcdefghijklmnopqrstuvwxyz{|}~
€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ
 ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿
ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞß
àáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ
)"
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: IEGet() vs WBGet()

12 Sep 2017, 14:24

Code: Select all

;AHK v1 command style

vText  = ;continuation section
(% ` Join`r`n
MY TEXT HERE
)

;or if you want LFs only instead of CRLFs:
;AHK v1 command style
vText  = ;continuation section
(% `
MY TEXT HERE
)

SendInput, % "{Raw}" vText
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], CodeKiller, teadrinker and 208 guests