IEGet() vs WBGet() Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
euras
Posts: 429
Joined: 05 Nov 2015, 12:56

IEGet() vs WBGet()

04 Sep 2017, 08:40

so finally I have found an answer to my question. If you want to work with the Tab you have active, you should use WBGet() instead of IEGet(). If you want to catch a Tab anywhere, use IEGet(). Jethrow tried to send an updated version of IEGet() which can grab an active Tab instead of the first one with the required Title, but his code doesn't grab the active Tab, it grabs THE LAST Tab.. Maybe someone can find why WBGet works with active Tab's and IEGet not?

Code: Select all

IEGet(Name="", HwndFilter="") {
	if (Name = "")	;// Get active window name if no parameter
		WinGetTitle, Name, % "ahk_id" HwndFilter:=WinExist("ahk_class IEFrame")
	else if (HwndFilter="A" or HwndFilter="Active")
		WinGet, HwndFilter, ID, ahk_class IEFrame
	Name := (Name="New Tab - Windows Internet Explorer")? "about:Tabs":RegExReplace(Name, " - (Windows|Microsoft) Internet Explorer")
	for wb in ComObjCreate("Shell.Application").Windows
		if wb.LocationName=Name and InStr(wb.FullName, "iexplore.exe")
			if Not HwndFilter or (HwndFilter and wb.hwnd=HwndFilter)
				return wb
}

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)
      }
   }
}
Last edited by euras on 05 Sep 2017, 07:20, edited 2 times in total.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: IEGet() vs WBGet()

04 Sep 2017, 14:01

It looks like IEGet, with HwndFilter on, gets the first tab it finds from the active *window*, not necessarily the active tab.

To get the active tab for a specific window, you just use WBGet specifying the hWnd of the window. 'Internet Explorer_Server1' always refers to the active tab for a specific window.

The NN parts of each ClassNN for the different controls in an Internet Explorer window, change depending on the tabs you activate. The text of TabWindowClass1 should always be the title of the active tab. Internet Explorer_Server1 should always refer to the active tab.

It may be as simple as: the more recently a tab was active, the lower its NN.

I believe that the Explorer/IE windows object loop, returns items tabs in the order they were created.

I use WBGet all the time, I never use IEGet.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
euras
Posts: 429
Joined: 05 Nov 2015, 12:56

Re: IEGet() vs WBGet()

05 Sep 2017, 06:09

jeeswg wrote:I use WBGet all the time, I never use IEGet.
I have tried to adapt WBGet to my code and in some places it works fine, but in some - doesn't work at all. It seems that WBGet doesn't catch the pwb at all. And I can't find the answer why the same command works well in one page and doesn't work at all in other.. If I replace WBGet in those situations with IEGet, then the code "grabs" pwb. I'm out of ideas why it's happening... If you use WBGet all the time, I think you should be met that problem, maybe you can help me with solution too... When WBGet grabs the pwb, I get 0 in ErrorLevel, when WBGet doesn't grab the pwb, I get "FAIL" in ErrorLevel.

Code: Select all

array1 := {KeyA: "Service: Instrumentpaneler - Microsoft Dynamics CRM", KeyB: "Microsoft Dynamics CRM", KeyD: "Service: Instrumentbord - Microsoft Dynamics CRM"}
array2 := {onz: "contentIFrame1", twz: "contentIFrame0"}
For rez, value in array1
for rr, val in array2
	{
		pwb.Visible := True
		pwb := WBGet(value)
		tt := pwb.document.getElementById(val).contentDocument.getElementById("formselectorcontainer").innerText
			if (tt <> "")
				break 2
	}
MsgBox %tt%
User avatar
tank
Posts: 3128
Joined: 28 Sep 2013, 22:15
Location: CarrolltonTX
Contact:

Re: IEGet() vs WBGet()

05 Sep 2017, 07:38

with wget you have to query the browser from the document. Is that enough of a hint?
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
euras
Posts: 429
Joined: 05 Nov 2015, 12:56

Re: IEGet() vs WBGet()

05 Sep 2017, 08:02

tank wrote:with wget you have to query the browser from the document. Is that enough of a hint?
no, sadly but no :( I have tried to find what variables the code gets from different page fro WBGet (like %msg%, %wintitle%), but they are the same in all pages, so I don't know what to do next. Maybe I need to do something with Internet Explorer_Server1 ?
User avatar
tank
Posts: 3128
Joined: 28 Sep 2013, 22:15
Location: CarrolltonTX
Contact:

Re: IEGet() vs WBGet()

05 Sep 2017, 08:44

Nope you need to let wbget get the document instead of trying to get the browser IID and just like in the last line of that function where it queries for the document IID you would then query the document for the browser IID
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
User avatar
tank
Posts: 3128
Joined: 28 Sep 2013, 22:15
Location: CarrolltonTX
Contact:

Re: IEGet() vs WBGet()  Topic is solved

05 Sep 2017, 08:53

I was going to wait and see if you figure it out but here from my personal library is how to do it see if you can translate it

Code: Select all

 
ControlGet, hwnd, Hwnd,, Internet Explorer_Server1, ahk_class IEFrame
pwb := IWebBrowserApp_from_Internet_Explorer_Server_HWND( hwnd, 1 )
IWebBrowserApp_from_IWebDOCUMENT( IWebDOCUMENT )
	{
	static IID_IWebBrowserApp := "{0002DF05-0000-0000-C000-000000000046}"  ; IID_IWebBrowserApp
	return ComObj(9,ComObjQuery( IHTMLWindow2_from_IWebDOCUMENT( IWebDOCUMENT ), IID_IWebBrowserApp, IID_IWebBrowserApp),1)
	}

IWebBrowserApp_from_Internet_Explorer_Server_HWND( hwnd, Svr#=1 ) 
	{               ;// based on ComObjQuery docs
	static msg := DllCall( "RegisterWindowMessage", "str", "WM_HTML_GETOBJECT" )
		, IID_IWebDOCUMENT := "{332C4425-26CB-11D0-B483-00C04FD90119}"
	
	SendMessage msg, 0, 0, Internet Explorer_Server%Svr#%, ahk_id %hwnd%
	
	if (ErrorLevel != "FAIL") 
		{
		lResult := ErrorLevel
		VarSetCapacity( GUID, 16, 0 )
		if DllCall( "ole32\CLSIDFromString", "wstr", IID_IWebDOCUMENT, "ptr", &GUID ) >= 0 
			{
			DllCall( "oleacc\ObjectFromLresult", "ptr", lResult, "ptr", &GUID, "ptr", 0, "ptr*", IWebDOCUMENT )
			return  IWebBrowserApp_from_IWebDOCUMENT( IWebDOCUMENT )
			}
		}
	}
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
euras
Posts: 429
Joined: 05 Nov 2015, 12:56

Re: IEGet() vs WBGet()

05 Sep 2017, 09:06

tank wrote:I was going to wait and see if you figure it out but here from my personal library is how to do it see if you can translate it
I would be glad to say that I figure it out, but no.. I checked your code but it doesn't work at all, because it calls to nonexistent function (I think IHTMLWindow2_from_IWebDOCUMENT( IWebDOCUMENT )). I don't use extra libraries if it came from there. So I'm still stuck in that :/
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: IEGet() vs WBGet()

05 Sep 2017, 09:14

This is how I would get access to an Internet Explorer tab either via WBGet or via an object loop.

Code: Select all

q:: ;get active tab from a specific window
WinGet, hWnd, ID, A
;WinGet, hWnd, ID, ahk_class IEFrame
oWB := WBGet("ahk_id " hWnd)
MsgBox, % oWB.document.title "`r`n" oWB.document.url
oWB := ""
return

;==================================================

w:: ;loop through all tabs (and get tab by hWnd/title/url)
vOutput := ""
;hWnd := "MyHWnd"
hWnd := 0
for oWB in ComObjCreate("Shell.Application").Windows
	if (!hWnd || (hWnd = oWB.HWND))
	&& (oWB.Name = "Internet Explorer")
	{
		vOutput .= oWB.document.title "`r`n" oWB.document.url "`r`n`r`n"
		;if (oWB.document.title = "MyTitle")
		;	break
		;if (oWB.document.url = "MyUrl")
		;	break
	}
MsgBox, % oWB.document.title "`r`n" oWB.document.url
oWB := ""
Clipboard := vOutput
MsgBox, % vOutput
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
tank
Posts: 3128
Joined: 28 Sep 2013, 22:15
Location: CarrolltonTX
Contact:

Re: IEGet() vs WBGet()

05 Sep 2017, 09:15

oops sorry about that

Code: Select all

IHTMLWindow2_from_IWebDOCUMENT( IWebDOCUMENT )
	{
	static IID_IHTMLWindow2 := "{332C4427-26CB-11D0-B483-00C04FD90119}"  ; IID_IHTMLWindow2
	return ComObj(9,ComObjQuery( IWebDOCUMENT, IID_IHTMLWindow2, IID_IHTMLWindow2),1)
	}
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()

05 Sep 2017, 10:07

So after reading through this thread (I am a newbie to all this COM stuff) is it possible to have 2 tabs open and switch back between them and still be able to use scripts? I will post mine below (HUGE thank you to Capn Odin who has helped me 10000% on this script)....

Code: Select all

IEGet(UrlOrTitle){
	for wb in ComObjCreate("Shell.Application").Windows() {
		if(InStr(wb.FullName, "iexplore.exe")) {
			if(UrlOrTitle == "" || InStr(wb.LocationURL, UrlOrTitle) || InStr(wb.LocationName, UrlOrTitle) || wb.HWND == UrlOrTitle) {
				Return wb
			}
		}
	}
}

#f::
	WinGet, winHwnd, ID, A
	pwb := IEGet(winHwnd)

; Notes
	TextField := pwb.document.getElementById("arid_WIN_2_1000000151").click()	; Clicks on comments field
	Send User After logging into the computer, it seems as though the Citrix online plug-in has not fully loaded and therefore, there are no working icons on the desktop.  When searching the Start Menu for the plug-in icon, there are no icons accessible on the computer.
	;TextField.Value := "User needs new workflow to get to website."

Sleep 300

; Summary
	pwb.Document.getElementById("arid_WIN_2_1000000000").Focus()
	TextField := pwb.document.getElementById("arid_WIN_2_1000000000")	; summary field
	pwb.Document.getElementById("arid_WIN_2_1000000000").click()
	Send Computer missing all icons/Generic computer
	;TextField.Value := "Computer missing all icons/Generic computer"

Sleep 300

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

Sleep 300

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

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

; Assign to Me
	pwb.document.getElementById("WIN_2_303684100").click() 		

; Status
	pwb.document.getElementById("arid_WIN_2_7").Focus()
	pwb.document.getElementById("arid_WIN_2_7").click()	
	Send {Down 5}
	Sleep 200
	Send {Enter}
	; pwb.document.getElementById("arid_WIN_2_7").value :="Resolved"

; Status Reason
	pwb.document.getElementById("arid_WIN_2_1000000881").Focus()
	pwb.document.getElementById("arid_WIN_2_1000000881").click()	
	Send {Down 4}
	Sleep 200
	Send {Enter}
	pwb.document.getElementById("arid_WIN_2_1000000881").value :="First Contact Resolution"

Sleep 300

; Resolution
	pwb.Document.getElementById("arid_WIN_2_1000000156").Focus()
	TextField := pwb.document.getElementById("arid_WIN_2_1000000156")		; Clicks on resolution field
	pwb.Document.getElementById("arid_WIN_2_1000000156").click()
	Send CMD > explorer c: > Program Files > Citrix > ICA Client > pnamain.exe
	; TextField.Value := "Ended Citrix via the task manager.  Re-launched pnamain.exe."		

Sleep 300

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

; Categorization Tab

	Tabs := pwb.document.getElementById("WIN_2_1000000200").getElementsByClassName("btn f1")
	Tabs[1].click()

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

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

Sleep 200

	; Tier 3
		TextField := pwb.document.getElementById("arid_WIN_2_1000000065").focus()	
		TextField := pwb.document.getElementById("arid_WIN_2_1000000065").click()
		Send Function Missing
		TextField.Value := "Function Missing"

Sleep 200

; Resolution Categorization
	; Tier 1
		TextField := pwb.document.getElementById("arid_WIN_2_1000002488").focus()	
		TextField := pwb.document.getElementById("arid_WIN_2_1000002488").click()
		Send Restore
		TextField.Value := "Restore"
	
	Sleep 200

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

Sleep 200

; Product Categorization

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

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

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

Sleep 200

	; Product Name
		pwb.Document.getElementById("arid_WIN_2_240001002").Focus()
		TextField := pwb.document.getElementById("arid_WIN_2_240001002")		
		pwb.Document.getElementById("arid_WIN_2_240001002").click()
		Send Desktop
		TextField.Value := "Desktop"

; Resolution Product Categorization


	; Tier 1
		pwb.Document.getElementById("arid_WIN_2_1000003891").Focus()
		TextField := pwb.document.getElementById("arid_WIN_2_1000003891")		
		pwb.Document.getElementById("arid_WIN_2_1000003891").click()
		;Send Software Infrastructure
		TextField.Value := "Software Infrastructure"
	
Sleep 200

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

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

Sleep 200

	; Product Name
		pwb.Document.getElementById("arid_WIN_2_1000003894").Focus()
		TextField := pwb.document.getElementById("arid_WIN_2_1000003894")		
		pwb.Document.getElementById("arid_WIN_2_1000003894").click()
		Send Citrix
		;TextField.Value := "Citrix"

ExitApp
User avatar
tank
Posts: 3128
Joined: 28 Sep 2013, 22:15
Location: CarrolltonTX
Contact:

Re: IEGet() vs WBGet()

05 Sep 2017, 12:18

you need a way to differentiate those tabs. How do you as a user know which one you want
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()

05 Sep 2017, 12:21

I guess I forgot to add, I open 2-3 instances of the same webpage. It's a hospital help desk so we could get calls back to back and I need to have a ticket open always. Is it even possible to differentiate them then considering they both have the same title? Is there a way to just get the active tab regardless of the 2 tabs with the same title?
User avatar
tank
Posts: 3128
Joined: 28 Sep 2013, 22:15
Location: CarrolltonTX
Contact:

Re: IEGet() vs WBGet()

05 Sep 2017, 12:51

use WBGet then instead
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
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: IEGet() vs WBGet()

05 Sep 2017, 12:54

If one tab is always active and the other isn't, you could use WBGet, and specify which Internet Explorer_Server control to use.

One thing you could do to differentiate tabs is get/set the zoom percentage:
Internet Explorer get/set zoom/text size - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 74#p165674

Another thing is to have the tabs open in different windows (different hWnds).
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()

05 Sep 2017, 13:00

I would like to just have multiple tabs open rather then windows if that's possible, jeeswg.

Yep, one tab will always be active and the other one will always be inactive. Could I post my code for some help? Capn Odin helped me a ton with the original code as I am new to AHK and COM!

Code: Select all

IEGet(UrlOrTitle){
	for wb in ComObjCreate("Shell.Application").Windows() {
		if(InStr(wb.FullName, "iexplore.exe")) {
			if(UrlOrTitle == "" || InStr(wb.LocationURL, UrlOrTitle) || InStr(wb.LocationName, UrlOrTitle) || wb.HWND == UrlOrTitle) {
				Return wb
			}
		}
	}
}

#f::
	WinGet, winHwnd, ID, A
	pwb := IEGet(winHwnd)

; Notes
	TextField := pwb.document.getElementById("arid_WIN_2_1000000151").click()	; Clicks on comments field
	Send password reset.
	;TextField.Value := "Directed them to website."	

Sleep 300

; Summary
	pwb.Document.getElementById("arid_WIN_2_1000000000").Focus()
	TextField := pwb.document.getElementById("arid_WIN_2_1000000000")	; summary field
	pwb.Document.getElementById("arid_WIN_2_1000000000").click()
	Send password reset request
	;TextField.Value := "password reset request"

Sleep 300

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

Sleep 300

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

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

; Assign to Me
	pwb.document.getElementById("WIN_2_303684100").click() 		

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

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

Sleep 300

; Resolution
	pwb.Document.getElementById("arid_WIN_2_1000000156").Focus()
	TextField := pwb.document.getElementById("arid_WIN_2_1000000156")		; Clicks on resolution field
	pwb.Document.getElementById("arid_WIN_2_1000000156").click()
	Send Called to NHD.
	; TextField.Value := "Ended Citrix via the task manager.  Re-launched pnamain.exe."		

Sleep 300

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

; Categorization Tab

	Tabs := pwb.document.getElementById("WIN_2_1000000200").getElementsByClassName("btn f1")
	Tabs[1].click()

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

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

Sleep 200

; Product Categorization

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

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

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

Sleep 200

	; Product Name
		pwb.Document.getElementById("arid_WIN_2_240001002").Focus()
		TextField := pwb.document.getElementById("arid_WIN_2_240001002")		
		pwb.Document.getElementById("arid_WIN_2_240001002").click()
		Send Desktop
		Sleep 300
		Send {Down}
		Sleep 175
		Send {Enter}
		; TextField.Value := "Desktop"

ExitApp
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: IEGet() vs WBGet()

06 Sep 2017, 13:38

So one thing you could do is to try and leave a marker of some kind on a tab, that you can retrieve via an object loop.

E.g. you could set the zoom for window 1 to 101%, for window 2 to 102%. There may be some other changes you could make, but I can't immediately think of any.

Code: Select all

q:: ;internet explorer - get zoom percent
vOutput := ""
for oWB in ComObjCreate("Shell.Application").Windows
	if (oWB.Name = "Internet Explorer")
	{
		vLogicalXDPI := oWB.document.parentWindow.screen.logicalXDPI
		vDeviceXDPI := oWB.document.parentWindow.screen.deviceXDPI
		vZoom := Round(vDeviceXDPI / vLogicalXDPI * 100)
		vOutput .= vZoom "`r`n" oWB.document.title "`r`n" oWB.document.url "`r`n`r`n"
	}
oWB := ""
MsgBox, % vOutput
return

w:: ;internet explorer - set zoom percent (and text size)
WinGet, hWnd, ID, A
oWB := WBGet("ahk_id " hWnd)
;OLECMDID_OPTICAL_ZOOM := 63 ;(zoom % e.g. 100, 135)
;OLECMDID_ZOOM := 19 ;(text size 0/1/2/3/4)
;vZoom := 130, vTextSize := 2
vZoom := 101
oWB.ExecWB(63, 2, vZoom, 0)
;oWB.ExecWB(19, 2, vTextSize, 0)
oWB := ""
return
==================================================

You could also refer to IE tabs by the control hWnd, the number will remain consistent until you close the tab.

Code: Select all

q::
WinGet, hWnd, ID, A
vOutput := ""
Loop
{
	ControlGet, hCtl, Hwnd,, % "Internet Explorer_Server" A_Index, % "ahk_id " hWnd
	if !hCtl
		break
	oWB := WBGet("ahk_id " hWnd, A_Index)
	vOutput .= hCtl "`r`n" oWB.document.title "`r`n" oWB.document.url "`r`n`r`n"
}
oWB := ""
MsgBox, % vOutput
return
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, 19:47

Awesome, I got it working! Perfect! Thank you!

Would there be a way to put all my text fields IDs into a separate main text file and then within my main big script code, put a variable? I ask because if ID fields change on the website, I will need to change all the text field IDs every script I created.

Part of my main code:

Code: Select all

TextField := pwb.document.getElementById("arid_WIN_2_1000000151").click()	
	TextField.Value := "User needs new workflow to get to website."
.txt file within the same folder as my main code:

something to the extent of:
variables.txt (file name)
var1 = arid_WIN_2_1000000151

Then my main script code file would be (example):

Code: Select all

TextField := pwb.document.getElementById("var1").click()	
	TextField.Value := "User needs new workflow to get to website."
Is it possible for AHk to read variables from another .txt file?
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: IEGet() vs WBGet()

06 Sep 2017, 20:19

You could look into IniRead, or #Include, or just keep all the changing variables at the top of the file for easy access.
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, 20:30

I looked into the #include (because I have probably 10 ID fields along probably 15 scripts) but wasn't sure if my .txt file has to include anything special other then:

example:

resolution=idnameoffield
notes=idnameoffield
and so on....

Also, would anything special need to be added into my code at the top other then?:

Code: Select all

#include variables.txt
Then an example line would look like:

Code: Select all

pwb.Document.getElementById(%summary%).Focus()
	TextField := pwb.document.getElementById(%summary%)	
	pwb.Document.getElementById(%summary%).click()
I tried all the above but had no luck :?

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: UncouthGoose and 121 guests